public ActionResult ConfirmAuthorization(string session) { if (!session.HasValue()) { return(IrrecoverableError("Could Not Find Pending Authentication Request", "No session was provided.")); } var authRequestBytes = Current.GetFromCache <byte[]>(session); if (authRequestBytes == null) { return(IrrecoverableError("Could Not Find Pending Authentication Request", "We were unable to find the pending authentication request, and cannot resume login.")); } IAuthenticationRequest authRequest = null; authRequest = authRequest.DeSerialize(authRequestBytes); Current.LoggedInUser.GrantAuthorization(authRequest.Realm.Host); return (SafeRedirect( (Func <string, string, ActionResult>)(new OpenIdController()).ResumeAfterLogin, new { session } )); }
public ActionResult ResumeAfterLogin(string session, string noPrompt) { var authRequestBytes = Current.GetFromCache <byte[]>(session); if (authRequestBytes == null) { return(IrrecoverableError("Could Not Find Pending Authentication Request", "We were unable to find the pending authentication request, and cannot resume login.")); } IAuthenticationRequest authRequest = null; authRequest = authRequest.DeSerialize(authRequestBytes); Current.RemoveFromCache(session); // HACK: fix up bad local ids sent from a relying party var localId = authRequest.LocalIdentifier; if (localId != null && NobodyClaims(localId.ToString())) { Current.LogException(new Exception("Rewrote [" + localId.ToString() + "]")); authRequest.LocalIdentifier = Current.LoggedInUser.GetClaimedIdentifier(); } var sendAssertion = (authRequest.IsDirectedIdentity || this.UserControlsIdentifier(authRequest)); if (!sendAssertion) { return(IrrecoverableError( "Cannot Complete Login", "Detected an attempt to send an assertion when the identifier (" + authRequest.LocalIdentifier + ") is not owned by the logged in user." )); } if (!Current.LoggedInUser.HasGrantedAuthorization(authRequest.Realm.Host)) { session = CreationSession(authRequest); return (SafeRedirect( (Func <string, ActionResult>)(new AccountController()).PromptForAuthorization, new { session } )); } bool noPromptB = false; if (noPrompt.HasValue()) { bool.TryParse(noPrompt, out noPromptB); } return(SendAssertion(authRequest, noPrompt: noPromptB)); }
public ActionResult PromptForAuthorization(string session) { if (!session.HasValue()) { return(IrrecoverableError("Could Not Find Pending Authentication Request", "No session was provided.")); } var authRequestBytes = Current.GetFromCache <byte[]>(session); if (authRequestBytes == null) { return(IrrecoverableError("Could Not Find Pending Authentication Request", "We were unable to find the pending authentication request, and cannot resume login.")); } IAuthenticationRequest authRequest = null; authRequest = authRequest.DeSerialize(authRequestBytes); ViewData["session"] = session; return(View((object)authRequest.Realm.Host)); }