public async Task <IHttpActionResult> Get() { Logger.Info("Start identity token validation request"); if (!_options.Endpoints.EnableIdentityTokenValidationEndpoint) { var error = "Endpoint is disabled. Aborting"; Logger.Warn(error); RaiseFailureEvent(error); return(NotFound()); } var parameters = Request.RequestUri.ParseQueryString(); var token = parameters.Get("token"); if (token.IsMissing()) { var error = "token is missing."; Logger.Error(error); RaiseFailureEvent(error); return(BadRequest(_localizationService.GetMessage(MessageIds.MissingToken))); } var clientId = parameters.Get("client_id"); if (clientId.IsMissing()) { var error = "client_id is missing."; Logger.Error(error); RaiseFailureEvent(error); return(BadRequest(_localizationService.GetMessage(MessageIds.MissingClientId))); } var result = await _validator.ValidateIdentityTokenAsync(token, clientId); if (result.IsError) { Logger.Info("Returning error: " + result.Error); RaiseFailureEvent(result.Error); return(BadRequest(result.Error)); } var response = result.Claims.ToClaimsDictionary(); Logger.Info("End identity token validation request"); RaiseSuccessEvent(); return(Json(response)); }
public async Task <IHttpActionResult> Get() { Logger.Info("Start identity token validation request"); if (!_options.Endpoints.IdentityTokenValidationEndpoint.IsEnabled) { Logger.Warn("Endpoint is disabled. Aborting"); return(NotFound()); } var parameters = Request.RequestUri.ParseQueryString(); var token = parameters.Get("token"); if (token.IsMissing()) { Logger.Error("token is missing."); return(BadRequest(Messages.MissingToken)); } var clientId = parameters.Get("client_id"); if (clientId.IsMissing()) { Logger.Error("client_id is missing."); return(BadRequest(Messages.MissingClientId)); } var result = await _validator.ValidateIdentityTokenAsync(token, clientId); if (result.IsError) { Logger.Info("Returning error: " + result.Error); return(BadRequest(result.Error)); } var response = result.Claims.ToClaimsDictionary(); Logger.Debug(JsonConvert.SerializeObject(response, Formatting.Indented)); Logger.Info("Returning identity token claims"); return(Json(response)); }
internal async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters) { var token = parameters.Get("token"); if (token.IsMissing()) { var error = "token is missing."; Logger.Error(error); await RaiseFailureEventAsync(error); return(BadRequest(_localizationService.GetMessage(MessageIds.MissingToken))); } var clientId = parameters.Get("client_id"); if (clientId.IsMissing()) { var error = "client_id is missing."; Logger.Error(error); await RaiseFailureEventAsync(error); return(BadRequest(_localizationService.GetMessage(MessageIds.MissingClientId))); } var result = await _validator.ValidateIdentityTokenAsync(token, clientId); if (result.IsError) { Logger.Info("Returning error: " + result.Error); await RaiseFailureEventAsync(result.Error); return(BadRequest(result.Error)); } var response = result.Claims.ToClaimsDictionary(); Logger.Info("End identity token validation request"); await RaiseSuccessEventAsync(); return(Json(response)); }