1
votes

I want to use password protection for a zend-framework project using .htpasswd. I am able to enable htpasswd in public/index.php i.e project entirely but what i want to achieve is enable password protection for a particular controller/action only.

Say, I have a controller by name UserController and action editUserAction. And another controller by name PublicController with action listUserAction. What I want to achieve is enable password protection for usercontroller/edit-user action. i.e. whenever a user tries to access url : http://myhost/myproject/user/edit-user User should be prompted for username and password but the rest of the urls should be accessible.

Is this possible ??? Is this possible using .htpasswd and .htaccess in zend projects ???

1

1 Answers

0
votes

Check out basic HTTP Authentication with PHP: http://php.net/manual/en/features.http-auth.php

You don't actually need to use a .htaccess file but can build the password prompt right into your controllers.