简体   繁体   English

无需htpasswd即可保护Apigility管理员UI的密码

[英]Password protecting Apigility admin UI without htpasswd

I was being searching to password protect apiglity admin ui without using htpasswd, but i did not got any information about. 我正在搜索不使用htpasswd的密码保护api admin ui,但是我没有任何有关的信息。 Can anybody help me out with this? 有人可以帮我吗?

Thanks in advance 提前致谢

You don't need password protection for ApiGility UI. 您不需要ApiGility UI的密码保护。 Access should only be allowed in the Dev environment. 仅应在开发环境中允许访问。

php public/index.php development enable <- to enable the UI
php public/index.php development disable <- to disable the UI

If you consist of having password protection for it. 如果您要为其提供密码保护。 Then you can add an event to the Application Module.php that check if the identified user is allowed to access that resource. 然后,您可以将一个事件添加到Application Module.php中,以检查是否允许所标识的用户访问该资源。

Edit - If you do want to protect something by password 编辑-如果您确实想通过密码保护某些内容

The following code should be placed in the Module.php file. 以下代码应放在Module.php文件中。 (In many cases under the Application module). (在许多情况下,在“应用程序”模块下)。

It call the event manager and attach action to the Dispatch event. 它调用事件管理器并将动作附加到Dispatch事件。 Every time the application reach the dispatch phase it will fire this event. 每当应用程序到达调度阶段,它将触发此事件。

The action is passed as a call back so you can attach function, classes ans etc. In this example I passed a new class that have access to the MvcEvent ($e). 该操作作为回调传递,因此您可以附加函数,类ans等。在此示例中,我传递了一个可以访问MvcEvent($ e)的新类。

For example, that class can check if a user is logged in. If it is not then redirect him to /login. 例如,该类可以检查用户是否已登录。如果未登录,则将其重定向到/ login。

public function onBootstrap(MvcEvent $e)
{
    $eventManager = $e->getApplication()->getEventManager();
    $eventManager->attach(MvcEvent::EVENT_DISPATCH, array(new UserAccessChecker($e), 'getResponse'));
}

For the purpose of auth You should further investigate ACL & RABC 为了进行身份验证,您应进一步调查ACLRABC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM