You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "snazy (via GitHub)" <gi...@apache.org> on 2025/05/23 11:22:24 UTC

[PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

snazy opened a new pull request, #1661:
URL: https://github.com/apache/polaris/pull/1661

   Polaris allows using RSA key-paris for the JWT token broker. The recommended way is to [generate the RSA key pair](https://github.com/apache/polaris/blob/d8b862b13914d526ee147dc0e359bfc9c1e319ad/site/content/in-dev/unreleased/configuring-polaris-for-production.md?plain=1#L61-L66) and configure the location of the key files.
   
   However, if only `polaris.authentication.token-broker.type=rsa-key-pair` but not the `public/private-key-pair` options are configured, Polaris generates those and stores them in `/tmp` using random file names (using `Files.createTempFile()`) - this happens for each (matching) realm. Each Polaris startup generates new key-pairs for each of those realms. It's practically not possible to associate the files to a realm. There is already a [production readiness check](https://github.com/apache/polaris/blob/d8b862b13914d526ee147dc0e359bfc9c1e319ad/quarkus/service/src/main/java/org/apache/polaris/service/quarkus/config/ProductionReadinessChecks.java#L118-L166) to warn users about this behavior.
   
   Due to the issue that the files cannot be associated, those seem to be somewhat useless and bring no advantage over keeping these "ephemeral RSA key pairs" on heap. This PR changes the code to not write the key-pair to the file system and keeps these "ephemeral key pairs" on heap. Since the same code path is used for key-paris _provided_ by the user (via the `public/private-key-pair` config options), that code path now only reads those files once and not every time the private/public key is needed.
   


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on PR #1661:
URL: https://github.com/apache/polaris/pull/1661#issuecomment-2904328769

   > It just occurred to me: it would be good to update `site/content/in-dev/unreleased/configuration.md` since the defaults for `polaris.authentication.token-broker.rsa-key-pair.public-key-file` and `polaris.authentication.token-broker.rsa-key-pair.private-key-file` have changed (there are no defaults anymore).
   
   Good catch! updated that file


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #1661:
URL: https://github.com/apache/polaris/pull/1661#discussion_r2105774991


##########
service/common/src/main/java/org/apache/polaris/service/auth/LocalRSAKeyProvider.java:
##########
@@ -48,12 +76,7 @@ public LocalRSAKeyProvider(Path publicKeyFileLocation, Path privateKeyFileLocati
    */
   @Override
   public PublicKey getPublicKey() {
-    try {
-      return PemUtils.readPublicKeyFromFile(publicKeyFileLocation, "RSA");
-    } catch (IOException e) {
-      LOGGER.error("Unable to read public key from file {}", publicKeyFileLocation, e);
-      throw new RuntimeException("Unable to read public key from file " + publicKeyFileLocation, e);
-    }
+    return publicKey;

Review Comment:
   Implementing the ability to rotate keys consistently across multiple Polaris instances is a bigger effort, and should be backed by a secrets manager.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy merged PR #1661:
URL: https://github.com/apache/polaris/pull/1661


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1661:
URL: https://github.com/apache/polaris/pull/1661#discussion_r2105063289


##########
service/common/src/main/java/org/apache/polaris/service/auth/LocalRSAKeyProvider.java:
##########
@@ -48,12 +76,7 @@ public LocalRSAKeyProvider(Path publicKeyFileLocation, Path privateKeyFileLocati
    */
   @Override
   public PublicKey getPublicKey() {
-    try {
-      return PemUtils.readPublicKeyFromFile(publicKeyFileLocation, "RSA");
-    } catch (IOException e) {
-      LOGGER.error("Unable to read public key from file {}", publicKeyFileLocation, e);
-      throw new RuntimeException("Unable to read public key from file " + publicKeyFileLocation, e);
-    }
+    return publicKey;

Review Comment:
   This change will require server restarts for key rotation. I'm not sure if on-the-fly key rotation was envisioned as a supported use case before, but it might be worth flagging this behaviour change for visibility.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1661:
URL: https://github.com/apache/polaris/pull/1661#discussion_r2107583360


##########
service/common/src/main/java/org/apache/polaris/service/auth/LocalRSAKeyProvider.java:
##########
@@ -48,12 +76,7 @@ public LocalRSAKeyProvider(Path publicKeyFileLocation, Path privateKeyFileLocati
    */
   @Override
   public PublicKey getPublicKey() {
-    try {
-      return PemUtils.readPublicKeyFromFile(publicKeyFileLocation, "RSA");
-    } catch (IOException e) {
-      LOGGER.error("Unable to read public key from file {}", publicKeyFileLocation, e);
-      throw new RuntimeException("Unable to read public key from file " + publicKeyFileLocation, e);
-    }
+    return publicKey;

Review Comment:
   I'm not saying the old code was perfect, but I sense that it might have had a purpose :thinking: 
   
   @collado-mike WDYT?



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1661:
URL: https://github.com/apache/polaris/pull/1661#discussion_r2107584472


##########
service/common/src/main/java/org/apache/polaris/service/auth/LocalRSAKeyProvider.java:
##########
@@ -48,12 +76,7 @@ public LocalRSAKeyProvider(Path publicKeyFileLocation, Path privateKeyFileLocati
    */
   @Override
   public PublicKey getPublicKey() {
-    try {
-      return PemUtils.readPublicKeyFromFile(publicKeyFileLocation, "RSA");
-    } catch (IOException e) {
-      LOGGER.error("Unable to read public key from file {}", publicKeyFileLocation, e);
-      throw new RuntimeException("Unable to read public key from file " + publicKeyFileLocation, e);
-    }
+    return publicKey;

Review Comment:
   To be clear: I personally support merging this PR.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #1661:
URL: https://github.com/apache/polaris/pull/1661#discussion_r2105772973


##########
service/common/src/main/java/org/apache/polaris/service/auth/LocalRSAKeyProvider.java:
##########
@@ -48,12 +76,7 @@ public LocalRSAKeyProvider(Path publicKeyFileLocation, Path privateKeyFileLocati
    */
   @Override
   public PublicKey getPublicKey() {
-    try {
-      return PemUtils.readPublicKeyFromFile(publicKeyFileLocation, "RSA");
-    } catch (IOException e) {
-      LOGGER.error("Unable to read public key from file {}", publicKeyFileLocation, e);
-      throw new RuntimeException("Unable to read public key from file " + publicKeyFileLocation, e);
-    }
+    return publicKey;

Review Comment:
   You'd have to keep the previous (public) key around and referenced by their id, as the [auth0 RSAKeyProvider interface](https://javadoc.io/doc/com.auth0/java-jwt/3.2.0/com/auth0/jwt/interfaces/RSAKeyProvider.html) defines, which [Polaris' KeyProvider](https://github.com/apache/polaris/blob/1631da00b5f1116f779a044b00bbff8132cb4f49/service/common/src/main/java/org/apache/polaris/service/auth/KeyProvider.java) does not. If you change the keys in a running Polaris system, all current tokens become immediately invalid.
   



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Keep generated RSA-key-pair for JWT token broker on heap [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on PR #1661:
URL: https://github.com/apache/polaris/pull/1661#issuecomment-2904227583

   It just occurred to me: it would be good to update `site/content/in-dev/unreleased/configuration.md` since the defaults for `polaris.authentication.token-broker.rsa-key-pair.public-key-file` and `polaris.authentication.token-broker.rsa-key-pair.private-key-file` have changed (there are no defaults anymore).


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org