I am trying to allow users to sign in to the ASP.NET MVC web site with their Google, Facebook, and Windows Live accounts. I am currently using the Azure App Fabric ACS, which made it almost too easy. The catch is I need the e-mail address. Google and Facebook provide the e-mail as a claim, but Windows Live doesn't. From the LiveConnect site it seems like this is easily possible using the wl.basic (to get the user's name) and wl.emails (to get the user's email address) scopes, but I haven't been able to influence the ACS in order to obtain this information. I also tried implementing the OAuth2 web server flow to get it from my site after the user has signed in. I was able to get the information I needed, but I became stuck in an infinite loop of signing on because the FedAuth cookies were removed when I redirected to https://oauth.live.com/authorize to start the flow. Has anybody been able to get this to work (on the server side)? Should I just scrap the ACS altogether and provide a custom page with uses the custom code from each provider to enable sign in?
I retrofitted a previous demo (blog engine ala smarx) with the code so that I wouldn't have to expose anything proprietary. In my web.config FedUtil has inserted the following:
<httpModules>
<add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
I removed the deny all users
But I have a particular action method (post of a new blog) that forces users to be authorized
[Authorize]
public ActionResult New()
{
var principal = Thread.CurrentPrincipal as IClaimsPrincipal;
if (principal == null)
return new HttpStatusCodeResult(403);
// if this is a Windows Live User we have more work to do
string redirectUrl = CheckForWindowsLiveUser(principal);
if (redirectUrl != null)
{
return Redirect(redirectUrl);
}
Inside the New request the first time the cookies (FedAuth and FedAuth1) have been filled in. After the redirect comes back they are gone. I haven't done anything to the session provider (maybe I should).