/// <summary> /// Attempts to authenticate users by forwarding them to an external website, and upon succcess or failure, redirect users back to the specified url. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="returnUrl"> /// The return url after users have completed authenticating against external website. /// </param> /// <param name="state"> /// Additional state to pass on the callback url. /// </param> public virtual void RequestAuthentication(HttpContextBase context, Uri returnUrl, StateDictionary state) { Requires.NotNull(context, "context"); Requires.NotNull(returnUrl, "returnUrl"); Requires.NotNull(state, "state"); Uri redirectUri = this.GetServiceLoginUrl(returnUrl); redirectUri = redirectUri.AttachQueryStringParameter("state", state.ToEncodedString()); context.Response.Redirect(redirectUri.AbsoluteUri, endResponse: true); }
public virtual void RequestAuthentication(HttpContextBase context, Uri returnUrl, StateDictionary state) { Requires.NotNull(returnUrl, "returnUrl"); Requires.NotNull(state, "state"); returnUrl = returnUrl.AttachQueryStringParameter("state", state.ToEncodedString()); var realm = new Realm(returnUrl.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)); IAuthenticationRequest request = RelyingParty.CreateRequest(this.providerIdentifier, realm, returnUrl); // give subclasses a chance to modify request message, e.g. add extension attributes, etc. this.OnBeforeSendingAuthenticationRequest(request); request.RedirectToProvider(); }
/// <summary> /// Attempts to authenticate users by forwarding them to an external website, and upon succcess or failure, redirect users back to the specified url. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="returnUrl"> /// The return url after users have completed authenticating against external website. /// </param> /// <param name="state"> /// Additional state to pass on the callback url. /// </param> public virtual void RequestAuthentication(HttpContextBase context, Uri returnUrl, StateDictionary state) { Requires.NotNull(returnUrl, "returnUrl"); Requires.NotNull(context, "context"); Requires.NotNull(state, "state"); Uri callback = returnUrl.StripQueryArgumentsWithPrefix("oauth_"); callback = callback.AttachQueryStringParameter("state", state.ToEncodedString()); this.WebWorker.RequestAuthentication(callback); }