public async Task <ScopeSecretValidationResult> ValidateAsync(HttpContext context) { _logger.LogTrace("Start scope validation"); var fail = new ScopeSecretValidationResult { IsError = true }; var parsedSecret = await _parser.ParseAsync(context); if (parsedSecret == null) { await RaiseFailureEvent("unknown", "No scope id or secret found"); _logger.LogInformation("No scope secret found"); return(fail); } // load scope var scope = (await _scopes.FindScopesAsync(new[] { parsedSecret.Id })).FirstOrDefault(); if (scope == null) { await RaiseFailureEvent(parsedSecret.Id, "Unknown scope"); _logger.LogInformation("No scope with that name found. aborting"); return(fail); } var result = await _validator.ValidateAsync(parsedSecret, scope.ScopeSecrets); if (result.Success) { _logger.LogInformation("Scope validation success"); var success = new ScopeSecretValidationResult { IsError = false, Scope = scope }; await RaiseSuccessEvent(scope.Name); return(success); } await RaiseFailureEvent(scope.Name, "Invalid client secret"); _logger.LogInformation("Scope validation failed."); return(fail); }
public async Task<ScopeSecretValidationResult> ValidateAsync(HttpContext context) { _logger.LogVerbose("Start scope validation"); var fail = new ScopeSecretValidationResult { IsError = true }; var parsedSecret = await _parser.ParseAsync(context); if (parsedSecret == null) { await RaiseFailureEvent("unknown", "No scope id or secret found"); _logger.LogInformation("No scope secret found"); return fail; } // load scope var scope = (await _scopes.FindScopesAsync(new[] { parsedSecret.Id })).FirstOrDefault(); if (scope == null) { await RaiseFailureEvent(parsedSecret.Id, "Unknown scope"); _logger.LogInformation("No scope with that name found. aborting"); return fail; } var result = await _validator.ValidateAsync(parsedSecret, scope.ScopeSecrets); if (result.Success) { _logger.LogInformation("Scope validation success"); var success = new ScopeSecretValidationResult { IsError = false, Scope = scope }; await RaiseSuccessEvent(scope.Name); return success; } await RaiseFailureEvent(scope.Name, "Invalid client secret"); _logger.LogInformation("Scope validation failed."); return fail; }