|
32 | 32 | import java.util.Date;
|
33 | 33 | import java.util.List;
|
34 | 34 | import java.util.Map;
|
35 |
| -import java.util.Objects; |
36 | 35 | import java.util.Optional;
|
37 | 36 | import java.util.function.Supplier;
|
38 | 37 | import org.apache.commons.lang3.StringUtils;
|
|
41 | 40 | import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
|
42 | 41 | import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
|
43 | 42 | import org.apache.polaris.service.auth.Authenticator;
|
44 |
| -import org.apache.polaris.service.auth.DecodedToken; |
45 |
| -import org.apache.polaris.service.auth.TokenBroker; |
46 | 43 | import org.apache.polaris.service.auth.TokenBrokerFactory;
|
47 |
| -import org.apache.polaris.service.auth.TokenResponse; |
| 44 | +import org.apache.polaris.service.auth.TokenBrokerFactoryConfig; |
48 | 45 | import org.apache.polaris.service.catalog.api.IcebergRestOAuth2ApiService;
|
49 | 46 | import org.apache.polaris.service.catalog.io.FileIOFactory;
|
50 | 47 | import org.apache.polaris.service.config.DefaultConfigurationStore;
|
|
54 | 51 | import org.apache.polaris.service.ratelimiter.RateLimiter;
|
55 | 52 | import org.apache.polaris.service.ratelimiter.TokenBucketFactory;
|
56 | 53 | import org.apache.polaris.service.storage.PolarisStorageIntegrationProviderImpl;
|
57 |
| -import org.apache.polaris.service.types.TokenType; |
58 | 54 | import org.glassfish.hk2.api.Factory;
|
59 | 55 | import org.glassfish.hk2.api.ServiceLocator;
|
60 | 56 | import org.glassfish.hk2.api.TypeLiteral;
|
@@ -92,7 +88,7 @@ public class PolarisApplicationConfig extends Configuration {
|
92 | 88 | private FileIOFactory fileIOFactory;
|
93 | 89 | private RateLimiter rateLimiter;
|
94 | 90 | private TokenBucketFactory tokenBucketFactory;
|
95 |
| - private TokenBrokerFactory tokenBrokerFactory; |
| 91 | + private TokenBrokerConfig tokenBroker = new TokenBrokerConfig(); |
96 | 92 |
|
97 | 93 | private AccessToken gcpAccessToken;
|
98 | 94 |
|
@@ -131,7 +127,13 @@ protected void configure() {
|
131 | 127 | bindFactory(SupplierFactory.create(serviceLocator, config::getPolarisAuthenticator))
|
132 | 128 | .to(Authenticator.class)
|
133 | 129 | .ranked(OVERRIDE_BINDING_RANK);
|
134 |
| - bindFactory(SupplierFactory.create(serviceLocator, config::getTokenBrokerFactory)) |
| 130 | + bindFactory(SupplierFactory.create(serviceLocator, () -> tokenBroker)) |
| 131 | + .to(TokenBrokerFactoryConfig.class); |
| 132 | + bindFactory( |
| 133 | + SupplierFactory.create( |
| 134 | + serviceLocator, |
| 135 | + () -> |
| 136 | + serviceLocator.getService(TokenBrokerFactory.class, tokenBroker.getType()))) |
135 | 137 | .to(TokenBrokerFactory.class)
|
136 | 138 | .ranked(OVERRIDE_BINDING_RANK);
|
137 | 139 | bindFactory(SupplierFactory.create(serviceLocator, config::getOauth2Service))
|
@@ -228,45 +230,8 @@ private Authenticator<String, AuthenticatedPolarisPrincipal> getPolarisAuthentic
|
228 | 230 | }
|
229 | 231 |
|
230 | 232 | @JsonProperty("tokenBroker")
|
231 |
| - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") |
232 |
| - public void setTokenBrokerFactory(TokenBrokerFactory tokenBrokerFactory) { |
233 |
| - this.tokenBrokerFactory = tokenBrokerFactory; |
234 |
| - } |
235 |
| - |
236 |
| - private TokenBrokerFactory getTokenBrokerFactory() { |
237 |
| - // return a no-op implementation if none is specified |
238 |
| - return Objects.requireNonNullElseGet( |
239 |
| - tokenBrokerFactory, |
240 |
| - () -> |
241 |
| - (rc) -> |
242 |
| - new TokenBroker() { |
243 |
| - @Override |
244 |
| - public boolean supportsGrantType(String grantType) { |
245 |
| - return false; |
246 |
| - } |
247 |
| - |
248 |
| - @Override |
249 |
| - public boolean supportsRequestedTokenType(TokenType tokenType) { |
250 |
| - return false; |
251 |
| - } |
252 |
| - |
253 |
| - @Override |
254 |
| - public TokenResponse generateFromClientSecrets( |
255 |
| - String clientId, String clientSecret, String grantType, String scope) { |
256 |
| - return null; |
257 |
| - } |
258 |
| - |
259 |
| - @Override |
260 |
| - public TokenResponse generateFromToken( |
261 |
| - TokenType tokenType, String subjectToken, String grantType, String scope) { |
262 |
| - return null; |
263 |
| - } |
264 |
| - |
265 |
| - @Override |
266 |
| - public DecodedToken verify(String token) { |
267 |
| - return null; |
268 |
| - } |
269 |
| - }); |
| 233 | + public void setTokenBroker(TokenBrokerConfig tokenBroker) { |
| 234 | + this.tokenBroker = tokenBroker; |
270 | 235 | }
|
271 | 236 |
|
272 | 237 | private RealmContextResolver getRealmContextResolver() {
|
|
0 commit comments