Exclude specific cakephp controller from http basic auth

烂漫一生 提交于 2019-12-05 17:31:43
Stephan Richter

Finally figured it out when I stumbelled upon this answer ( https://stackoverflow.com/a/14010456/1285585 ) to a related question.

Here is my solution:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/webroot
  <Directory /var/www>
    Options FollowSymLinks
    AllowOverride All
 </Directory>

 <Location "/">
    # Default to Basic Auth protection for any stie
    AuthType Basic
    AuthName "Keawe Development"
    AuthUserFile /host/.htpasswd
    Require valid-user

    # If the request goes to a rest page: bypass basic auth
    SetEnvIf Request_URI ^/rest/ noauth=1
    Allow from env=REDIRECT_noauth
    Allow from env=noauth

    Order Deny,Allow
    Satisfy any
    Deny from all
  </Location>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!