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 baseUri = Request.Scheme + Uri.SchemeDelimiter + Request.Host + Request.PathBase; string currentUri = baseUri + Request.Path + Request.QueryString; AuthenticationProperties properties = challenge.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = currentUri; } string authorizationEndpoint = AuthorizeEndpoint + Options.AppId; string state = Options.StateDataFormat.Protect(properties); var cookieOptions = new CookieOptions { HttpOnly = true, Secure = Request.IsSecure }; string stateCookieKey = Constants.StatePrefix + Options.AuthenticationType; Response.Cookies.Append(stateCookieKey, state, cookieOptions); var redirectContext = new YotiApplyRedirectContext( 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 Yoti middleware /// </summary> /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge </param> public virtual void ApplyRedirect(YotiApplyRedirectContext context) { OnApplyRedirect(context); }