如何手动"登录&QUOT用户;使用WebSecurity + SimpleMembership? [英] How do I manually "log a user in" using WebSecurity + SimpleMembership?
问题描述
我想使用WebSecurity + SimpleMembership,但实现通过自定义/替代身份验证方法的能力(可选)登录用户。
I'd like to use WebSecurity+SimpleMembership, but implement the ability to (optionally) login users via a custom/alternative authentication method.
WebSecurity.Login只有一个方法签名,既要有一个用户名和密码。我想跳过密码检查,例如:
WebSecurity.Login only has one method signature, which requires both a username and a password. I'd like to skip the password check, e.g.:
if (MyCustomAuthenticationMethod.Authenticate(username, customData)) {
WebSecurity.Login(username); // Login without password check, method doesn't exist though
}
我想定制的auth-方法是可能给OAuthWebSecurity存在,但我不知道如何去实现我自己的。
I assume custom-auth-methods are possible given OAuthWebSecurity exists, but I'm not sure how to go about implementing my own.
推荐答案
好了,你可以简单地回去认证的根源,直接调用
Well, you could simply go back to root of authentication and call directly
FormsAuthentication.SetAuthCookie
这将创建的cookie和验证您的用户。
见<一href=\"http://stackoverflow.com/questions/1871010/asp-net-memebership-authorization-without-password\">Asp.net Memebership没有授权密码
This will create cookie and authenticate your user. See Asp.net Memebership Authorization without password
这篇关于如何手动&QUOT;登录&QUOT用户;使用WebSecurity + SimpleMembership?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!