简体   繁体   English

Symfony2和安全模块:如何验证URL中传递的用户名和密码

[英]Symfony2 & security module: how can i authenticate passing username and password in the URL

I have a configured Symfony2 security module, this is, it can authenticate users from a form that submits to the path specified in "check_path" option located in security.xml 我有一个配置好的Symfony2安全模块,它可以从提交到位于security.xml中“ check_path”选项中指定的路径的表单中对用户进行身份验证。

I know is not best practice but id like to authenticate with an alternate url that has the following anatomy: .../alternatelogin/username/password 我知道这不是最佳做法,但id希望使用具有以下结构的备用URL进行身份验证:... / alternatelogin /用户名/密码

Inside the alternatelogin controller id like Symfony to make the same check and redirection that would do in the normal submit-login-form authentication method. 在类似于Symfony的alternatelogin控制器id内,进行与普通的commit-login-form身份验证方法相同的检查和重定向。

My first idea was to make the controller communicate with the "dummy" controller specified in security.xml (the one in the "check_path" option), but using forward or redirectToRoute wont make the trick. 我的第一个想法是使控制器与security.xml中指定的“虚拟”控制器(“ check_path”选项中的控制器)通信,但是使用forward或redirectToRoute不会成功。

Is there a working way to do this? 有没有可行的方法来做到这一点?

You will have to do your own username and password check in the database, but once you've done that, the following link solves the rest for you: 您将必须在数据库中进行自己的用户名和密码检查,但是一旦完成,下面的链接将为您解决其余问题:

https://hasin.me/2013/10/27/how-to-login-a-user-programatically-in-symfony2/ https://hasin.me/2013/10/27/how-to-login-a-user-programatically-in-symfony2/

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

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