<IfDefine HAVE_AUTH_PGSQL> <IfModule !mod_auth_pgsql.c> LoadModule auth_pgsql_module extramodules/mod_auth_pgsql.so </IfModule> </IfDefine> <IfModule mod_auth_pgsql.c> # # mod_auth_pgsql can be used to limit access to documents by checking # data in a PostgresQL database. # # This will enable user-based PostgreSQL authentication of everything # within /var/www. You'll need to do the following as the postgres user # beforehand: # # CREATE DATABASE auth; # \c auth # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(32) NOT NULL, # PRIMARY KEY (user_name) # ); # CREATE USER apache; # GRANT SELECT ON users TO apache; # # INSERT INTO users VALUES # ('testuser', '179ad45c6ce2cb97cf1029e212046e81'); # # 179ad45c6ce2cb97cf1029e212046e81 is the MD5 hash of 'testpass' # you can create such hashes using "echo -n 'PaSsWoRd' | md5sum" # #<Directory /var/www> # AuthName "PostgreSQL authenticated zone" # AuthType Basic # # Auth_PG_database auth # Auth_PG_pwd_table users # Auth_PG_uid_field user_name # Auth_PG_pwd_field user_passwd # Auth_PG_hash_type MD5 # # require valid-user #</Directory> # This will enable group-based PostgreSQL authentication of everything # within /var/www. You'll need to do the following as the postgres user # beforehand: # # CREATE DATABASE auth; # \c auth # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(32) NOT NULL, # user_group CHAR(20) NOT NULL, # PRIMARY KEY (user_name) # ); # CREATE USER apache; # GRANT SELECT ON users TO apache; # # INSERT INTO users VALUES # ('testuser', '179ad45c6ce2cb97cf1029e212046e81', 'user'); # INSERT INTO users VALUES # ('testadmin', '179ad45c6ce2cb97cf1029e212046e81', 'admin'); # #<Directory /var/www> # AuthName "PostgreSQL group authenticated zone" # AuthType Basic # # Auth_PG_database auth # Auth_PG_pwd_table users # Auth_PG_uid_field user_name # Auth_PG_pwd_field user_passwd # Auth_PG_grp_table users # Auth_PG_gid_field user_group # Auth_PG_hash_type MD5 # # require group admin #</Directory> # Like the above this enables group-based PostgreSQL authentication of # everything within /var/www, but this configuration allows users to # belong to more than one group. You'll need to do the following as # the postgres user beforehand: # # CREATE DATABASE auth; # \c auth # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(32) NOT NULL, # PRIMARY KEY (user_name) # ); # CREATE TABLE groups ( # user_name CHAR(30) NOT NULL, # user_group CHAR(20) NOT NULL, # PRIMARY KEY (user_name, user_group) # ); # CREATE USER apache; # GRANT SELECT ON users TO apache; # GRANT SELECT ON groups TO apache; # # INSERT INTO users VALUES # ('testuser', '179ad45c6ce2cb97cf1029e212046e81'); # INSERT INTO groups VALUES ('testuser', 'user'); # INSERT INTO users VALUES # ('testadmin', '179ad45c6ce2cb97cf1029e212046e81'); # INSERT INTO groups VALUES ('testadmin', 'admin'); # INSERT INTO groups VALUES ('testadmin', 'user'); # #<Directory /var/www> # AuthName "PostgreSQL group authenticated zone" # AuthType Basic # # Auth_PG_database auth # Auth_PG_pwd_table users # Auth_PG_uid_field user_name # Auth_PG_pwd_field user_passwd # Auth_PG_grp_table groups # Auth_PG_gid_field user_group # Auth_PG_hash_type MD5 # # require group user #</Directory> </IfModule>