Skip to content

SAML Resource Resolver

Duende.IdentityServer.Saml.Services.ISamlResourceResolver

Section titled “Duende.IdentityServer.Saml.Services.ISamlResourceResolver”

Resolves the claim types that a SAML service provider (SP) is allowed to receive, based on its AllowedScopes and RequestedClaimTypes configuration. AllowedScopes must contain only identity resource names — API resource scopes are not supported for SAML service providers.

public interface ISamlResourceResolver
{
Task<SamlResourceResolutionResult> ResolveRequestedClaimTypesAsync(
SamlServiceProvider sp,
CancellationToken ct);
}
MethodDescription
ResolveRequestedClaimTypesAsyncResolves the claim types for the given service provider. sp is the service provider to resolve claim types for and ct is the cancellation token. Returns a result indicating success with the resolved claim types, or failure with an error reason.

The result of resolving claim types for a SAML service provider.

MemberDescription
SucceededGets whether the resolution succeeded.
ClaimTypesGets the resolved claim types. Only populated when Succeeded is true.
ErrorGets the error description. Only populated when Succeeded is false.
ValidatedResourcesGets the validated resources. Only populated when Succeeded is true.
Success(IReadOnlyList<string> claimTypes, ResourceValidationResult validatedResources)Creates a successful result.
Failure(string error)Creates a failed result.

The default implementation, DefaultSamlResourceResolver, is the default implementation of ISamlResourceResolver that resolves claim types from the SP’s AllowedScopes via the resource store. AllowedScopes must contain only enabled identity resources. It fails when:

  • AllowedScopes is empty,
  • a scope isn’t an enabled identity resource, or
  • RequestedClaimTypes contains a claim type that isn’t in the resolved identity resources.

On failure, IdentityServer logs the details and returns the generic error Service provider configuration error.

On success, the claim set is RequestedClaimTypes if it isn’t empty, otherwise all UserClaims of the resolved resources.

builder.Services.AddScoped<ISamlResourceResolver, CustomResourceResolver>();