Enable htpasswd in zend-framework project for a particular action/url or a controller

烂漫一生 提交于 2019-12-14 02:36:54

问题


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:


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.



来源:https://stackoverflow.com/questions/8600925/enable-htpasswd-in-zend-framework-project-for-a-particular-action-url-or-a-contr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!