protected override Task ApplyResponseChallengeAsync() { if (Response.StatusCode != 401) { return(Task.FromResult <object>(null)); } AuthenticationResponseChallenge challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode); if (challenge != null) { string requestPrefix = Request.Scheme + Uri.SchemeDelimiter + Request.Host; AuthenticationProperties properties = challenge.Properties; if (String.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = requestPrefix + Request.PathBase + Request.Path + Request.QueryString; } // OAuth2 10.12 CSRF GenerateCorrelationId(properties); string returnTo = BuildReturnTo(Options.StateDataFormat.Protect(properties)); string authorizationEndpoint = Options.CasServerUrlBase + "/login" + "?service=" + Uri.EscapeDataString(returnTo); if (properties.Dictionary.ContainsKey("renew") && properties.Dictionary["renew"] == "true") { authorizationEndpoint += "&renew=true"; } var redirectContext = new CasApplyRedirectContext( Context, Options, properties, authorizationEndpoint); Options.Provider.ApplyRedirect(redirectContext); } return(Task.FromResult <object>(null)); }
/// <summary> /// Called when a Challenge causes a redirect to authorize endpoint in the Google OAuth 2.0 middleware /// </summary> /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge </param> public virtual void ApplyRedirect(CasApplyRedirectContext context) { OnApplyRedirect(context); }