Enable htpasswd in zend-framework project for a pa

2019-07-24 00:08发布

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条回答
做自己的国王
2楼-- · 2019-07-24 00:41

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.

查看更多
登录 后发表回答