adutra commented on code in PR #2389:
URL: https://github.com/apache/polaris/pull/2389#discussion_r2285400260
##########
runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java:
##########
@@ -157,16 +143,18 @@ public TokenResponse generateFromClientSecrets(
if (principal.isEmpty()) {
return new
TokenResponse(OAuthTokenErrorResponse.Error.unauthorized_client);
}
- String tokenString = generateTokenString(clientId, scope,
principal.get().getId());
+ String tokenString =
+ generateTokenString(principal.get().getName(),
principal.get().getId(), clientId, scope);
return new TokenResponse(
tokenString, TokenType.ACCESS_TOKEN.getValue(),
maxTokenGenerationInSeconds);
}
- private String generateTokenString(String clientId, String scope, Long
principalId) {
+ private String generateTokenString(
+ String principalName, long principalId, String clientId, String scope) {
Instant now = Instant.now();
return JWT.create()
.withIssuer(ISSUER_KEY)
- .withSubject(String.valueOf(principalId))
+ .withSubject(principalName)
Review Comment:
> we don't use principalId for lookups from metastore from sub and always
use the prinicipal id from the claim ?
Correct.
> how do we plan to leverage principalName from the subject here ?
The `DefaultAuthenticator` only does lookups by name if the principal id is
not available. This won't happen with polaris internal tokens, of course. But
other `Authenticator` implementations could require the principal name to be
available. It's imho bad that the principal name is never surfaced in internal
polaris tokens.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]