Class EntraIssuerValidator
java.lang.Object
com.irurueta.authserver.authorization.api.web.social.EntraIssuerValidator
- All Implemented Interfaces:
org.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>
public class EntraIssuerValidator
extends Object
implements org.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>
Validates the issuer of an ID token of Microsoft Entra ID in a multi-tenant application.
Such a token is issued by the tenant its user belongs to (https://login.microsoftonline.com/{tid}/v2.0)
while the discovery document of the common endpoint advertises a {tenantid} placeholder as the
issuer, so the framework's check against one fixed issuer would reject every token. This validator takes the tenant
from the token's own tid claim, requires the iss to be exactly that tenant's issuer, and, when a list
is given, requires the tenant to be one of the permitted ones. The signature has already been verified against
Entra's published keys by then, so the tid is the one Entra put in the token.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.springframework.security.oauth2.core.OAuth2TokenValidatorResultBuilds a failed result.org.springframework.security.oauth2.core.OAuth2TokenValidatorResultvalidate(org.springframework.security.oauth2.jwt.Jwt token) Validates the issuer of a token.
-
Field Details
-
TENANT_CLAIM
Claim that holds the id of the tenant the user belongs to.- See Also:
-
INVALID_TOKEN
Error code of a refused token.- See Also:
-
permittedTenants
Tenants accepted; empty accepts any tenant.
-
-
Constructor Details
-
EntraIssuerValidator
Creates the validator.- Parameters:
permittedTenants- ids of the tenants accepted, compared ignoring case; empty accepts any tenant.
-
-
Method Details
-
validate
public org.springframework.security.oauth2.core.OAuth2TokenValidatorResult validate(org.springframework.security.oauth2.jwt.Jwt token) Validates the issuer of a token.- Specified by:
validatein interfaceorg.springframework.security.oauth2.core.OAuth2TokenValidator<org.springframework.security.oauth2.jwt.Jwt>- Parameters:
token- the ID token, already decoded and signature-verified.- Returns:
- a success, or a failure when the token has no tenant, its issuer is not the issuer of its tenant, or its tenant is not permitted.
-
failure
private static org.springframework.security.oauth2.core.OAuth2TokenValidatorResult failure(String description) Builds a failed result.- Parameters:
description- the reason.- Returns:
- the result.
-