<-
Apache > HTTP Server > Documentation > Modules

Apache Module mod_auth_basic 325j6

Available Languages:  ko 

Description: Basic HTTP authentication
Status: Base
Module Identifier: auth_basic_module
Source File: mod_auth_basic.c
Compatibility: Available in Apache 2.1 and later

Summary 6m2os

This module allows the use of HTTP Basic Authentication to restrict access by looking up s in the given providers. HTTP Digest Authentication is provided by mod_authz_.

 Apache!

Directives 1a4l6m

Bugfix checklist 4i2533

See also 27136x

top

AuthBasicAuthoritative Directive y6i4s

Description: Sets whether authorization and authentication are ed to lower level modules
Syntax: AuthBasicAuthoritative On|Off
Default: AuthBasicAuthoritative On
Context: directory, .htaccess
Override: AuthConfig
Status: Base
Module: mod_auth_basic

Normally, each authorization module listed in AuthBasirovider directive. When using such modules, the order of processing is determined in the modules' source code and is not configurable.

top

AuthBasicFake Directive 3q866

Description: Fake basic authentication using the given expressions for name and
Syntax: AuthBasicFake off|name []
Default: none
Context: directory, .htaccess
Override: AuthConfig
Status: Base
Module: mod_auth_basic
Compatibility: Apache HTTP Server 2.4.5 and later

The name and specified are combined into an Authorization header, which is ed to the server or service behind the webserver. Both the name and fields are interpreted using the expression parser, which allows both the name and to be set based on request parameters.

If the is not specified, the default value "" will be used. To disable fake basic authentication for an URL space, specify "AuthBasicFake off".

In this example, we a fixed name and to a backend server.

Fixed Example 331g69

<Location "/demo">
    AuthBasicFake demo demo
</Location>

In this example, we the email address extracted from a client certificate, extending the functionality of the FakeBasicAuth option within the SSLOptions directive. Like the FakeBasicAuth option, the is set to the fixed string "".

Certificate Example 574f5d

<Location "/secure">
    AuthBasicFake "%{SSL_CLIENT_S_DN_Email}"
</Location>

Extending the above example, we generate a by hashing the email address with a fixed phrase, and ing the hash to the backend server. This can be used to gate into legacy systems that do not client certificates.

Example 5u583m

<Location "/secure">
    AuthBasicFake "%{SSL_CLIENT_S_DN_Email}" "%{sha1:phrase-%{SSL_CLIENT_S_DN_Email}}"
</Location>

Exclusion Example 1n294s

<Location "/public">
    AuthBasicFake off
</Location>
top

AuthBasirovider Directive 1w726g

Description: Sets the authentication provider(s) for this location
Syntax: AuthBasirovider provider-name [provider-name] ...
Default: AuthBasirovider file
Context: directory, .htaccess
Override: AuthConfig
Status: Base
Module: mod_auth_basic

The AuthBasirovider directive sets which provider is used to authenticate the s 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 5z1g6h

<Location "/secure">
    AuthType basic
    AuthName "private area"
    AuthBasirovider  dbm
    AuthDBMType        SDBM
    AuthDBMFile    "/www/etc/dbmwd"
    Require            valid-
</Location>

Providers are queried in order until a provider finds a match for the requested name, at which point this sole provider will attempt to check the . A failure to the does not result in control being ed on to subsequent providers.

Providers are implemented by mod_authn_socache.

top

AuthBasicUseDigestAlgorithm Directive j521a

Description: Check s against the authentication providers as if Digest Authentication was in force instead of Basic Authentication.
Syntax: AuthBasicUseDigestAlgorithm MD5|Off
Default: AuthBasicUseDigestAlgorithm Off
Context: directory, .htaccess
Override: AuthConfig
Status: Base
Module: mod_auth_basic
Compatibility: Apache HTTP Server 2.4.7 and later

Normally, when using Basic Authentication, the providers listed in AuthBasirovider attempt to a by checking their data stores for a matching name and associated . The stored s are usually encrypted, but not necessarily so; each provider may choose its own storage scheme for s.

When using AuthDigestProvider and Digest Authentication, providers perform a similar check to find a matching name in their data stores. However, unlike in the Basic Authentication case, the value associated with each stored name must be an encrypted string composed from the name, realm name, and . (See RFC 2617, Section 3.2.2.2 for more details on the format used for this encrypted string.)

As a consequence of the difference in the stored values between Basic and Digest Authentication, converting from Digest Authentication to Basic Authentication generally requires that all s be assigned new s, as their existing s cannot be recovered from the storage scheme imposed on those providers which Digest Authentication.

Setting the AuthBasicUseDigestAlgorithm directive to MD5 will cause the 's Basic Authentication to be checked using the same encrypted format as for Digest Authentication. First a string composed from the name, realm name, and is hashed with MD5; then the name and this encrypted string are ed to the providers listed in AuthType was set to Digest and Digest Authentication was in force.

Through the use of AuthBasicUseDigestAlgorithm a site may switch from Digest to Basic Authentication without requiring s to be assigned new s.

The inverse process of switching from Basic to Digest Authentication without asg new s is generally not possible. Only if the Basic Authentication s have been stored in plain text or with a reversible encryption scheme will it be possible to recover them and generate a new data store following the Digest Authentication storage scheme.
Only providers which Digest Authentication will be able to authenticate s when AuthBasicUseDigestAlgorithm is set to MD5. Use of other providers will result in an error response and the client will be denied access.

Available Languages:  ko 

top

Comments 2p1l6j

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 by our s 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 Libera.chat, or sent to our mailing lists.