public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            if (!_options.Endpoints.TokenEndpoint.IsEnabled)
            {
                Logger.Warn("Endpoint is disabled. Aborting");
                return(NotFound());
            }

            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }
예제 #2
0
        /// <summary>
        /// Processes the token request
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Token response</returns>
        public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            var appidvalidation = await _comoRequestValidator.Validate(parameters, client);

            if (appidvalidation.IsError)
            {
                return(this.TokenErrorResponse(appidvalidation.Error));
            }
            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }
        public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(new RevocationErrorResult(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(new RevocationErrorResult(result.Error));
            }

            // revoke tokens
            if (result.TokenTypeHint == Constants.TokenTypeHints.AccessToken)
            {
                await RevokeAccessTokenAsync(result.Token, client);
            }
            else if (result.TokenTypeHint == Constants.TokenTypeHints.RefreshToken)
            {
                await RevokeRefreshTokenAsync(result.Token, client);
            }
            else
            {
                var found = await RevokeAccessTokenAsync(result.Token, client);

                if (!found)
                {
                    await RevokeRefreshTokenAsync(result.Token, client);
                }
            }

            return(Ok());
        }