public Task ValidateAsync(CustomAuthorizeRequestValidationContext context)
        {
            var redirectUri = new Uri(context.Result.ValidatedRequest.RedirectUri);

            if (!string.IsNullOrWhiteSpace(redirectUri.Query))
            {
                context.Result.ValidatedRequest.RedirectUri = redirectUri.AbsoluteUri;
            }
            return(Task.CompletedTask);
        }
        public async Task <AuthorizeRequestValidationResult> ValidateAsync(NameValueCollection parameters, ClaimsPrincipal subject = null)
        {
            _logger.LogDebug("Start authorize request protocol validation");

            var request = new ValidatedAuthorizeRequest
            {
                Options = _options,
                Subject = subject ?? Principal.Anonymous,
                Raw     = parameters ?? throw new ArgumentNullException(nameof(parameters))
            };

            // load client_id
            // client_id must always be present on the request
            var loadClientResult = await LoadClientAsync(request);

            if (loadClientResult.IsError)
            {
                return(loadClientResult);
            }

            // load request object
            var roLoadResult = await LoadRequestObjectAsync(request);

            if (roLoadResult.IsError)
            {
                return(roLoadResult);
            }

            // validate request object
            var roValidationResult = await ValidateRequestObjectAsync(request);

            if (roValidationResult.IsError)
            {
                return(roValidationResult);
            }

            // validate client_id and redirect_uri
            var clientResult = await ValidateClientAsync(request);

            if (clientResult.IsError)
            {
                return(clientResult);
            }

            // state, response_type, response_mode
            var mandatoryResult = ValidateCoreParameters(request);

            if (mandatoryResult.IsError)
            {
                return(mandatoryResult);
            }

            // scope, scope restrictions and plausability
            var scopeResult = await ValidateScopeAsync(request);

            if (scopeResult.IsError)
            {
                return(scopeResult);
            }

            // nonce, prompt, acr_values, login_hint etc.
            var optionalResult = await ValidateOptionalParametersAsync(request);

            if (optionalResult.IsError)
            {
                return(optionalResult);
            }

            // custom validator
            _logger.LogDebug("Calling into custom validator: {type}", _customValidator.GetType().FullName);
            var context = new CustomAuthorizeRequestValidationContext
            {
                Result = new AuthorizeRequestValidationResult(request)
            };
            await _customValidator.ValidateAsync(context);

            var customResult = context.Result;

            if (customResult.IsError)
            {
                LogError("Error in custom validation", customResult.Error, request);
                return(Invalid(request, customResult.Error, customResult.ErrorDescription));
            }

            _logger.LogTrace("Authorize request protocol validation successful");

            return(Valid(request));
        }
 /// <summary>
 /// Custom validation logic for the authorize request.
 /// </summary>
 /// <param name="context">The context.</param>
 public Task ValidateAsync(CustomAuthorizeRequestValidationContext context)
 {
     return(Task.FromResult(0));
 }
 /// <summary>
 /// Custom validation logic for the authorize request.
 /// </summary>
 /// <param name="context">The context.</param>
 public Task ValidateAsync(CustomAuthorizeRequestValidationContext context)
 {
     return(Task.CompletedTask);
 }