04
Mai 2012
Marko

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

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.