DuendeSoftware / Support

Support for Duende Software products
20 stars 0 forks source link

Successful validation for non existing ResourceIndicators #1305

Open Mendroch opened 3 weeks ago

Mendroch commented 3 weeks ago

Which version of Duende IdentityServer are you using?

v7

Which version of .NET are you using?

.NET 8

Describe the bug

We are seeking to enable successful validation for ResourceIndicators that are syntactically valid, but do not exist. Unfortunately, the current documentation does not provide a solution for this particular scenario.

As a workaround, we have implemented an overridden method that clears the ResourceIndicators list. However, we are interested in exploring if there is a more efficient or recommended solution to address this issue.

Additionally, we would appreciate guidance on how to successfully validate ResourceIndicators that do not conform to the expected syntax.

public class CustomResourceValidator : DefaultResourceValidator
{
    public MediusResourceValidator(IResourceStore store, IScopeParser scopeParser, ILogger<DefaultResourceValidator> logger)
        : base(store, scopeParser, logger)
    {}

    public override async Task<ResourceValidationResult> ValidateRequestedResourcesAsync(ResourceValidationRequest request)
    {
        var newRequest = new ResourceValidationRequest
        {
            Client = request.Client,
            Scopes = request.Scopes,
            ResourceIndicators = []
        };
        return await base.ValidateRequestedResourcesAsync(newRequest);
    }
}

----------

identityServerBuilder.Services
    .AddTransient<IResourceValidator, CustomResourceValidator>();

To Reproduce

- Expected behavior

Successful validation for scenarios described in guidance.

Log output/exception with stacktrace

-

Additional context

-