Hi everyone,

Last week I chatted with a Polaris user (a bank in France) that has an
issue with IdP support.
His IdP (per policy) only issues opaque access tokens.

So, I would like to start a discussion about support opaque (non JWT)
access tokens when Polaris is configured with external authentication
(polaris.authentication.type=external).

Today, Polaris only works with IdP issuing JWT access tokens. Quarkus OIDC
already validates opaque tokens through the token introspection endpoint of
the identity provider (RFC 7662), but Polaris drops the resulting identity:
OidcIdentityPreparer only handles identities whose principal is a
JsonWebToken, so no PolarisCredential is created and the request is
rejected with 401. Note that our documentation suggests providing a
custom PrincipalMapper for opaque tokens, but that can't work, as no mapper
is invoked for these identities.

I opened a PR to address this: https://github.com/apache/polaris/pull/6026

The change is small and doesn't modify any public interface:
- OidcIdentityPreparer also prepares identities carrying a token
introspection response.
- The default principal mapper resolves the existing
polaris.oidc.principal-mapper.*-claim-path settings against the JWT claims,
or against the introspection response for opaque token (for instance
"username" or "sub"). The JWT takes precedence, so the behavior is not
changed for JWT tokens.
- Roles come from the introspection "scope" field and go through the
existing polaris.oid.principal-roles-mapper.* settings.

I would like your feedback on a couple of points:
1. Custom PrincipalMapper/PrincipalRolesMapper impl will now also be
invoked for opaque token identities, whose principal is not a JsonWebToken.
Before, such requests were rejected before reaching any mapper.
Implementations blindly casting the principal to JsonWebToken will have to
handle this case. I added an upgrade note in the CHANGELOG about that. Do
you see any concern with this?
2. With opaque tokens, every request triggers a call to the introspection
endpoint unless the Quarkus token cache is enabled
(quarkus.oidc.token-cache.max-size, disabled by default). I documented the
trade-off (load on the identity provider vs revoked tokens being accepted
until the cache entry expires) rather than changing the default. Does it
sound good to you?

Thoughts?

Thanks,

Regards
JB

Reply via email to