如何手动"登录&QUOT用户;使用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和验证您的用户。
见Asp.net Memebership没有授权密码

This will create cookie and authenticate your user. See Asp.net Memebership Authorization without password