Ejemplo n.º 1
0
        public async Task ExtractRevocationRequest_UnexpectedMethodReturnsAnError(string method)
        {
            // Arrange
            await using var server = await CreateServerAsync(options => options.EnableDegradedMode());

            await using var client = await server.CreateClientAsync();

            // Act
            var response = await client.SendAsync(method, "/connect/revoke", new OpenIddictRequest());

            // Assert
            Assert.Equal(Errors.InvalidRequest, response.Error);
            Assert.Equal(SR.GetResourceString(SR.ID2084), response.ErrorDescription);
            Assert.Equal(SR.FormatID8000(SR.ID2084), response.ErrorUri);
        }
Ejemplo n.º 2
0
            /// <inheritdoc/>
            public ValueTask HandleAsync(ValidateUserinfoRequestContext context)
            {
                if (context is null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                if (string.IsNullOrEmpty(context.Request.AccessToken))
                {
                    context.Logger.LogInformation(SR.GetResourceString(SR.ID6131), Parameters.AccessToken);

                    context.Reject(
                        error: Errors.MissingToken,
                        description: SR.FormatID2029(Parameters.AccessToken),
                        uri: SR.FormatID8000(SR.ID2029));

                    return(default);
Ejemplo n.º 3
0
            /// <inheritdoc/>
            public ValueTask HandleAsync(ValidateRevocationRequestContext context)
            {
                if (context is null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                // Reject revocation requests missing the mandatory token parameter.
                if (string.IsNullOrEmpty(context.Request.Token))
                {
                    context.Logger.LogInformation(SR.GetResourceString(SR.ID6111), Parameters.Token);

                    context.Reject(
                        error: Errors.InvalidRequest,
                        description: SR.FormatID2029(Parameters.Token),
                        uri: SR.FormatID8000(SR.ID2029));

                    return(default);
            /// <inheritdoc/>
            public ValueTask HandleAsync(ProcessAuthenticationContext context)
            {
                if (context is null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                // Note: unlike the equivalent event in the server stack, authentication can be triggered for
                // arbitrary requests (typically, API endpoints that are not owned by the validation stack).
                // As such, the token is not directly resolved from the request, that may be null at this stage.
                // Instead, the token is expected to be populated by one or multiple handlers provided by the host.
                //
                // Note: this event can also be triggered by the validation service to validate an arbitrary token.

                if (string.IsNullOrEmpty(context.Token))
                {
                    context.Reject(
                        error: Errors.MissingToken,
                        description: SR.GetResourceString(SR.ID2000),
                        uri: SR.FormatID8000(SR.ID2000));

                    return(default);