XJDKC commented on code in PR #2782: URL: https://github.com/apache/polaris/pull/2782#discussion_r2427413410
########## runtime/service/src/main/java/org/apache/polaris/service/credentials/connection/BearerConnectionCredentialVendor.java: ########## @@ -0,0 +1,84 @@ +/* + * 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.credentials.connection; + +import com.google.common.base.Preconditions; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Priority; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import org.apache.polaris.core.connection.AuthenticationType; +import org.apache.polaris.core.connection.BearerAuthenticationParametersDpo; +import org.apache.polaris.core.connection.ConnectionConfigInfoDpo; +import org.apache.polaris.core.credentials.connection.CatalogAccessProperty; +import org.apache.polaris.core.credentials.connection.ConnectionCredentialVendor; +import org.apache.polaris.core.credentials.connection.ConnectionCredentials; +import org.apache.polaris.core.secrets.UserSecretsManager; + +/** + * Connection credential vendor for Bearer token authentication. + * + * <p>This vendor handles Bearer token authentication by reading the bearer token from the secrets + * manager and providing it for connecting to external catalogs. + * + * <p>The vendor provides only the bearer token. When connecting to the remote catalog, Iceberg SDK + * will use this token as-is in HTTP Authorization headers. Bearer tokens typically have a limited + * lifetime and should be refreshed by the user when they expire. + * + * <p>This is the default implementation with {@code @Priority(100)}. Custom implementations can + * override this by providing a higher priority value. + */ +@RequestScoped +@AuthType(AuthenticationType.BEARER) +@Priority(100) Review Comment: Done! ########## polaris-core/src/main/java/org/apache/polaris/core/connection/BearerAuthenticationParametersDpo.java: ########## @@ -51,9 +49,10 @@ public BearerAuthenticationParametersDpo( @Override public @Nonnull Map<String, String> asIcebergCatalogProperties( - UserSecretsManager secretsManager, PolarisCredentialManager credentialManager) { - String bearerToken = secretsManager.readSecret(getBearerTokenReference()); - return Map.of(OAuth2Properties.TOKEN, bearerToken); + PolarisCredentialManager credentialManager) { + // Return only metadata properties - credentials are handled by ConnectionCredentialVendor + // Bearer auth has no metadata properties + return Map.of(); Review Comment: Done! -- 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]
