Mai 2012

Secure a single controller with .htpasswd in cakephp

Sometimes you just want to secure several controllers, maybe temporary maybe for any other reason.
If you just have a basic cake application without any user management, .htaccess will help you.
1. oepn the app/.htaccess file of your Project.
2. Insert at bottom.

#specify witch controler needs a password auth
SetEnvIf Request_URI "^/app/webroot/controllerA" passreq
SetEnvIf Request_URI "^/app/webroot/controllerB" passreq
AuthType Basic
AuthName "Please Log in"
AuthUserFile /path-to-your/.htpasswd
AuthGroupFile /
Require valid-user
Order allow,deny
Allow from all
#Deny all calls where env=passreq, as you specified at top
Deny from env=passreq
Satisfy any

thats it.

Ein Kommentar zu "Secure a single controller with .htpasswd in cakephp"

Kommentar verfassen