X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=docs%2Fmanual%2Fmod%2Fmod_auth_form.html.en;h=0922e25f32158ebf507b2e10b4f2998394342d53;hb=0ae5b1af6b6bf3048d2a124e84905f63d6507dea;hp=c62ebb9ec0fcc89af10a9b85f8735f0ccb5e6941;hpb=b55229f0bc1580738cf6d412d32707da0bbe1611;p=apache diff --git a/docs/manual/mod/mod_auth_form.html.en b/docs/manual/mod/mod_auth_form.html.en index c62ebb9ec0..0922e25f32 100644 --- a/docs/manual/mod/mod_auth_form.html.en +++ b/docs/manual/mod/mod_auth_form.html.en @@ -1,32 +1,39 @@ - -mod_auth_form - Apache HTTP Server +mod_auth_form - Apache HTTP Server Version 2.5 - + + + + +

Apache HTTP Server Version 2.5

+
<-
-Apache > HTTP Server > Documentation > Version 2.3 > Modules
+Apache > HTTP Server > Documentation > Version 2.5 > Modules

Apache Module mod_auth_form

-

Available Languages:  en 

+

Available Languages:  en  | + fr 

-
Description:Form authentication
Status:Base
Module Identifier:auth_form_module
Source File:mod_auth_form.c
+Source File:mod_auth_form.c +Compatibility:Available in Apache 2.3 and later

Summary

Warning

@@ -54,9 +61,17 @@

Once the user has been successfully authenticated, the user's login details will be stored in a session provided by mod_session.

- +
-
top

Basic Configuration

- +

To protect a particular URL with mod_auth_form, you need to decide where you will store your session, and you will need to decide what method you will use to authenticate. In this simple example, the @@ -101,25 +108,24 @@ mod_session_cookie, and authentication will be attempted against a file using mod_authn_file. If authentication is unsuccessful, the user will be redirected to the form login page.

- -

Basic example

- AuthFormProvider file
- AuthUserFile conf/passwd
- AuthType form
- AuthName realm
- AuthFormLoginRequiredLocation http://example.com/login.html
- Session On
- SessionCookieName session path=/
- SessionCryptoPassphrase secret
-

- + +

Basic example

AuthFormProvider file
+AuthUserFile "conf/passwd"
+AuthType form
+AuthName realm
+AuthFormLoginRequiredLocation "http://example.com/login.html"
+Session On
+SessionCookieName session path=/
+SessionCryptoPassphrase secret
+
+

The directive AuthType will enable the mod_auth_form authentication when set to the value form. The directives AuthFormProvider and AuthUserFile specify that usernames and passwords should be checked against the chosen file.

-

The directives Session, +

The directives Session, SessionCookieName and SessionCryptoPassphrase create an encrypted session stored within an HTTP cookie on the browser. For more information @@ -137,69 +143,62 @@

The login form can be hosted as a standalone page, or can be provided inline on the same page.

- +

When configuring the login as a standalone page, unsuccessful authentication attempts should be redirected to a login form created by the website for this purpose, using the AuthFormLoginRequiredLocation directive. Typically this login page will contain an HTML form, asking the user to provide their usename and password.

- -

Example login form

- <form method="POST" action="/dologin.html">
- Username: <input type="text" name="httpd_username" value="" />
- Password: <input type="password" name="httpd_password" value="" />
- <input type="submit" name="login" value="Login" />
- </form>
-

+ +

Example login form

<form method="POST" action="/dologin.html">
+  Username: <input type="text" name="httpd_username" value="" />
+  Password: <input type="password" name="httpd_password" value="" />
+  <input type="submit" name="login" value="Login" />
+</form>
+

The part that does the actual login is handled by the form-login-handler. The action of the form should point at this handler, which is configured within - Apache as follows:

- -

Form login handler example

- <Location /dologin.html> - - SetHandler form-login-handler
- AuthFormLoginRequiredLocation http://example.com/login.html
- AuthFormLoginSuccessLocation http://example.com/success.html
- AuthFormProvider file
- AuthUserFile conf/passwd
- AuthType form
- AuthName realm
- Session On
- SessionCookieName session path=/
- SessionCryptoPassphrase secret
-
- </Location> -

+ Apache httpd as follows:

+ +

Form login handler example

<Location "/dologin.html">
+    SetHandler form-login-handler
+    AuthFormLoginRequiredLocation "http://example.com/login.html"
+    AuthFormLoginSuccessLocation "http://example.com/success.html"
+    AuthFormProvider file
+    AuthUserFile "conf/passwd"
+    AuthType form
+    AuthName realm
+    Session On
+    SessionCookieName session path=/
+    SessionCryptoPassphrase secret
+</Location>
+

The URLs specified by the AuthFormLoginRequiredLocation directive will typically point to a page explaining to the user that their login attempt was unsuccessful, and they should try again. The AuthFormLoginSuccessLocation directive specifies the URL the user should be redirected to upon successful login.

- +

Alternatively, the URL to redirect the user to on success can be embedded within the login form, as in the example below. As a result, the same form-login-handler can be reused for different areas of a website.

-

Example login form with location

- <form method="POST" action="/dologin.html">
- - Username: <input type="text" name="httpd_username" value="" />
- Password: <input type="password" name="httpd_password" value="" />
- <input type="submit" name="login" value="Login" />
- <input type="hidden" name="httpd_location" value="http://example.com/success.html" />
-
- </form>
-

+

Example login form with location

<form method="POST" action="/dologin.html">
+  Username: <input type="text" name="httpd_username" value="" />
+  Password: <input type="password" name="httpd_password" value="" />
+  <input type="submit" name="login" value="Login" />
+  <input type="hidden" name="httpd_location" value="http://example.com/success.html" />
+</form>
+
top

Inline Login

- +

Warning

-

A risk exists that under certain circumstances, the login form configured +

A risk exists that under certain circumstances, the login form configured using inline login may be submitted more than once, revealing login credentials to the application running underneath. The administrator must ensure that the underlying application is properly secured to prevent abuse. If in doubt, use the @@ -218,37 +217,33 @@ AuthFormLoginRequiredLocation directive, a HTTP_UNAUTHORIZED status code is returned to the browser indicating to the user that they are not authorized to view the page.

- +

To configure inline authentication, the administrator overrides the error document returned by the HTTP_UNAUTHORIZED status code with a custom error document containing the login form, as follows:

-

Basic inline example

- AuthFormProvider file
- ErrorDocument 401 /login.shtml
- AuthUserFile conf/passwd
- AuthType form
- AuthName realm
- AuthFormLoginRequiredLocation http://example.com/login.html
- Session On
- SessionCookieName session path=/
- SessionCryptoPassphrase secret
-

- +

Basic inline example

AuthFormProvider file
+ErrorDocument 401 "/login.shtml"
+AuthUserFile "conf/passwd"
+AuthType form
+AuthName realm
+AuthFormLoginRequiredLocation "http://example.com/login.html"
+Session On
+SessionCookieName session path=/
+SessionCryptoPassphrase secret
+
+

The error document page should contain a login form with an empty action property, as per the example below. This has the effect of submitting the form to the original protected URL, without the page having to know what that URL is.

-

Example inline login form

- <form method="POST" action="">
- - Username: <input type="text" name="httpd_username" value="" />
- Password: <input type="password" name="httpd_password" value="" />
- <input type="submit" name="login" value="Login" />
-
- </form>
-

+

Example inline login form

<form method="POST" action="">
+  Username: <input type="text" name="httpd_username" value="" />
+  Password: <input type="password" name="httpd_password" value="" />
+  <input type="submit" name="login" value="Login" />
+</form>
+

When the end user has filled in their login details, the form will make an HTTP POST request to the original password protected URL. @@ -270,41 +265,37 @@

mod_auth_form addresses this by allowing the method and body of the original request to be embedded in the login form. If authentication - is successful, the original method and body will be retried by Apache, preserving + is successful, the original method and body will be retried by Apache httpd, preserving the state of the original request.

To enable body preservation, add three additional fields to the login form as per the example below.

-

Example with body preservation

- <form method="POST" action="">
- - Username: <input type="text" name="httpd_username" value="" />
- Password: <input type="password" name="httpd_password" value="" />
- <input type="submit" name="login" value="Login" />
- <input type="hidden" name="httpd_method" value="POST" />
- <input type="hidden" name="httpd_mimetype" value="application/x-www-form-urlencoded" />
- <input type="hidden" name="httpd_body" value="name1=value1&name2=value2" />

-
- </form> -

+

Example with body preservation

<form method="POST" action="">
+  Username: <input type="text" name="httpd_username" value="" />
+  Password: <input type="password" name="httpd_password" value="" />
+  <input type="submit" name="login" value="Login" />
+  
<input type="hidden" name="httpd_method" value="POST" /> + <input type="hidden" name="httpd_mimetype" value="application/x-www-form-urlencoded" /> + <input type="hidden" name="httpd_body" value="name1=value1&name2=value2" />
+</form>
+

How the method, mimetype and body of the original request are embedded within the login form will depend on the platform and technology being used within the website.

One option is to use the mod_include module along with the - KeptBodySize directive, along with a suitable + KeptBodySize directive, along with a suitable CGI script to embed the variables in the form.

- +

Another option is to render the login form using a CGI script or other dynamic technology.

-

CGI example

- AuthFormProvider file
- ErrorDocument 401 /cgi-bin/login.cgi
- ...
-

+

CGI example

        AuthFormProvider file
+        ErrorDocument 401 "/cgi-bin/login.cgi"
+        ...
+
top
@@ -321,14 +312,13 @@ logout. This URL might explain to the user that they have been logged out, and give the user the option to log in again.

-

Basic logout example

- SetHandler form-logout-handler
- AuthName realm
- AuthFormLogoutLocation http://example.com/loggedout.html
- Session On
- SessionCookieName session path=/
- SessionCryptoPassphrase secret
-

+

Basic logout example

SetHandler form-logout-handler
+AuthName realm
+AuthFormLogoutLocation "http://example.com/loggedout.html"
+Session On
+SessionCookieName session path=/
+SessionCryptoPassphrase secret
+

Note that logging a user out does not delete the session; it merely removes the username and password from the session. If this results in an empty session, @@ -338,15 +328,21 @@ value, like 1 (setting the directive to zero would mean no session age limit).

-

Basic session expiry example

- SetHandler form-logout-handler
- AuthFormLogoutLocation http://example.com/loggedout.html
- Session On
- SessionMaxAge 1
- SessionCookieName session path=/
- SessionCryptoPassphrase secret
-

+

Basic session expiry example

SetHandler form-logout-handler
+AuthFormLogoutLocation "http://example.com/loggedout.html"
+Session On
+SessionMaxAge 1
+SessionCookieName session path=/
+SessionCryptoPassphrase secret
+
+
top
+
+

Usernames and Passwords

+

Note that form submission involves URLEncoding the form data: + in this case the username and password. You should therefore + pick usernames and passwords that avoid characters that are + URLencoded in form submission, or you may get unexpected results.

top

AuthFormAuthoritative Directive

@@ -383,14 +379,14 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormMethod directive specifies the name of an HTML field which, if present, will contain the method of the request to to submit should login be successful.

By populating the form with fields described by - AuthFormMethod, + AuthFormMethod, AuthFormMimetype and AuthFormBody, a website can retry a request that may have been interrupted by the login screen, or by a session @@ -406,12 +402,12 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormDisableNoStore flag disables the sending of a Cache-Control no-store header with the error 401 page returned when the user is not yet logged in. The purpose of the header - is to make it difficult for an ecmascript application to attempt to resubmit the + is to make it difficult for an ecmascript application to attempt to resubmit the login form, and reveal the username and password to the backend application. Disable at your own risk.

@@ -426,7 +422,7 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormFakeBasicAuth flag determines whether a Basic Authentication header will be added to @@ -445,7 +441,7 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormLocation directive specifies the name of an HTML field which, if present, will contain a URL to redirect the browser to @@ -461,15 +457,17 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later. The use of the expression +parser has been added in 2.4.4.

The AuthFormLoginRequiredLocation directive - specifies the URL to redirect to should the user not be authorised to view a page. By default, - if a user is not authorised to view a page, the HTTP response code HTTP_UNAUTHORIZED - will be returned with the page specified by the + specifies the URL to redirect to should the user not be authorised to view a page. The value + is parsed using the ap_expr parser before being sent to the client. + By default, if a user is not authorised to view a page, the HTTP response code + HTTP_UNAUTHORIZED will be returned with the page specified by the ErrorDocument directive. This directive overrides this default.

- +

Use this directive if you have a dedicated login page to redirect users to.

@@ -483,13 +481,15 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later. The use of the expression +parser has been added in 2.4.4.

The AuthFormLoginSuccessLocation directive - specifies the URL to redirect to should the user have logged in successfully. This directive - can be overridden if a form field has been defined containing another URL using the - AuthFormLocation directive.

- + specifies the URL to redirect to should the user have logged in successfully. The value is + parsed using the ap_expr parser before being sent to the client. + This directive can be overridden if a form field has been defined containing another URL + using the AuthFormLocation directive.

+

Use this directive if you have a dedicated login URL, and you have not embedded the destination page in the login form.

@@ -504,25 +504,25 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later. The use of the expression +parser has been added in 2.4.4.

The AuthFormLogoutLocation directive - specifies the URL of a page on the server to redirect to should the user attempt to log out.

+ specifies the URL of a page on the server to redirect to should the user attempt to log + out. The value is parsed using the ap_expr parser before + being sent to the client.

When a URI is accessed that is served by the handler form-logout-handler, the page specified by this directive will be shown to the end user. For example:

- -

Example

- <Location /logout>
- - SetHandler form-logout-handler
- AuthFormLogoutLocation http://example.com/loggedout.html
- Session on
- ... -
- </Location> -

- + +

Example

<Location "/logout">
+    SetHandler form-logout-handler
+    AuthFormLogoutLocation "http://example.com/loggedout.html"
+    Session on
+    #...
+</Location>
+
+

An attempt to access the URI /logout/ will result in the user being logged out, and the page /loggedout.html will be displayed. Make sure that the page loggedout.html is not password protected, otherwise the page will not be @@ -539,14 +539,14 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormMethod directive specifies the name of an HTML field which, if present, will contain the method of the request to to submit should login be successful.

- +

By populating the form with fields described by - AuthFormMethod, + AuthFormMethod, AuthFormMimetype and AuthFormBody, a website can retry a request that may have been interrupted by the login screen, or by a session @@ -562,14 +562,14 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormMethod directive specifies the name of an HTML field which, if present, will contain the - mimetype of the request to to submit should login be successful.

+ mimetype of the request to submit should login be successful.

By populating the form with fields described by - AuthFormMethod, + AuthFormMethod, AuthFormMimetype and AuthFormBody, a website can retry a request that may have been interrupted by the login screen, or by a session @@ -585,7 +585,7 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormPassword directive specifies the name of an HTML field which, if present, will contain the password to be used to log @@ -604,29 +604,26 @@ lower level modules Status:Base Module:mod_auth_form -

The AuthFormProvider directive sets +

The AuthFormProvider directive sets which provider is used to authenticate the users for this location. The default file provider is implemented by the mod_authn_file module. Make sure that the chosen provider module is present in the server.

-

Example

- <Location /secure>
- - AuthType form
- AuthName "private area"
- AuthFormProvider dbm
- AuthDBMType SDBM
- AuthDBMUserFile /www/etc/dbmpasswd
- Require valid-user
- ...
-
- </Location> -

+

Example

<Location "/secure">
+    AuthType form
+    AuthName "private area"
+    AuthFormProvider  dbm
+    AuthDBMType        SDBM
+    AuthDBMUserFile    "/www/etc/dbmpasswd"
+    Require            valid-user
+    #...
+</Location>
+

Providers are implemented by mod_authn_dbm, mod_authn_file, mod_authn_dbd, - and mod_authnz_ldap.

+ mod_authnz_ldap and mod_authn_socache.

top
@@ -638,13 +635,13 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormSitePassphrase directive - specifies a passphrase which, if present in the user session, causes Apache to + specifies a passphrase which, if present in the user session, causes Apache httpd to bypass authentication checks for the given URL. It can be used on high traffic websites to reduce the load induced on authentication infrastructure.

- +

The passphrase can be inserted into a user session by adding this directive to the configuration for the form-login-handler. The form-login-handler itself will always run the authentication checks, regardless of whether a passphrase @@ -665,24 +662,24 @@ lower level modules

AuthFormSize Directive

- + - +
Description:The largest size of the form in bytes that will be parsed for the login details
Syntax:AuthFormBody size
Syntax:AuthFormSize size
Default:8192
Context:directory
Status:Base
Module:mod_auth_form
Compatibility:Available in Apache 2.3.0 and later
Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormSize directive specifies the maximum size of the body of the request that will be parsed to find the login form.

- +

If a login request arrives that exceeds this size, the whole request will be aborted with the HTTP response code HTTP_REQUEST_TOO_LARGE.

If you have populated the form with fields described by - AuthFormMethod, + AuthFormMethod, AuthFormMimetype and AuthFormBody, you probably want to set this - field to a similar size as the KeptBodySize + field to a similar size as the KeptBodySize directive.

@@ -696,7 +693,7 @@ lower level modules Context:directory Status:Base Module:mod_auth_form -Compatibility:Available in Apache 2.3.0 and later +Compatibility:Available in Apache HTTP Server 2.3.0 and later

The AuthFormUsername directive specifies the name of an HTML field which, if present, will contain the username to be used to log @@ -705,8 +702,30 @@ lower level modules

-

Available Languages:  en 

-
+

Available Languages:  en  | + fr 

+
top

Comments

Notice:
This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.
+
\ No newline at end of file