启用htpasswd的在Zend中,框架项目的特定操作/ URL或控制器 [英] Enable htpasswd in zend-framework project for a particular action/url or a controller

查看:128
本文介绍了启用htpasswd的在Zend中,框架项目的特定操作/ URL或控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用密码保护使用htpasswd的一个Zend-框架项目。我能够让htpasswd的公共/ index.php文件,即项目完全,但我想要实现的是能为特定的控制器/唯一操作密码保护。

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.

我说,我有一个控制器的名字UserController中和行动editUserAction。而另一控制器通过名字PublicController用行动listUserAction。我想实现的是启用UserController中/编辑用户操作密码保护。即当用户试图访问网址:的http://为m​​yhost / MyProject的/用户/编辑用户用户会被提示输入用户名和密码,但URL的其余部分应是可访问的。

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.

这是可能的???这是使用htpasswd的和.htaccess中的Zend项目???

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

推荐答案

查看基本的HTTP验证用PHP:的 http://php.net/manual/en/features.http-auth.php

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

您实际上并不需要使用.htaccess文件,但可以建立密码提示到您的权利控制器。

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

这篇关于启用htpasswd的在Zend中,框架项目的特定操作/ URL或控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆