You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "dimas-b (via GitHub)" <gi...@apache.org> on 2024/12/17 04:23:57 UTC
[PR] Make JWT brokers injectable [polaris]
dimas-b opened a new pull request, #570:
URL: https://github.com/apache/polaris/pull/570
* Detach `TokenBrokerFactory` sub-classes from Jackson-based config parsing logic.
* Add a new unified `TokenBrokerConfig` under DW to hold JWT config data.
* Resolve JWT factories through HK2 named service lookup, using the type name from `TokenBrokerConfig`
* Add dedicated class `NoneTokenBrokerFactory` for the default do-nothing token broker implementation.
* Yaml config (`polaris-server.yml`) is not affected
<!--
Possible security vulnerabilities: STOP here and contact security@apache.org instead!
Please update the title of the PR with a meaningful message - do not leave it "empty" or "generated"
Please update this summary field:
The summary should cover these topics, if applicable:
* the motivation for the change
* a description of the status quo, for example the current behavior
* the desired behavior
* etc
PR checklist:
- Do a self-review of your code before opening a pull request
- Make sure that there's good test coverage for the changes included in this PR
- Run tests locally before pushing a PR (./gradlew check)
- Code should have comments where applicable. Particularly hard-to-understand
areas deserve good in-line documentation.
- Include changes and enhancements to the documentation (in site/content/in-dev/unreleased)
- For Work In Progress Pull Requests, please use the Draft PR feature.
Make sure to add the information BELOW this comment.
Everything in this comment will NOT be added to the PR description.
-->
--
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] Make JWT brokers injectable [polaris]
Posted by "collado-mike (via GitHub)" <gi...@apache.org>.
collado-mike commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1890910157
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTSymmetricKeyFactory.java:
##########
@@ -19,56 +19,58 @@
package org.apache.polaris.service.auth;
import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.function.Supplier;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
@Identifier("symmetric-key")
public class JWTSymmetricKeyFactory implements TokenBrokerFactory {
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
- private int maxTokenGenerationInSeconds = 3600;
- private String file;
- private String secret;
+
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+
+ @Inject
+ public JWTSymmetricKeyFactory(MetaStoreManagerFactory metaStoreManagerFactory, Config config) {
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
+ this.config = config;
+ }
@Override
public TokenBroker apply(RealmContext realmContext) {
- if (file == null && secret == null) {
+ String secret = config.secret();
Review Comment:
I'm for checking in the constructor, FWIW
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1892851411
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTSymmetricKeyFactory.java:
##########
@@ -19,56 +19,58 @@
package org.apache.polaris.service.auth;
import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.function.Supplier;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
@Identifier("symmetric-key")
public class JWTSymmetricKeyFactory implements TokenBrokerFactory {
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
- private int maxTokenGenerationInSeconds = 3600;
- private String file;
- private String secret;
+
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+
+ @Inject
+ public JWTSymmetricKeyFactory(MetaStoreManagerFactory metaStoreManagerFactory, Config config) {
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
+ this.config = config;
+ }
@Override
public TokenBroker apply(RealmContext realmContext) {
- if (file == null && secret == null) {
+ String secret = config.secret();
Review Comment:
refactored (and rebased)
--
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] Make JWT brokers injectable [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888032840
##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/config/TokenBrokerConfig.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.dropwizard.config;
+
+import jakarta.annotation.Nullable;
+import org.apache.polaris.service.auth.JWTRSAKeyPairFactory;
+import org.apache.polaris.service.auth.JWTSymmetricKeyFactory;
+
+public class TokenBrokerConfig
+ implements JWTSymmetricKeyFactory.Config, JWTRSAKeyPairFactory.Config {
+ private String type = "none";
+ private int maxTokenGenerationInSeconds = 3600;
+ private String file;
+ private String secret;
+
+ public String getType() {
Review Comment:
I suspect you need some `@JsonSetter` annotations here for Jackson? (#561)
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888805212
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTRSAKeyPairFactory.java:
##########
@@ -25,18 +25,24 @@
@Identifier("rsa-key-pair")
public class JWTRSAKeyPairFactory implements TokenBrokerFactory {
- private int maxTokenGenerationInSeconds = 3600;
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
- public void setMaxTokenGenerationInSeconds(int maxTokenGenerationInSeconds) {
- this.maxTokenGenerationInSeconds = maxTokenGenerationInSeconds;
+ @Inject
+ public JWTRSAKeyPairFactory(Config config, MetaStoreManagerFactory metaStoreManagerFactory) {
+ this.config = config;
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
}
@Override
public TokenBroker apply(RealmContext realmContext) {
return new JWTRSAKeyPair(
metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext),
- maxTokenGenerationInSeconds);
+ config.maxTokenGenerationInSeconds());
+ }
+
+ public interface Config {
Review Comment:
works for me
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888853626
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTSymmetricKeyFactory.java:
##########
@@ -19,56 +19,58 @@
package org.apache.polaris.service.auth;
import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.function.Supplier;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
@Identifier("symmetric-key")
public class JWTSymmetricKeyFactory implements TokenBrokerFactory {
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
- private int maxTokenGenerationInSeconds = 3600;
- private String file;
- private String secret;
+
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+
+ @Inject
+ public JWTSymmetricKeyFactory(MetaStoreManagerFactory metaStoreManagerFactory, Config config) {
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
+ this.config = config;
+ }
@Override
public TokenBroker apply(RealmContext realmContext) {
- if (file == null && secret == null) {
+ String secret = config.secret();
Review Comment:
True, but I did not want to alter behaviour is this PR. Let's me know and I will move the check.
--
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] Make JWT brokers injectable [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra merged PR #570:
URL: https://github.com/apache/polaris/pull/570
--
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] Make JWT brokers injectable [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888131631
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTSymmetricKeyFactory.java:
##########
@@ -19,56 +19,58 @@
package org.apache.polaris.service.auth;
import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.function.Supplier;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
@Identifier("symmetric-key")
public class JWTSymmetricKeyFactory implements TokenBrokerFactory {
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
- private int maxTokenGenerationInSeconds = 3600;
- private String file;
- private String secret;
+
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+
+ @Inject
+ public JWTSymmetricKeyFactory(MetaStoreManagerFactory metaStoreManagerFactory, Config config) {
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
+ this.config = config;
+ }
@Override
public TokenBroker apply(RealmContext realmContext) {
- if (file == null && secret == null) {
+ String secret = config.secret();
Review Comment:
I guess this check can be moved to the constructor.
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTRSAKeyPairFactory.java:
##########
@@ -25,18 +25,24 @@
@Identifier("rsa-key-pair")
public class JWTRSAKeyPairFactory implements TokenBrokerFactory {
- private int maxTokenGenerationInSeconds = 3600;
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
- public void setMaxTokenGenerationInSeconds(int maxTokenGenerationInSeconds) {
- this.maxTokenGenerationInSeconds = maxTokenGenerationInSeconds;
+ @Inject
+ public JWTRSAKeyPairFactory(Config config, MetaStoreManagerFactory metaStoreManagerFactory) {
+ this.config = config;
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
}
@Override
public TokenBroker apply(RealmContext realmContext) {
return new JWTRSAKeyPair(
metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext),
- maxTokenGenerationInSeconds);
+ config.maxTokenGenerationInSeconds());
+ }
+
+ public interface Config {
Review Comment:
Would it be better / simpler to have one config interface for all token broker factories?
##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/config/TokenBrokerConfig.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.dropwizard.config;
+
+import jakarta.annotation.Nullable;
+import org.apache.polaris.service.auth.JWTRSAKeyPairFactory;
+import org.apache.polaris.service.auth.JWTSymmetricKeyFactory;
+
+public class TokenBrokerConfig
+ implements JWTSymmetricKeyFactory.Config, JWTRSAKeyPairFactory.Config {
+ private String type = "none";
+ private int maxTokenGenerationInSeconds = 3600;
+ private String file;
+ private String secret;
+
+ public String getType() {
Review Comment:
Or a `@JsonCreator` constructor?
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888851577
##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/config/TokenBrokerConfig.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.dropwizard.config;
+
+import jakarta.annotation.Nullable;
+import org.apache.polaris.service.auth.JWTRSAKeyPairFactory;
+import org.apache.polaris.service.auth.JWTSymmetricKeyFactory;
+
+public class TokenBrokerConfig
+ implements JWTSymmetricKeyFactory.Config, JWTRSAKeyPairFactory.Config {
+ private String type = "none";
+ private int maxTokenGenerationInSeconds = 3600;
+ private String file;
+ private String secret;
+
+ public String getType() {
Review Comment:
"Need" in what sense? It works "as is" as the receiver of the DW YAML config data.
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1889317525
##########
dropwizard/service/src/main/java/org/apache/polaris/service/dropwizard/config/TokenBrokerConfig.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.dropwizard.config;
+
+import jakarta.annotation.Nullable;
+import org.apache.polaris.service.auth.JWTRSAKeyPairFactory;
+import org.apache.polaris.service.auth.JWTSymmetricKeyFactory;
+
+public class TokenBrokerConfig
+ implements JWTSymmetricKeyFactory.Config, JWTRSAKeyPairFactory.Config {
+ private String type = "none";
+ private int maxTokenGenerationInSeconds = 3600;
+ private String file;
+ private String secret;
+
+ public String getType() {
Review Comment:
Added `@JsonProperty` for clarity.
--
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] Make JWT brokers injectable [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888313986
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTRSAKeyPairFactory.java:
##########
@@ -25,18 +25,24 @@
@Identifier("rsa-key-pair")
public class JWTRSAKeyPairFactory implements TokenBrokerFactory {
- private int maxTokenGenerationInSeconds = 3600;
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
- public void setMaxTokenGenerationInSeconds(int maxTokenGenerationInSeconds) {
- this.maxTokenGenerationInSeconds = maxTokenGenerationInSeconds;
+ @Inject
+ public JWTRSAKeyPairFactory(Config config, MetaStoreManagerFactory metaStoreManagerFactory) {
+ this.config = config;
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
}
@Override
public TokenBroker apply(RealmContext realmContext) {
return new JWTRSAKeyPair(
metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext),
- maxTokenGenerationInSeconds);
+ config.maxTokenGenerationInSeconds());
+ }
+
+ public interface Config {
+ int maxTokenGenerationInSeconds();
Review Comment:
```suggestion
Duration maxTokenGeneration();
```
(but I don't know if DW has support for java time)
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1888804128
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTRSAKeyPairFactory.java:
##########
@@ -25,18 +25,24 @@
@Identifier("rsa-key-pair")
public class JWTRSAKeyPairFactory implements TokenBrokerFactory {
- private int maxTokenGenerationInSeconds = 3600;
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
- public void setMaxTokenGenerationInSeconds(int maxTokenGenerationInSeconds) {
- this.maxTokenGenerationInSeconds = maxTokenGenerationInSeconds;
+ @Inject
+ public JWTRSAKeyPairFactory(Config config, MetaStoreManagerFactory metaStoreManagerFactory) {
+ this.config = config;
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
}
@Override
public TokenBroker apply(RealmContext realmContext) {
return new JWTRSAKeyPair(
metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext),
- maxTokenGenerationInSeconds);
+ config.maxTokenGenerationInSeconds());
+ }
+
+ public interface Config {
+ int maxTokenGenerationInSeconds();
Review Comment:
I did not want to introduce functional changes in this PR. It's just a refactoring for injectability.
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1889316755
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTRSAKeyPairFactory.java:
##########
@@ -25,18 +25,24 @@
@Identifier("rsa-key-pair")
public class JWTRSAKeyPairFactory implements TokenBrokerFactory {
- private int maxTokenGenerationInSeconds = 3600;
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
- public void setMaxTokenGenerationInSeconds(int maxTokenGenerationInSeconds) {
- this.maxTokenGenerationInSeconds = maxTokenGenerationInSeconds;
+ @Inject
+ public JWTRSAKeyPairFactory(Config config, MetaStoreManagerFactory metaStoreManagerFactory) {
+ this.config = config;
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
}
@Override
public TokenBroker apply(RealmContext realmContext) {
return new JWTRSAKeyPair(
metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext),
- maxTokenGenerationInSeconds);
+ config.maxTokenGenerationInSeconds());
+ }
+
+ public interface Config {
Review Comment:
Updated to a unified config interface.
--
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] Make JWT brokers injectable [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #570:
URL: https://github.com/apache/polaris/pull/570#discussion_r1890997810
##########
service/common/src/main/java/org/apache/polaris/service/auth/JWTSymmetricKeyFactory.java:
##########
@@ -19,56 +19,58 @@
package org.apache.polaris.service.auth;
import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.function.Supplier;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
@Identifier("symmetric-key")
public class JWTSymmetricKeyFactory implements TokenBrokerFactory {
- @Inject private MetaStoreManagerFactory metaStoreManagerFactory;
- private int maxTokenGenerationInSeconds = 3600;
- private String file;
- private String secret;
+
+ private final MetaStoreManagerFactory metaStoreManagerFactory;
+ private final Config config;
+
+ @Inject
+ public JWTSymmetricKeyFactory(MetaStoreManagerFactory metaStoreManagerFactory, Config config) {
+ this.metaStoreManagerFactory = metaStoreManagerFactory;
+ this.config = config;
+ }
@Override
public TokenBroker apply(RealmContext realmContext) {
- if (file == null && secret == null) {
+ String secret = config.secret();
Review Comment:
ok, will update
--
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