bharos commented on code in PR #10437:
URL: https://github.com/apache/gravitino/pull/10437#discussion_r2943044816


##########
common/src/main/java/org/apache/gravitino/dto/responses/AuthMeResponse.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.gravitino.dto.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+/** Response for the authenticated principal information. */
+@Getter
+@EqualsAndHashCode(callSuper = true)
+@ToString
+public class AuthMeResponse extends BaseResponse {
+
+  @JsonProperty("principal")
+  private final String principal;

Review Comment:
   nit : Should we add @Nullable annotation



##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -102,8 +102,32 @@ export const logoutAction = 
createAsyncThunk('auth/logoutAction', async ({ route
     try {
       const provider = await oauthProviderFactory.getProvider()
       if (provider) {
+        // For OIDC providers, use signoutRedirect to end Keycloak session
+        if (provider.getUserManager) {
+          const userManager = provider.getUserManager()
+          if (userManager) {
+            // Clear legacy auth tokens before redirect
+            localStorage.removeItem('accessToken')
+            localStorage.removeItem('authParams')
+            localStorage.removeItem('expiredIn')
+            localStorage.removeItem('isIdle')
+            localStorage.removeItem('version')
+
+            dispatch(clearIntervalId())
+            dispatch(setAuthToken(''))
+
+            // Redirect to IdP logout endpoint — this will navigate away from 
the app
+            // signoutRedirect() must be called before clearAuthData() because 
it needs
+            // the stored id_token for the id_token_hint parameter in 
RP-initiated logout
+            await userManager.signoutRedirect()
+
+            await provider.clearAuthData()
+
+            return { token: null }
+          }
+        }
+
         await provider.clearAuthData()

Review Comment:
   I'm thinking maybe we can keep the return statement, although unreachable, 
for more readability, after signoutRedirect
   
   return { token: null }   // unreachable in practice but explicit return



##########
web-v2/web/src/lib/auth/providers/oidc.js:
##########
@@ -67,17 +67,17 @@ export class OidcOAuthProvider extends BaseOAuthProvider {
       let user = await this.userManager.getUser()
 
       if (user && !user.expired) {
-        // For JWKS validation, we need the ID token (JWT format), not the 
access token
-        return user.id_token || user.access_token
+        // Use access token for API requests per OAuth2 spec
+        return user.access_token || user.id_token

Review Comment:
   My concern is that based on Oauth:
   https://oauth.net/id-tokens-vs-access-tokens/
   id_token is always a JWT but access_token may not be.
   Validator expects token to be of JWT form 
https://github.com/apache/gravitino/blob/891ab2d655692a8169b507cdee16598f3fdb6aa3/server-common/src/main/java/org/apache/gravitino/server/authentication/JwksTokenValidator.java#L102
   
   So just wondering if it can break any existing provider flow



-- 
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]

Reply via email to