Exemple #1
0
        protected override async Task <bool> HandleUnauthorizedAsync(ChallengeContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var properties = new AuthenticationProperties(context.Properties);

            if (string.IsNullOrEmpty(properties.RedirectUri))
            {
                properties.RedirectUri = CurrentUri;
            }

            // OAuth2 10.12 CSRF
            GenerateCorrelationId(properties);

            var authorizationEndpoint = BuildChallengeUrl(properties, BuildRedirectUri(Options.CallbackPath));
            var redirectContext       = new OAuthRedirectToAuthorizationContext(
                Context, Options,
                properties, authorizationEndpoint);
            await Options.Events.RedirectToAuthorizationEndpoint(redirectContext);

            return(true);
        }
Exemple #2
0
 /// <summary>
 /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware.
 /// </summary>
 /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge.</param>
 public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context);
 internal static Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context)
 {
     context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom");
     return Task.FromResult(0);
 }
Exemple #4
0
 /// <summary>
 /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware.
 /// </summary>
 /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge.</param>
 public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context);