вторник, 22 апреля 2014 г.

Apache: способы аутентификации

В web-сервере Apache присутствует множество модулей для настройки аутентификации.
Приведу некоторые примеры: 



AD аутентификация.

 <Location /storage> 
  AuthName "Please input your domain username and password" 
  AuthType SSPI 
  SSPIAuth On 
  SSPIAuthoritative off
  SSPIOfferBasic Off             # let non-IE clients authenticate (also probably fix Vista problems) 
  SSPIBasicPreferred Off      # basic authentication should have higher priority 
  SSPIUsernameCase lower 
  SSPIPerRequestAuth On    # Available only starting with 1.0.4 version of mod_auth_sspi. Probably helps with IE problems with POST if On (but it will generate 401 requests in error.log for each page request) 
  SSPIOfferSSPI On 
  Options FollowSymLinks
  SSPIPackage NTLM 
  Require valid-user 
</Location>

Для ограничения доступа, создаем файл со списком разрешенных пользователей.
В директории /storage/ создаем файл .htaccess:
Require user my_domain\user1 my_domain\user2

Аутентификацияс помощью mySQL.

LoadModule mysql_auth_module modules/mod_auth_mysql.so
<Directory "c:/Apache22/htdocs/protected">
  AuthName "MySQL Testing"
  AuthType Basic
  AuthMySQLEnable On
  AuthMySQLKeepAlive On
  AuthMySQLHost localhost
  AuthMySQLUser user
  AuthMySQLPassword password
  AuthMySQLDB test
  AuthMySQLUserTable user_info
  AuthMySQLPwEncryption vbulletin
  AuthMySQLSaltField user_salt
  require valid-user
</Directory> 

ldap аутентификация.

<Location /ldap>
  AuthType Basic
  AuthName "Subversion repository: Documents Project"
  AuthBasicProvider ldap
  AuthzLDAPAuthoritative on
  AuthLDAPURL "ldap://ldap_server.ru:58089/ou=People,dc=css,dc=my_dc,dc=com?cssDisplayNameDefault"
  AuthLDAPBindDN "cn=911,ou=People,dc=css,dc=my_dc,dc=com"
  AuthLDAPBindPassword my_password
  require valid-user
</Location>

Аутентификацияс помощью файла паролей / file based

<Location /secret/>
  Dav on
  Order allow,deny
  Allow from all
  AuthType Basic
  AuthName "My HTTPS"
  AuthUserFile "C:\Apache\conf\auth"
  Require user admin user1
  Options Indexes FollowSymLinks
</Location>
содержимое файла auth:
     admin:admin_md5_pass
     user1:user1_md5_pass

создается с помощью команды:
C:\Apache\bin>htpasswd.exe -n -b admin admin
admin:$apr1$cVus6mdp$AX1d4lBvrvibDKquxx.PW/

Описание ключей:
    -n  Don't update file; display results on stdout.
    -b  Use the password from the command line rather than prompting for it.

Аутентификация с помощью клиентских сертификатов.

Рассмотрена в отдельной статье Яндекс.Метрика

Комментариев нет:

Отправить комментарий

Популярные сообщения