2

为移动用户构建一个新的移动网络平台,以在他们的手机上购买和下载内容。过去,我们使用了完全定制的登录机制,但我正在研究为下一版本的平台使用自定义成员资格提供程序。

问题是,我们有一些稍微奇怪的“登录”机制要求,所以我不能 100% 确定 MembershipProvider 是最合适的。

只是通过“是的,会员提供者很合适”或“不,你在一个圆孔里敲一个方形钉子”来寻找一些关于以下要求的一般反馈

要求

  1. 用户可能需要使用“手机号码”(用户名)和“Pin”(密码)登录 这非常适合,因为他们已经注册并通过短信确认,并且满足ValidateUser(string username, string password)方法实现

  2. 用户可能只需要使用“手机号码”登录。在这种情况下,我们不会费心在我们这边进行身份验证。它减少了用户的步骤数量,并且在我们尝试向他们收费时由特定的操作员完成验证。(运营商可以验证输入的手机号码,当它到达运营商支付网站时与手机匹配)......所以即使用户有密码,我们也需要以某种方式欺骗会员提供商,让他们进来使用空白密码。

  3. 用户根本不需要登录。在这种情况下,我们可以将用户透明地退回到一个特殊的网络运营商网页,当他们透明地退回给我们时,我们将在 Headers 中获取手机号码。在这种情况下,我们需要以编程方式从标题中获取该数字,在后面的代码中代表他们执行登录(同样没有任何 pin/密码),用户将神奇地自动登录。

要求 2 和 3 有点奇怪。我们基本上有 3 种不同的登录机制,一个会员提供者需要满足这些机制。

  • 用户输入的手机和用户输入的密码
  • 用户仅输入手机(我想后面的代码可以满足密码要求)
  • 完全透明的登录(完成整个登录过程的代码)

Anyone got any comments/feed back on the above or have any advice on any bizarre membership provider implementation you've done in the past.

4

1 回答 1

1

I think it could work. We do #3 on one of our sites. Here is a chunk of code that we use to take care of it. To use this, create a login page (transparentlogin.aspx or something similar), make sure that the web.config file allows anonymous access to this page, and put code like this in the page_load function for the transparentlogin.aspx page:

const string specialpassword = "ThisIsOurSpecialPasswordForBehindTheScenesLogin";

if (MobileNumberFoundInHeader())
{
  string username = GetMobileNumberFromHeaders();
  // Authenticate the user behind the scenes
  System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);
  System.Web.Security.FormsAuthentication.Authenticate(username, specialpassword);
}
else
{
  throw new Exception ("Mobile Number Missing");
}

Then, in the ValidateUser function in the MembershipProvider, make sure you do a check like this:

public override bool ValidateUser(string username, string password)
{
 const string specialpassword = "ThisIsOurSpecialPasswordForBehindTheScenesLogin";

 bool ValidationSuccess = false;

 // If the password being passed in is the right secret key (same  
 // for all users), then we will say that the password matches the
 // username, thus allowing the user to login 
 if (password == specialpassword)
 {
   ValidationSuccess = true;
 }

 if (DoStandardUsernamePasswordVerification() == true)
 {
   ValidationSuccess = true;
 }

 return ValidationSuccess;
}

As for requirement #2, I'm a little confused. What exactly is an operator? I thought we were dealing with a mobile phone using a web browser to browse to a website. Where does the operator fit into that? If the solution I propose above doesn't help, please post a response with more details about the Operator.

Tim

于 2009-07-06T19:40:03.290 回答