Example #1
0
        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;

                string redirectUri =
                    baseUri +
                    Options.CallbackPath;

                AuthenticationProperties properties = challenge.Properties;
                if (string.IsNullOrEmpty(properties.RedirectUri))
                {
                    properties.RedirectUri = currentUri;
                }

                string state = Options.StateDataFormat.Protect(properties);

                string authorizationEndpoint = Options.AuthorizationEndpoint +
                                               "?redirect_uri=" + Uri.EscapeDataString(redirectUri) +
                                               "&state=" + Uri.EscapeDataString(state);

                var redirectContext = new VanLangApplyRedirectContext(
                    Context, Options,
                    properties, authorizationEndpoint);
                //Options.Provider.ApplyRedirect(redirectContext);
                Context.Response.Redirect(authorizationEndpoint);
            }

            return(Task.FromResult <object>(null));
        }
Example #2
0
 /// <summary>
 /// Called when a Challenge causes a redirect to authorize endpoint in the VanLang middleware
 /// </summary>
 /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge </param>
 public virtual void ApplyRedirect(VanLangApplyRedirectContext context)
 {
     OnApplyRedirect(context);
 }