Difference between revisions of "Require Login"

From Amahi Wiki
Jump to: navigation, search
 
(43 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{MessageBox|
 
{{MessageBox|
backgroundcolor = red|
+
backgroundcolor = #faa|
 
image =Warning.png|
 
image =Warning.png|
 
heading =WARNING|
 
heading =WARNING|
 
message = This is recommended only for advanced users, proceed with caution.}}
 
message = This is recommended only for advanced users, proceed with caution.}}
Would you like to control which HDA users can access certain web applications?  While this function does not currently exist in Amahi, it can be done quite easily by following the steps outlined below.  When a user accesses the specific web application, they will be prompted for a user name and password.
+
<div style="border: 1px solid #A3B1BF; padding: .8em 1em; background-color: #E6F2FF; margin: 0px 1em;">
 +
'''NOTE:''' The one-click [https://www.amahi.org/apps/web-apps Web Apps] will provide this capability in Amahi 7 or greater.</div>
 +
 
 +
 
 +
Would you like to control which HDA users can access certain web applications?  This can be easily done in Amahi 6.  To use this function, select the web apps section in the apps tab.  Expand the desired app and select the '''Require login''' check box.  If selected, this settings makes it such that the application will ask for a user name and a password.  The perform the steps below to create the <code>htpasswd</code> file.
 +
 
 +
 
 +
'''NOTE:''' This is a global setting at the moment, i.e. the users and password are all the same to all the apps that have '''Require login''' selected.  This feature <u>IS NOT</u> compatible with [[Secure_App_Access|Access Web Apps over SSL]].
  
 
== How to do it ==
 
== How to do it ==
*This requires creation of two files (<code>.htaccess</code> and <code>.htpasswd</code>) be placed in the directory of each web application you want to protect.
+
This requires creation of the <code>htpasswd</code> be placed in the '''''/var/hda/web-apps''''' directoryThe <code>htpasswd</code> file will identify user names and passwords (encrypted).
*The <code>.htpasswd</code> file will identify user names/passwords (encrypted) and the <code>.htaccess</code> file  will contain the code needed to use that file to protect the web application.
+
 
#First you need to identify the web application you want to protect and it's physical location ('''''/var/hda/web-app/appname''''') on your serverFor example, the path for '''Linfo''' would be '''''/var/hda/web-app/linfo'''''.
+
 
#Next, you need to decide on the user names/passwords who will have access. This has to be the HDA users credentials that are used to log into the HDA Dashboard. 
+
==== Create the htpasswd File ====
==== Create the Files ====
+
There are two options for creating the <code>htpasswd</code> file:
There are two options for creating the <code>.htpasswd</code> and <code>.htaccess</code> files:
+
*Option 1:  Navigate to [http://www.htaccesstools.com/htpasswd-generator/ htpasswd Generator].
*Option 1:  Navigate to [http://www.webmaster-toolkit.com/htaccess-generator.shtml .htaccess Generator].
 
 
<blockquote>
 
<blockquote>
*Enter desired Username, Password, and Path (physical location where <code>.htpasswd</code> will be stored).  For example, Username '''''amahi''''', Password '''''amahi''''', and Path '''''/var/hda/web-apps/linfo'''''.
+
*Enter desired Username, Password, and Path (physical location where <code>.htpasswd</code> will be stored).  For example, Username '''''amahi''''', Password '''''amahi''''', and Path '''''/var/hda/web-apps'''''.
 
*Select the '''Generate .htaccess''' button.
 
*Select the '''Generate .htaccess''' button.
*Create <code>.htacess</code> file in the web application html directory (i.e. '''''/var/hda/web-apps/linfo/html'''''). Copy the text in ''"This is what your .htaccess file should look like..."'' box and paste it into the <code>.htacess</code> file (i.e. '''''/var/hda/web-apps/linfo/html''''').  It should look similar to this:
+
*Copy the text from ''"And this is what your .htpasswd file should look like..."'' box and paste it into the <code>.htpasswd</code> file.  It should look similar to this:  
{{Text|AuthUserFile /var/hda/web-apps/linfo/.htpasswd
+
<pre>amahi:amb24e1pXrqFY</pre>
AuthGroupFile /dev/null
+
*Proceed to the '''Copy and Set File Permissions''' section to complete.
AuthName "Password Protected Area"
 
AuthType Basic
 
<limit GET POST>
 
require valid-user
 
</limit>}}
 
*Next create <code>.htpasswd</code> file in then web application directory (i.e. '''''/var/hda/web-apps/linfo''''').  Copy the text from ''"And this is what your .htpasswd file should look like..."'' box and paste it into the <code>.htpasswd</code> file (i.e. '''''/var/hda/web-apps/linfo''''').  It should look similar to this:  
 
{{Text|amahi:amb24e1pXrqFY}}
 
*Proceed to the '''Set the Permissions''' section to complete.
 
 
</blockquote>
 
</blockquote>
*Option 2:   
+
*Option 2:  [[Open_Terminal_as_root|Open Terminal as root user]]
 
<blockquote>
 
<blockquote>
*Perform the following steps [[Open_Terminal_as_root|as root user]] (change '''username''', '''password''', and '''appname''' as appropriate):
+
*Create the <code>htpasswd</code> file (change username and password):
{{Code|htpasswd -c -b /var/hda/web-apps/appname/.htpasswd username password}}
+
<pre>htpasswd -c -b .htpasswd username password</pre>
 +
*Proceed to the '''Copy and Set File Permissions''' section to complete.
 +
</blockquote>
 +
 
 +
==== User Maintenance (Add/Delete) ====
 
*Add additional users, repeat the previous step ('''NOTE:''' the -c option is only needed the first time you create the file for that web application):
 
*Add additional users, repeat the previous step ('''NOTE:''' the -c option is only needed the first time you create the file for that web application):
{{Code|htpasswd -b /var/hda/web-apps/appname/.htpasswd username password}}
+
htpasswd -b /var/hda/web-apps/htpasswd username password
 
*Delete a user, do the following:
 
*Delete a user, do the following:
  {{Code|htpasswd -D /var/hda/web-apps/appname/.htpasswd username}}
+
  htpasswd -D /var/hda/web-apps/htpasswd username
*Create the <code>.htaccess</code> file in the '''''/var/hda/web-apps/appname/html''''' directory (change '''appname''' in ''AuthName'' and ''AuthUserFile'' lines; i.e. '''Linfo''' and '''linfo''' respectively):
+
 
{{Text|AuthName "appname Access"
+
==== Copy and Set File permissions: ====
AuthType Basic
+
*Copy the <code>.htpasswd</code> file to the web application directory:
AuthUserFile /var/hda/web-apps/appname/.htpasswd
+
cp .htpasswd /var/hda/web-apps/htpasswd
require valid-user}}
+
* Ensure the permissions are correctly set on the two files as follows:
</blockquote>
+
chmod 600 /var/hda/web-apps/htpasswd
 +
chown apache:apache /var/hda/web-apps/htpasswd
 +
 
 +
==== If you have Webmin installed ====
  
==== Set File permissions: ====
+
*After logging into Webmin select “Others” on the left-hand side, click on “Protected Web Directories” and then select “Add protection for a new directory”.
* Ensure the permissions are correctly set on the two files as follows (change '''appname''' as appropriate):
+
*In ''"Directory path"'' browse to/or enter the path to the <code>html</code> web directory you wish to protect, in ''“Authentication realm”'' enter something like for example ''“Authentication required”'' (this will show up on the popup login box) and then click on create.
{{Code|chmod 600 /var/hda/web-apps/appname/.htpasswd
+
*Now you need to setup users to allow login by clicking on ''“Add a new user”'' in ''“Associated users and groups”'', when users have been created you should be good to go.
chmod 600 /var/hda/web-apps/appname/html/.htaccess
 
chown apache:apache /var/hda/web-apps/appname/.htpasswd
 
chown apache:users /var/hda/web-apps/appname/html/.htaccess}}
 
  
* That's all there is to it.  Now when a HDA user accesses the web application, they will be greeted with a pop windows asking for user name and password.  If you uninstall the app, the <code>.htpasswd</code> and <code>.htaccess</code> files will be removed as well.
 
  
==== Future Considerations ====
+
'''NOTE:''' After you have completed this process using Webmin you can then select ''"un-protect selected directory"'' and use the HDA-Dashboard to enable/disable password protection.
* Add a share to hold all .htpasswd files. Rename .htpasswd to .appname in order to keep them separate.
 
* Locate a web application to create/manage .htpasswd files (DirectoryPass or htaccess generator)
 
* Integrate with Amahi Dashboard to do all this via GUI.
 

Latest revision as of 02:23, 8 August 2019

Warning.png WARNING
This is recommended only for advanced users, proceed with caution.


NOTE: The one-click Web Apps will provide this capability in Amahi 7 or greater.


Would you like to control which HDA users can access certain web applications? This can be easily done in Amahi 6. To use this function, select the web apps section in the apps tab. Expand the desired app and select the Require login check box. If selected, this settings makes it such that the application will ask for a user name and a password. The perform the steps below to create the htpasswd file.


NOTE: This is a global setting at the moment, i.e. the users and password are all the same to all the apps that have Require login selected. This feature IS NOT compatible with Access Web Apps over SSL.

How to do it

This requires creation of the htpasswd be placed in the /var/hda/web-apps directory. The htpasswd file will identify user names and passwords (encrypted).


Create the htpasswd File

There are two options for creating the htpasswd file:

  • Enter desired Username, Password, and Path (physical location where .htpasswd will be stored). For example, Username amahi, Password amahi, and Path /var/hda/web-apps.
  • Select the Generate .htaccess button.
  • Copy the text from "And this is what your .htpasswd file should look like..." box and paste it into the .htpasswd file. It should look similar to this:
amahi:amb24e1pXrqFY
  • Proceed to the Copy and Set File Permissions section to complete.
  • Create the htpasswd file (change username and password):
htpasswd -c -b .htpasswd username password
  • Proceed to the Copy and Set File Permissions section to complete.

User Maintenance (Add/Delete)

  • Add additional users, repeat the previous step (NOTE: the -c option is only needed the first time you create the file for that web application):
htpasswd -b /var/hda/web-apps/htpasswd username password
  • Delete a user, do the following:
htpasswd -D /var/hda/web-apps/htpasswd username

Copy and Set File permissions:

  • Copy the .htpasswd file to the web application directory:
cp .htpasswd /var/hda/web-apps/htpasswd
  • Ensure the permissions are correctly set on the two files as follows:
chmod 600 /var/hda/web-apps/htpasswd
chown apache:apache /var/hda/web-apps/htpasswd

If you have Webmin installed

  • After logging into Webmin select “Others” on the left-hand side, click on “Protected Web Directories” and then select “Add protection for a new directory”.
  • In "Directory path" browse to/or enter the path to the html web directory you wish to protect, in “Authentication realm” enter something like for example “Authentication required” (this will show up on the popup login box) and then click on create.
  • Now you need to setup users to allow login by clicking on “Add a new user” in “Associated users and groups”, when users have been created you should be good to go.


NOTE: After you have completed this process using Webmin you can then select "un-protect selected directory" and use the HDA-Dashboard to enable/disable password protection.