--- mod_auth_pgsql.html.orig Fri Jan 11 16:58:18 2002 +++ mod_auth_pgsql.html Thu May 2 18:49:20 2002 @@ -23,14 +23,16 @@ -
	One database, and one (or two) tables.  One table holds the username and the encryped (or plain) password.
  The other table holds the username and the names of the group to which the user belongs.
It is possible to have username, groupname and password in the same table.
- + One database, and one function with parameters (name, name, name, text, inet, text) +for context, group, login name, password, remoute IP address, URI. +Function must return some value (for example oid) as a link to credentials for this connect. +This value inserts into environment variable CREDENTIALS. -
	Every authentication access is logged in the same database of the authentication table, but in different table.
User name and date of the request are logged.
As option, it can log password, ip address, request line.
+ Every authentication access can be logged by authentificate SQL function.


@@ -61,48 +63,16 @@
  • Auth_PG_user
  • -
  • Auth_PG_pwd +
  • Auth_PG_pwd
  • -
  • Auth_PG_pwd_table -
  • -
  • Auth_PG_grp_table -
  • -
  • Auth_PG_uid_field +
  • Auth_PG_function
  • -
  • Auth_PG_pwd_field +
  • Auth_PG_context
  • -
  • Auth_PG_gid_field +
  • Auth_PG_finish
  • -
  • Auth_PG_nopasswd -
  • Auth_PG_authoritative
  • -
  • Auth_PG_lowercase_uid -
  • -
  • Auth_PG_uppercase_uid
  • -
  • Auth_PG_pwd_ignore_case
    -
  • -
  • Auth_PG_encrypted -
  • -
  • Auth_PG_hash_type
    -
  • -
  • Auth_PG_pwd_whereclause -
  • -
  • Auth_PG_grp_whereclause
  • -
  • Auth_PG_cache_passwords
    -
  • -
  • Auth_PG_log_table -
  • -
  • Auth_PG_log_uname_field -
  • -
  • Auth_PG_log_date_field -
  • -
  • Auth_PG_log_uri_field -
  • -
  • Auth_PG_log_addrs_field -
  • -
  • Auth_PG_log_pwd_field -
  • @@ -172,62 +142,33 @@


    -

    Auth_PG_pwd_table

    - Syntax: Auth_PG_pwd_table relation name
    +

    Auth_PG_function

    + Syntax: Auth_PG_function function name
    Context: directory, .htaccess
    Override: AuthConfig
    Status: Extension -

    Gives the name of the relation which contains the username and password - information.
    - See Auth_PG_encrypted, by default the password - is encrypted.
    +

    Gives the name of the function which calculate credentials and returns +NULL if access forbidden. This function can log accesses if need.

    -

    Auth_PG_grp_table

    - Syntax: Auth_PG_grp_table relation name
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    Gives the name of the relation which contains the username and group information. - This can be the same table specified with Auth_PG_pwd_table. - This directive is only necessary if you want to authenticate -by user groups. A user within multiple groups has therefore multiple - entries.

    - -

    Auth_PG_uid_field

    - Syntax: Auth_PG_uid_field attribute name
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    Specifies the attribute name of the field containing the user name in the -Auth_PG_pwd_table relation.

    - -

    Auth_PG_pwd_field

    - Syntax: Auth_PG_pwd_field attribute name
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    Specifies the attribute name of the field containing the encrypted (see - Auth_PG_encrypted) password in the Auth_PGpwd_table relation. -

    - -

    Auth_PG_gid_field

    - Syntax: Auth_PG_gid_field attribute name
    +

    Auth_PG_context

    + Syntax: Auth_PG_context context name
    Context: directory, .htaccess
    Override: AuthConfig
    Status: Extension -

    Specifies the attribute name of the field containing the group name in - the Auth_PG_grp_table relation. This directive is only necessary - if you want to authenticate by user groups.

    +

    Gives the name of the context. For service of independent +user groups, where login names in different groups can be +equal without real user equality. +

    -

    Auth_PG_nopasswd

    - Syntax: Auth_PG_nopasswd on or off
    +

    Auth_PG_finish

    + Syntax: Auth_PG_finish uri
    Context: directory, .htaccess
    Override: AuthConfig
    Status: Extension -

    This option is off by default. Turning it on will cause a user to be validated - when their password field is empty. The password entered will - be ignored. Exercise caution when turning this on.

    +

    If configured, do not drop connection until configured URI. +Usualy URI of footer triggers drop of connect to PostgreSQL. +

    Auth_PG_authoritative

    Syntax: Auth_PG_authoritative on or off
    @@ -243,210 +184,31 @@ and authenticate the user. Exercise caution when turning this option off. It can be a security risk. Can be used to use two authentication schemes for the same dir.

    - -

    Auth_PG_lowercase_uid

    - Syntax: Auth_PG_lowercase_uid on or off
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    This option is off by default. Controls whether this module converts user - UIDs to lowercase before looking them up. When turned on this does not affect - the case of the original user ID should this module decline to authenticate - and a lower level is called.

    - -

    Auth_PG_uppercase_uid

    - Syntax: Auth_PG_uppercase_uid on or off
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    This option is off by default. Controls whether this module converts user - UIDs to uppercase before looking them up. When turned on this does not affect - the case of the original user ID should this module decline to authenticate - and a lower level is called.

    -

    Auth_PG_pwd_ignore_case

    -Syntax: Auth_PG_pwd_ignore_case on or off
    -Context: directory, .htaccess
    -Override: AuthConfig
    -Status: Extension -

    This option is off by default. Controls whether this module ignore the -upper/lowercase of password from user, when looking up clear text password -from db. 

    - -

    Auth_PG_encrypted

    - Syntax: Auth_PG_encrypted on or off
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    Defaults to on. Controls weather this module expects passwords in the database -to be encrypted or not. When turned off, you can use unencrypted passwords -in your database. Exercise caution when deciding to turn this off!

    - -


    -

    - -

    Auth_PG_hash_type

    - Syntax: Auth_PG_hash_type CRYPT or MD5
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    Set the encryption type for the password stored in the database.
    - Defaults to CRYPT. 

    - -


    -

    - -

    Auth_PG_pwd_whereclause

    - Syntax: Auth_PG_pwd_whereclause SQL fragment
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    This option allows you to exercise greater control over the SQL code used - to retrieve the user name and password from the database. -You can use this to search for the username using more attributes -in the table than the pwd_field.

    - -

    The basic SQL statement used to retrieve a user's password for checking - looks like this:

    - - - -

    The pwd_whereclause will be added to the end of this statement and must - fit logically. The where clause must be double quoted, - with initial space .

    - -

    Example:

    - -
          Auth_PG_pwd_whereclause " and access_level > 100 "
    - -

     

    - -

    Auth_PG_grp_whereclause

    - Syntax: Auth_PG_grp_whereclause SQL fragment
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension -

    This option allows you to exercise greater control over the SQL code used - to retrieve the group name and corresponding user from the -database. You can use this to search for the group name using -more attributes in the table than the gid_field.

    - -

    The basic SQL statement used to retrieve a group name and user name for - checking looks like this:

    - - - The gid_whereclause will be added to the end - of this statement and must fit logically. The where clause - must be double quoted.
    -
    -
    -
    -

    Auth_PG_cache_passwords

    - Syntax: Auth_PG_cache_passwords on | off
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Enable password caching, default is off.
    - The cache table is local to the directory, will be cleaned when full, - default size is 50.
    -
    - -

    Auth_PG_log_table

    - Syntax: Auth_PG_log_table table name
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the table where logging information will -go, the user need write access to this table.
    - Required for logging.
    -
    - -

    Auth_PG_log_uname_field

    - Syntax: Auth_PG_log_uname_field fieldname
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the fieldname where the username will be -saved.
    - Required for logging.
    -
    - -

    Auth_PG_log_date_field

    - Syntax: Auth_PG_log_date_field fieldname
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the fieldname where the date will be saved.
    - Required for logging.
    -
    - -

    Auth_PG_log_uri_field

    - Syntax: Auth_PG_uri_field fieldname
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the fieldname where the request string will - be saved.
    - Optional for logging.
    - -

    Auth_PG_log_addrs_field

    - Syntax: Auth_PG_addrs_field  fieldname
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the fieldname where the IP address will be - saved.
    - Optional for logging.
    - -

    Auth_PG_log_pwd_field

    - Syntax: Auth_PG_pwd_field  fieldname
    - Context: directory, .htaccess
    - Override: AuthConfig
    - Status: Extension
    -
    - Specifies the fileld name where the password used to - authenticate will be saved.
    - Note: the password will be saved in clear text
    - Optional for logging.
    -
    -

    Example

    Here is an example .htaccess file you might use to enable PostgreSQL authentication: -

    PostgreSQL trusted user:

    AuthName "My PostgreSQL Authenticator"
    AuthType basic

    Auth_PG_host localhost
    Auth_PG_port 5432
    Auth_PG_user postgres
    Auth_PG_database www
    Auth_PG_pwd_table valid_users
    Auth_PG_uid_field user
    Auth_PG_pwd_field password

    <LIMIT GET POST>
    require valid-user
    </LIMIT>

    PostgreSQL trusted user, select only users with access_level > 100:

    AuthName "My PostgreSQL Authenticator"
    AuthType basic

    Auth_PG_host localhost
    Auth_PG_port 5432
    Auth_PG_user postgres
    Auth_PG_database www
    Auth_PG_pwd_table valid_users
    Auth_PG_uid_field user
    Auth_PG_pwd_field password
    Auth_PG_pwd_whereclause " and access_level > 100 "

    <LIMIT GET POST>
    require valid-user
    </LIMIT>

    PostgreSQL user with password authentication, with logging:

    AuthName "My PostgreSQL Authenticator"
    AuthType basic

    Auth_PG_host someserver.somenet
    Auth_PG_port 5432
    Auth_PG_user postgres
    Auth_PG_pwd xxxxxxx
    Auth_PG_database www
    Auth_PG_pwd_table valid_users
    Auth_PG_uid_field user
    Auth_PG_pwd_field password
    Auth_PG_log_table access_log
    Auth_PG_log_uname_field login
    Auth_PG_log_date_field date
    Auth_PG_log_uri_field request
    Auth_PG_log_addrs_field ip_address


    <LIMIT GET POST>
    require valid-user
    </LIMIT>





    - -

    Technical Notes

    +
    +PostgreSQL trusted user:
    +
    +	AuthName "My PostgreSQL Authenticator"
    +	AuthType basic
    +
    +	Auth_PG_host localhost
    +	Auth_PG_port 5432
    +	Auth_PG_user postgres
    +	Auth_PG_database www
    +	Auth_PG_function valid_users
    +	Auth_PG_context staff
    +
    +	<LIMIT GET POST>
    +		require valid-user
    +	</LIMIT>
    +
    +
    - -
    -
    -
    -
    -

    Download