sungwy commented on code in PR #3250: URL: https://github.com/apache/polaris/pull/3250#discussion_r2610744466
########## runtime/service/src/main/java/org/apache/polaris/service/auth/ExternalAuthenticator.java: ########## @@ -0,0 +1,77 @@ +/* + * 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.auth; + +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.RequestScoped; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.iceberg.exceptions.NotAuthorizedException; +import org.apache.polaris.core.auth.PolarisPrincipal; + +/** + * Authenticator for principals supplied by an external identity provider. + * + * <p>Builds an in-memory {@link PolarisPrincipal} directly from credential claims without any + * persistence lookups. + */ +@RequestScoped +@Identifier("external") +public class ExternalAuthenticator implements Authenticator { + + @Override + public PolarisPrincipal authenticate(PolarisCredential credentials) { + PolarisCredential externalCredentials = ensureExternal(credentials); Review Comment: instead of overriding the Principal to be external here, maybe we could validate that it is external and raise an exception if it isn't instead. Then we have a clearer separation of responsibility between: 1. detecting whether a `PolarisCredential`'s origin was internal or external 2. and determining if a PolarisPrincipal should be internal, federated or external. ########## runtime/service/src/main/java/org/apache/polaris/service/auth/ExternalAuthenticator.java: ########## @@ -0,0 +1,77 @@ +/* + * 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.auth; + +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.RequestScoped; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.iceberg.exceptions.NotAuthorizedException; +import org.apache.polaris.core.auth.PolarisPrincipal; + +/** + * Authenticator for principals supplied by an external identity provider. + * + * <p>Builds an in-memory {@link PolarisPrincipal} directly from credential claims without any + * persistence lookups. + */ +@RequestScoped +@Identifier("external") +public class ExternalAuthenticator implements Authenticator { + + @Override + public PolarisPrincipal authenticate(PolarisCredential credentials) { + PolarisCredential externalCredentials = ensureExternal(credentials); Review Comment: instead of overriding the Principal to be external here, maybe we could validate that it is external and raise an exception if it isn't instead. Then we have a clearer separation of responsibility between: 1. detecting whether a `PolarisCredential`'s origin was internal or external 2. and determining if a `PolarisPrincipal` should be internal, federated or external. -- 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]
