You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "LauraXia123 (via GitHub)" <gi...@apache.org> on 2026/06/17 02:47:54 UTC
[PR] [#11686] web-v2(UI): remove simpleAuthUser for oauth mode and config request headers by authType [gravitino]
LauraXia123 opened a new pull request, #11703:
URL: https://github.com/apache/gravitino/pull/11703
### What changes were proposed in this pull request?
1. remove simpleAuthUser for oauth mode
2. config request headers by authType
### Why are the changes needed?
Fix: #11686
### Does this PR introduce _any_ user-facing change?
N/A
### How was this patch tested?
use local idp test logout action
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11686] web-v2(UI): remove simpleAuthUser for oauth mode and config request headers by authType [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11703:
URL: https://github.com/apache/gravitino/pull/11703#discussion_r3425271438
##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -180,19 +181,25 @@ const transform = {
return config
}
- // Use OAuth provider factory for proper token management
+ // Get authType from Redux store to determine which auth method to use
+ const authType = store.getState().auth.authType
+
try {
- const token = await oauthProviderFactory.getAccessToken()
-
- if (token && config?.requestOptions?.withToken !== false) {
- // ** jwt token
- config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token
- } else if (window.sessionStorage.getItem('simpleAuthUser')) {
- // Simple auth fallback
- const simpleAuthToken = window.sessionStorage.getItem('simpleAuthToken')
+ if (authType === 'oauth') {
Review Comment:
`authType` starts as `null` in the Redux slice and is only populated after `/configs` resolves. During that bootstrap window, this interceptor will skip adding an `Authorization` header entirely (even if an OAuth access token is already available), which can trigger spurious 401s/redirects on early API calls. Consider falling back to persisted auth artifacts (e.g., `localStorage.accessToken`) when `authType` is not yet known, while still avoiding the simple-auth fallback in OAuth mode.
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -150,11 +150,16 @@ export const logoutAction = createAsyncThunk(
dispatch(clearIntervalId())
dispatch(setAuthToken(''))
- dispatch(setAuthUser(null))
} else {
+ // Simple auth: clear simple auth user
dispatch(setAuthUser(null))
}
Review Comment:
In the OAuth logout path, `authUser` in Redux is no longer cleared. This can leave stale user information in the UI after `router.push('/login')` (SPA navigation), even though the token is cleared. It also makes logout behavior inconsistent between auth types.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11686] web-v2(UI): remove simpleAuthUser for oauth mode and config request headers by authType [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades merged PR #11703:
URL: https://github.com/apache/gravitino/pull/11703
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11686] web-v2(UI): remove simpleAuthUser for oauth mode and config request headers by authType [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11703:
URL: https://github.com/apache/gravitino/pull/11703#discussion_r3425320820
##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -40,6 +40,7 @@ import { useAuth as Auth } from '../../provider/session'
import { githubApis } from '@/lib/api/github'
import { isProdEnv } from '@/lib/utils'
import { oauthProviderFactory } from '@/lib/auth/providers/factory'
+import { store } from '@/lib/store'
Review Comment:
Importing the Redux `store` here introduces a circular dependency: `lib/store` → `lib/store/auth` → `lib/api/auth` → `lib/utils/axios` → `lib/store`. Even if it often “works” due to deferred access, this cycle can lead to partially-initialized modules or hard-to-debug runtime behavior depending on bundler evaluation order. Consider decoupling axios auth header selection from Redux (e.g., persist `authType` to storage when configs load, or pass authType into axios via config/requestOptions).
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -150,11 +150,14 @@ export const logoutAction = createAsyncThunk(
dispatch(clearIntervalId())
dispatch(setAuthToken(''))
- dispatch(setAuthUser(null))
- } else {
- dispatch(setAuthUser(null))
}
+ // Always clear authUser in Redux and sessionStorage on logout
+ // This ensures consistent behavior for both OAuth and simple auth
+ dispatch(setAuthUser(null))
+ sessionStorage.removeItem('simpleAuthUser')
+ sessionStorage.removeItem('simpleAuthToken')
Review Comment:
`dispatch(setAuthUser(null))` already removes `simpleAuthUser` from sessionStorage in the reducer, so removing it again here is redundant. Keeping only the `simpleAuthToken` cleanup avoids duplicated logic while preserving the intended behavior.
##########
web-v2/web/src/lib/provider/session.js:
##########
@@ -101,6 +101,10 @@ const AuthProvider = ({ children }) => {
goToMetalakeListPage()
}
} else if (authType === 'oauth') {
+ // Clear any residual simpleAuthUser when authType is oauth
+ sessionStorage.removeItem('simpleAuthUser')
+ sessionStorage.removeItem('simpleAuthToken')
+
Review Comment:
These removals are likely ineffective for OAuth mode because the OAuth path later dispatches `setAuthUser(user)`, and the `setAuthUser` reducer persists that value back into `sessionStorage` under `simpleAuthUser`. If the goal is to stop using `simpleAuthUser` for OAuth entirely, the persistence logic needs to be gated by `authType` (or use a different storage key/action for OAuth users).
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org