public async Task <Client> GetFromClientIdAsync(String clientId) { Client client = await _inner.GetFromClientIdAsync(clientId); if (client != null) { _logger.LogTrace("Validate client : {validator}", _validatorType); ConfigurationValidationContext <Client> context = new ConfigurationValidationContext <Client>(client); await _validator.ValidateAsync(context); if (context.IsValid) { _logger.LogDebug("Client configuration validation for {clientId} succeeded", client.ClientId); return(client); } else { _logger.LogError("Invalid client configuration for {clientId}: {error}", client.ClientId, context.ErrorMessage); //await _events.RaiseAsync(new InvalidConfigurationEvent<Client>(client, context.ErrorMessage)); return(null); } } return(null); }
protected virtual Task ValidateRoleAsync(ConfigurationValidationContext <Policy> context) { if (context.Item.Roles.Count == 0) { context.SetError($"At least on Role is required, but no role is configured."); return(Task.CompletedTask); } return(Task.CompletedTask); }
protected virtual Task ValidateCycliqueRoleAsync(ConfigurationValidationContext <Policy> context) { foreach (Role role in context.Item.Roles) { if (!CheckCircularReference(role)) { context.SetError($"Circular reference detected. Please avoid circular references."); return(Task.CompletedTask); } } return(Task.CompletedTask); }
public async Task ValidateAsync(ConfigurationValidationContext <Policy> context) { //await ValidateRoleAsync(context); //if (!context.IsValid) { return; } await ValidateCycliqueRoleAsync(context); if (!context.IsValid) { return; } }
public async Task ValidateAsync(ConfigurationValidationContext <Client> context) { //TODO(demarco): Need to reactivate this !!! await ValidatePolicyAsync(context); if (!context.IsValid) { return; } //await ValidateScopeAsync(context); //if (!context.IsValid) { return; } //await ValidateSecretsAsync(context); //if (!context.IsValid) { return; } }
protected virtual Task ValidatePolicyAsync(ConfigurationValidationContext <Client> context) { if (context.Item.Policy == null) { context.SetError($"Policy is required, but no policy is configured."); return(Task.CompletedTask); } ConfigurationValidationContext <Policy> policyContext = new ConfigurationValidationContext <Policy>(context.Item.Policy); _policyConfigurationValidator.ValidateAsync(policyContext); if (!policyContext.IsValid) { context.SetError(policyContext.ErrorMessage); } return(Task.CompletedTask); }