Provides notification used for determining the OAuth flow type based on the request.
Inheritance: Microsoft.AspNetCore.Authentication.BaseControlContext
        public override async Task <bool> HandleRequestAsync()
        {
            var matchRequestContext = new OAuthMatchContext(Context, Options);

            if (Options.AuthorizeEndpointPath.HasValue && Options.AuthorizeEndpointPath == Request.Path)
            {
                matchRequestContext.MatchesAuthorizeEndpoint();
            }
            else if (Options.TokenEndpointPath.HasValue && Options.TokenEndpointPath == Request.Path)
            {
                matchRequestContext.MatchesTokenEndpoint();
            }

            await Options.Provider.MatchEndpoint(matchRequestContext);

            if (matchRequestContext.HandledResponse)
            {
                return(true);
            }

            if (matchRequestContext.Skipped)
            {
                return(false);
            }

            if (matchRequestContext.IsAuthorizeEndpoint || matchRequestContext.IsTokenEndpoint)
            {
                if (!Options.AllowInsecureHttp && !Context.Request.IsHttps)
                {
                    Logger.LogWarning("Authorization server ignoring http request because AllowInsecureHttp is false.");

                    return(false);
                }

                if (matchRequestContext.IsAuthorizeEndpoint)
                {
                    return(await InvokeAuthorizeEndpointAsync());
                }

                if (matchRequestContext.IsTokenEndpoint)
                {
                    await InvokeTokenEndpointAsync();

                    return(true);
                }
            }

            return(false);
        }
 /// <summary>
 /// Called to determine if an incoming request is treated as an Authorize or Token
 /// endpoint. If Options.AuthorizeEndpointPath or Options.TokenEndpointPath
 /// are assigned values, then handling this event is optional and context.IsAuthorizeEndpoint and context.IsTokenEndpoint
 /// will already be true if the request path matches.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>Task to enable asynchronous execution</returns>
 public virtual Task MatchEndpoint(OAuthMatchContext context)
 {
     return OnMatchEndpoint.Invoke(context);
 }
Exemple #3
0
 /// <summary>
 /// Called to determine if an incoming request is treated as an Authorize or Token
 /// endpoint. If Options.AuthorizeEndpointPath or Options.TokenEndpointPath
 /// are assigned values, then handling this event is optional and context.IsAuthorizeEndpoint and context.IsTokenEndpoint
 /// will already be true if the request path matches.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>Task to enable asynchronous execution</returns>
 public virtual Task MatchEndpoint(OAuthMatchContext context)
 {
     return(OnMatchEndpoint.Invoke(context));
 }