Skip to content

Instantly share code, notes, and snippets.

@xdumaine
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdumaine/8689945 to your computer and use it in GitHub Desktop.
Save xdumaine/8689945 to your computer and use it in GitHub Desktop.
private static OpenIdRelyingParty openId = new OpenIdRelyingParty();
[HttpPost]
public ActionResult OpenId(string identifier)
{
if (!Identifier.IsValid(identifier))
{
ModelState.AddModelError("loginIdentifier",
"The specified login identifier is invalid");
return RedirectToAction("Index");
}
//// use these to validate the connection to the OpenId provider
//var r = (HttpWebRequest)WebRequest.Create(identifier);
//var httpRes = (HttpWebResponse)r.GetResponse();
var openIdIdentifier = Identifier.Parse(identifier);
var request = openId.CreateRequest(openIdIdentifier);
// Require some additional data
var claimsRequest = new ClaimsRequest { Email = DemandLevel.Require };
request.Mode = AuthenticationRequestMode.Setup;
request.AddExtension(claimsRequest);
return request.RedirectingResponse.AsActionResult();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment