jtuglu1 commented on code in PR #19236: URL: https://github.com/apache/druid/pull/19236#discussion_r3052741832
########## processing/src/main/java/org/apache/druid/auth/TaskAuthContext.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.druid.auth; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.apache.druid.guice.annotations.ExtensionPoint; + +import javax.annotation.Nullable; +import java.util.Map; + +/** + * Holds authentication context that can be passed to tasks for accessing external services + * that require user credentials (e.g., Iceberg REST Catalog with OAuth). + * + * <p>Implementations must ensure credentials are redacted during serialization by applying + * {@link TaskAuthContextRedactionMixIn} to the ObjectMapper used for persistence/logging. + * This follows the same pattern as {@link org.apache.druid.metadata.PasswordProvider} and + * {@link org.apache.druid.metadata.PasswordProviderRedactionMixIn}. + * + * <p>The auth context is injected into tasks at submission time by {@code TaskAuthContextProvider} + * and is available during task execution. It is NOT persisted to metadata storage - only the + * non-sensitive fields (identity, metadata) are serialized. + * + * <p><b>Credential lifetime:</b> Vended credentials (OAuth tokens, STS session tokens) have + * limited lifetimes, typically 1-12 hours. There is currently no credential refresh mechanism, + * so long-running tasks may fail when credentials expire. Task restarts are also not supported + * since the original credentials are not preserved. + * + * @see TaskAuthContextRedactionMixIn + */ +@ExtensionPoint +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") +public interface TaskAuthContext +{ + /** + * Returns the authenticated identity (e.g., username, email, service account name). + * This value is safe to serialize and log. + * + * @return the identity string + */ + String getIdentity(); Review Comment: > Does anything bad happen if someone sets a context and sets the identity to someone else? If we want to scope the auth context to Druid-settable only, then yes we should. IMO, I think that's a safer option but I could see people wanting to use this apart from Authorization result. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
