- Overview
- Installation & Uninstallation
- Local and remote management using IIS 7
- Context and processing order
- Apache compatibility
- Modules
- core functions
- mod_antibot
- mod_asis
- mod_auth_basic
- mod_auth_digest
- mod_authn_anon
- mod_authn_dbd
- mod_authn_default
- mod_authn_file
- mod_authz_default
- mod_authz_groupfile
- mod_authz_host
- mod_authz_user
- mod_cache
- mod_dbd
- mod_deflate
- mod_developer
- mod_dir
- mod_disk_cache
- mod_env
- mod_evasive
- mod_expires
- mod_filter
- mod_gzip
- mod_headers
- mod_hotlink
- mod_linkfreeze
- mod_log_config
- mod_logio
- mod_mem_cache
- mod_mime
- mod_proxy
- mod_replace
- mod_rewrite
- mod_seo
- mod_setenvif
- mod_so
- mod_speling
- mod_usertrack
- mod_xsendfile
- Articles
- Release history
- Troubleshooting
- License agreement
mod_authn_dbd
Overview
mod_authn_dbd module provides user authentication by searching users in SQL tables.
This module relies on mod_dbd to specify the backend database driver and connection parameters, and manage the database connections. The functionality is similar to this of mod_authn_file , the only difference is the storage for passwords - for mod_authn_file it's plain text file and for mod_authn_dbd it's SQL table.
To apply this module to
mod_auth_basic
or
mod_auth_digest
, it should be defined in
AuthBasicProvider
or
AuthDigestProvider
respectively with
dbd
value.
Quick start
Sample mod_authn_dbd configuration in .htaccess
# mod_dbd configuration
DBDriver mssql
DBDParams "Data Source=db_server;Initial Catalog=users_db;Persist Security Info=True;User ID=sa;Password=your_password"
# mod_auth_basic configuration
AuthType Basic
AuthName "My Server"
AuthBasicProvider dbd
Require valid-user
# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery "SELECT password FROM users_table WHERE user = @USERNAME"
Related articles and topics
- HTTP Authentication and Authorization
- Enabling site authentication not using Windows users
- mod_dbd: Saying technically
- How to connect mod_dbd with various databases
- Introduction to database functionality of Helicon Ape
- mod_auth_basic
- mod_auth_digest
- mod_authn_file
- mod_authn_dbd
Enviroment variables
Name | Context | Description |
---|---|---|
enable_plaintext_passwords | S V D .h | Enables plain text passwords in password file; by default it is disabled |
Directives
Name | Context | Description |
---|---|---|
AuthDBDUserPWQuery | S V D .h | Contains SQL query to look up the password for the user |
AuthDBDUserRealmQuery | S V D .h | Contains SQL query to look up the password hash for the user and realm |
AuthDBDUserPWQuery
AuthDBDUserPWQuery
directive contains the SQL query that
will be used to search password for the specified user. The user's ID will be
passed as a single string parameter when the SQL query is executed. It may be
referenced within the query statement using a
@USERNAME
format specifier.
The first column value of the first row returned by the query is a string containing the encrypted password. Subsequent rows will be ignored. If no rows are returned, the user will not be authenticated through mod_authn_dbd.
Syntax
AuthDBDUserPWQuery query
Example
AuthDBDUserPWQuery "SELECT password FROM users_table WHERE user = @USERNAME"
Note! This directive is used for Basic authentication .
To generate passwords for Basic authentication, open Helicon Ape Manager,
create new file (
File -> New
) and go to
Options -> Insert user
password...
In the opened dialog select
Basic
authentication type,
desired encryption type, username and password. The password to be inserted
into the passwords SQL table is the part of the
Result
after the
semicolon.
user1:$apr1$INLVN...$vGlaWUKqx3A8vsO4qgtVC.
Note! If you don't need the password to be encrypted, you may write it as is into the proper SQL table column.
AuthDBDUserRealmQuery
AuthDBDUserRealmQuery
directive contains the SQL query that
will be used to search password for the specified user and realm. The user's ID
and the realm (in such order) will be passed as a string parameters when the
SQL query is executed. They may be referenced within the query statement using
@USERNAME
and
@REALM
format specifiers.
The first column value of the first row returned by the query is a string containing the encrypted password. Subsequent rows will be ignored. If no rows are returned, the user will not be authenticated through mod_authn_dbd.
Syntax
AuthDBDUserRealmQuery query
Example
AuthDBDUserRealmQuery "SELECT password FROM users_table WHERE user = @USERNAME AND realm = @REALM"
Note!
No single quotes around
@REALM
and
@USERNAME
values should be put.
Note! This directive is used for Digest authentication .
To generate passwords for Digest authentication open Helicon Ape Manager,
create new file (
File -> New
) and go to
Options -> Insert user
password...
In the opened dialog select
Digest
authentication type,
desired encryption type, username, password and realm. The password to be
inserted into the passwords SQL table is the part of the
Result
after
the second semicolon.
user2:realm2:c9e7e0ea0dfb6f2bd070e76e75e5dfa9