You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "Octavi00 (via GitHub)" <gi...@apache.org> on 2026/06/27 06:15:55 UTC
[PR] Web UI support for built-in IdP Basic login [gravitino]
Octavi00 opened a new pull request, #11812:
URL: https://github.com/apache/gravitino/pull/11812
Web UI support for built-in IdP Basic login [#11682] EPIC
### What changes were proposed in this pull request?
- Fix: #11681: Added Basic login functionality following front-end session logic as requested + supporting UI modifications.
### Files Changed + why are the changes needed?
1. server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java (Feature)
- Adds web login header check to skip the unwanted browser basic auth popup
2. web/web/src/app/login/components/BasicLogin.js (New Component)
- Basic Login Page setup
- Handles user login input + error catching and message upon invalid credentials
- (Possibly add a more descriptive error message for invalid login?)
- Prompts UI error popup upon failed login
3. web/web/src/app/login/page.js (Feature)
- When visited + logged in (confirmed with an access token) immediately redirects to metalakes
- Replaced if-else logic with switch case to handle different login components (oidc, basic, and default)
4. web/web/src/app/page.js (Feature)
- Replaced empty web page with auto redirect to real main page /metalakes as described to be the home page in the issue thread.
5. web/web/src/lib/api/auth/index.js (API Token)
- Added new 'basicToken'
- Allows simple token-accept functionalities, mainly 'X-Gravitino-Web-Login' which is useful later on for stopping unwanted page refresh upon invalid logins
6. web/web/src/lib/auth/providers/factory.js (Feature)
- Added new variable 'authenticators' to read from the current config file to allow for setting 'providerType' and returning early before unsuitable OAuth behaviour, which isn't wanted for Basic Auth
- Added missing 'this.providerType = providerType' line
- Added null catch case for provider now that basic doesn't carry one
- Fixed getProvider type to prevent possible null issues
7. web/web/src/lib/provider/session.js (Feature)
- Added else-if to redirect user to the metalake (home) page if already logged in otherwise forced into the login page.
8. web/web/src/lib/store/auth/index.js (Feature)
- Added basicLoginAction to replicate loginAction with custom Basic Auth logic
- Added specific variable retention during refresh in authSlice. Prevents logout button from disappearing during refresh
- Added authType to extraReducers for extra security with 'basic' functionality (previously only for oauth)
9. web/web/src/lib/utils/axios/index.js (Feature)
- Added isFullAuthHeader to set tokens relative to Basic Login auth while also maintaining jwt flow in the subsequent line
- Added 'isFailedWebUILoginRequest' to prevent page refresh upon failed logins (this is a feature meant for OAuth which should be disabled for basic auth)
- Added catch for 401 API pop-up caused by failed logins
### Does this PR introduce _any_ user-facing change?
(Please list the user-facing changes introduced by your change, including
1. Change in user-facing APIs
- Added new basicLoginApi with basicToken.
- Contains X-Gravitino-Web-Login
### How was this patch tested?
(Please test your changes, and provide instructions on how to test it:
1. Enabled basic auth mode using given instructions, and manually tested
3. Ensured additions didn't cause any new unit test errors
4. Manually reverted to the default conf file to ensure default behaviours unaffected
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576696773
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
@Octavi00 After my research, I found that a better solution is that for basic authentication, if the status code is 401, then there should be no headers in the response.
Can you modify the Java code according to this logic?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576647590
##########
web-v2/web/src/app/page.js:
##########
@@ -19,6 +19,16 @@
'use client'
+import { useEffect } from 'react'
+
+import { useRouter } from 'next/navigation'
+
export default function Home() {
- return <></>
+ const router = useRouter()
+
+ useEffect(() => {
+ router.replace('/metalakes')
Review Comment:
The initAuth function in session.js already fully covers the redirect logic for all authType values:
* simple: Unauthenticated → /login; Authenticated → goToMetalakeListPage() → /metalakes
* basic: No token → /login; Has token → goToMetalakeListPage() → /metalakes
* oauth: No token → /login; Has token → goToMetalakeListPage() → /metalakes
The goToMetalakeListPage() function (defined at session.js:54-70) already executes router.replace('/metalakes') when the current pathname is /.
Since AuthProvider wraps all pages in layout.js, when a user visits the root path /:
1. AuthProvider's useEffect triggers initAuth, which handles the redirect based on auth state
2. page.js's useEffect also triggers router.replace('/metalakes')
These two redirects execute simultaneously, making the one in page.js completely redundant — it is entirely covered by initAuth's logic.
Conclusion: The router.replace('/metalakes') in page.js is unnecessary and can be safely removed, as initAuth already handles all redirect scenarios for every authType.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4987263134
@lasdf1234, I made your requested change to the IdpUserGroupManager class, and I also wanted to ask if my decision to add a const isBasicLoginRequest inside the axios Index.js file was okay. I know a few days ago you mentioned ignoring the browser popups for a trade off in avoiding header responses on failed logins. Is this a good alternative, or should I also avoid this until I find a better fix / altogether?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3567785388
##########
web-v2/web/src/app/page.js:
##########
@@ -19,6 +19,16 @@
'use client'
+import { useEffect } from 'react'
+
+import { useRouter } from 'next/navigation'
+
export default function Home() {
- return <></>
+ const router = useRouter()
+
+ useEffect(() => {
+ router.replace('/metalakes')
Review Comment:
In the session provider, if there is a token, it should redirect to goToMetalakeListPage(); if there is no token, it should go to the Login page. It should not default to redirecting to the Metalake page here.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3600681639
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -98,6 +98,36 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
return { token: access_token, expired: expires_in }
})
+export const basicLoginAction = createAsyncThunk(
+ 'auth/basicLoginAction',
+ async ({ username, password, router }, { dispatch }) => {
+ const basicToken = `Basic ${btoa(`${username}:${password}`)}`
+
+ const [err, res] = await to(basicLoginApi(basicToken))
Review Comment:
Leave it for now
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576262927
##########
web-v2/web/src/app/login/page.js:
##########
@@ -28,36 +29,47 @@ import { useEffect, useState, Suspense } from 'react'
import OidcLogin from './components/OidcLogin'
import DefaultLogin from './components/DefaultLogin'
+import BasicLogin from './components/BasicLogin'
import { oauthProviderFactory } from '@/lib/auth/providers/factory'
import { resetMetalakeStore } from '@/lib/store/metalakes'
import { useAppDispatch } from '@/lib/hooks/useStore'
+import { to } from '@/lib/utils'
+import { getAuthConfigs } from '@/lib/store/auth'
+
const fonts = Roboto({ subsets: ['latin'], weight: ['400'], display: 'swap' })
const { Title } = Typography
const LoginContent = () => {
+ const router = useRouter()
const searchParams = useSearchParams()
const inactiveReason = searchParams.get('reason') === 'inactive'
const maxDurationReason = searchParams.get('reason') === 'max_duration'
+ const [authType, setAuthType] = useState(null)
const [providerType, setProviderType] = useState(null)
const dispatch = useAppDispatch()
useEffect(() => {
- const detectProviderType = async () => {
- try {
- const detectedType = await oauthProviderFactory.getProviderType()
- setProviderType(detectedType)
- } catch (error) {
- setProviderType('default') // fallback to default provider
+ const detectLoginType = async () => {
+ const [, resAuthConfigs] = await to(dispatch(getAuthConfigs()))
Review Comment:
Thanks for the input, I will apply your suggested changes. I hadn't realized that authType was loaded by default, so my adjustment was pretty redundant.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4911250969
@Octavi00 Hi, will you continue working on this PR? All changes need to support web v2, and any changes specific to the old web need to be removed.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592519441
##########
web-v2/web/src/app/login/page.js:
##########
@@ -42,22 +44,45 @@ const LoginContent = () => {
const maxDurationReason = searchParams.get('reason') === 'max_duration'
const [providerType, setProviderType] = useState(null)
const dispatch = useAppDispatch()
+ const authType = useAppSelector(state => state.auth.authType)
useEffect(() => {
+ dispatch(resetMetalakeStore())
+
+ if (authType !== 'oauth') {
+ return
+ }
+
const detectProviderType = async () => {
try {
const detectedType = await oauthProviderFactory.getProviderType()
setProviderType(detectedType)
} catch (error) {
- setProviderType('default') // fallback to default provider
+ setProviderType('default')
}
}
- dispatch(resetMetalakeStore())
detectProviderType()
- }, [])
+ }, [authType, dispatch])
- const useOidcLogin = providerType === 'oidc'
+ const renderLogin = () => {
+ switch (authType) {
+ case 'basic':
+ return <BasicLogin />
+
+ case 'simple':
+ return <SimpleLogin />
+
+ case 'oauth':
+ if (providerType === null) return null
+ if (providerType === 'oidc') return <OidcLogin />
+
+ return <DefaultLogin />
+
+ default:
+ return null
Review Comment:
I like this idea, but I will instead use a spin from antd just for the sake of a nicer ui
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4888987723
> @Octavi00 Please implement this UI support onto web-v2, as we will no longer be maintaining the legacy web version moving forward. Thx
@Octavi00 Please take a look at this comment. In addition, in the web v2 version, if authentication is enabled in simple mode, there will also be a login page, which is in the DefaultLogin component. So we need to first decouple the simple authentication login from the OAuth default provider login interface. Therefore, the login page should first be divided by oauthType into simple/basic/oauth, and then further divided by the providerType under the OAuth mode. The providerType is determined by the config['gravitino.authenticator.oauth.provider'] configuration.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4941977875
Hi @LauraXia123, I've spent some time adapting my V1 changes into the V2 web, and it actually turned out to be a pretty smooth process. I used an ant design in my BasicLoginPage.js to avoid making an unnecessary decision, like installing another library in order to reuse my V1 page. I got the ui page to show a proper error message upon failed login attempts, and also included the redirection from root (8090) to homepage (ui/metalakes) as I mentioned in the v1 rendition. I avoided some unnecessary changes for v2, and I included the decoupling method you were looking for in the login/page.js. I separated auth from oidcs or default into being derived based on authType, as well as providerType if it's Oauth. Also, would you like me to rename the default variable to something like defaultOAuth? Apart from that, all changes are very similar, and I would like to request a copilot review, as was done previously, to help make sure I'm not overlooking something.
Thank you
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3577460011
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -175,6 +209,11 @@ export const logoutAction = createAsyncThunk(
)
export const setIntervalIdAction = createAsyncThunk('auth/setIntervalIdAction', async (expiredIn, { dispatch }) => {
+ // If the auth type is basic, we don't need to set an interval for token refresh
+ if (localStorage.getItem('authType') === 'basic') {
+ return { intervalId: null }
+ }
+
Review Comment:
setIntervalIdAction is never called for basic auth — the guard is unreachable dead code
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4987809955
> I made your requested change to the IdpUserGroupManager class, and I also wanted to ask if my decision to add a const isBasicLoginRequest inside the axios Index.js file was okay. I know a few days ago you mentioned ignoring the browser popups for a trade off in avoiding header responses on failed logins. Is this a good alternative, or should I also avoid this until I find a better fix / altogether?
If such changes are made, without modifying the backend code, it is possible to avoid the pop-up window. I think this is feasible.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592407904
##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -244,7 +253,7 @@ const transform = {
}
try {
- if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
+ if (code === 'ECONNABORTED' && message?.indexOf('timeout')) {
Review Comment:
`message?.indexOf('timeout')` is used as a boolean, but `String#indexOf` returns `-1` when not found (truthy), so this condition will incorrectly treat *any* ECONNABORTED as a timeout unless `message` is undefined. Use `includes()` or compare `indexOf(...) !== -1`.
##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -292,8 +312,8 @@ const transform = {
}
const retryRequest = new AxiosRetry()
- const { isOpenRetry } = originConfig.requestOptions.retryRequest
- originConfig.method?.toUpperCase() === RequestEnum.GET && isOpenRetry && retryRequest.retry(axiosInstance, error)
+ const { isOpenRetry } = originConfig?.requestOptions?.retryRequest
+ originConfig?.method?.toUpperCase() === RequestEnum.GET && isOpenRetry && retryRequest.retry(axiosInstance, error)
Review Comment:
`const { isOpenRetry } = originConfig?.requestOptions?.retryRequest` can still throw when `retryRequest` is undefined because destructuring from `undefined` is a runtime error. Read the flag via optional chaining instead.
##########
web-v2/web/src/lib/api/auth/index.js:
##########
@@ -44,3 +44,17 @@ export const loginApi = (url, params) => {
{ withToken: false }
)
}
+
+export const basicLoginApi = basicToken => {
+ return defHttp.get(
+ {
+ url: '/api/version',
+ headers: {
+ Authorization: basicToken,
+ Accept: 'application/vnd.gravitino.v1+json',
+ 'Content-Type': 'application/json'
+ }
Review Comment:
`basicLoginApi` describes using a WebUI login header (per PR description) to prevent the browser Basic-auth popup, but the request doesn’t currently send such a header. If the backend gates `WWW-Authenticate: Basic` suppression on a header, add it here (and drop `Content-Type` for a GET to avoid unnecessary CORS preflights).
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -113,7 +113,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
// to let client to create correct authenticated request.
// Refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
for (String challenge : ue.getChallenges()) {
- resp.setHeader(AuthConstants.HTTP_CHALLENGE_HEADER, challenge);
+ if (!challenge.toLowerCase().startsWith("basic")) {
+ resp.setHeader(AuthConstants.HTTP_CHALLENGE_HEADER, challenge);
+ }
Review Comment:
This currently suppresses `WWW-Authenticate: Basic` challenges for *all* clients. The PR description mentions skipping the browser Basic-auth popup via a **web-login header check**, but no header gating is implemented here, so non-WebUI clients will also stop receiving Basic challenges on 401. Gate the suppression on an explicit WebUI header (and add a regression test) so only WebUI requests skip the Basic challenge.
##########
web-v2/web/src/app/login/page.js:
##########
@@ -42,22 +44,45 @@ const LoginContent = () => {
const maxDurationReason = searchParams.get('reason') === 'max_duration'
const [providerType, setProviderType] = useState(null)
const dispatch = useAppDispatch()
+ const authType = useAppSelector(state => state.auth.authType)
useEffect(() => {
+ dispatch(resetMetalakeStore())
+
+ if (authType !== 'oauth') {
+ return
+ }
+
const detectProviderType = async () => {
try {
const detectedType = await oauthProviderFactory.getProviderType()
setProviderType(detectedType)
} catch (error) {
- setProviderType('default') // fallback to default provider
+ setProviderType('default')
}
}
- dispatch(resetMetalakeStore())
detectProviderType()
- }, [])
+ }, [authType, dispatch])
- const useOidcLogin = providerType === 'oidc'
+ const renderLogin = () => {
+ switch (authType) {
+ case 'basic':
+ return <BasicLogin />
+
+ case 'simple':
+ return <SimpleLogin />
+
+ case 'oauth':
+ if (providerType === null) return null
+ if (providerType === 'oidc') return <OidcLogin />
+
+ return <DefaultLogin />
+
+ default:
+ return null
Review Comment:
When `authType` hasn’t been loaded yet (initially `null` on a fresh visit), `renderLogin()` returns `null`, resulting in a blank login card until `/configs` resolves. Show a lightweight loading state instead of rendering nothing.
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -98,6 +98,36 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
return { token: access_token, expired: expires_in }
})
+export const basicLoginAction = createAsyncThunk(
+ 'auth/basicLoginAction',
+ async ({ username, password, router }, { dispatch }) => {
+ const basicToken = `Basic ${btoa(`${username}:${password}`)}`
+
+ const [err, res] = await to(basicLoginApi(basicToken))
Review Comment:
New Basic-login behavior is introduced here (token construction, `/api/version` probe, sessionStorage persistence, and redirect), but there are no Jest/unit tests covering the success + 401 failure paths. Given this repo already has Web UI unit tests (e.g., `web-v2/web/src/lib/auth/providers/*.test.js`), please add coverage for `basicLoginAction` (including that failed login does not trigger a full page reload).
##########
web-v2/web/src/app/login/components/SimpleLogin.js:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { clearIntervalId, setAuthUser } from '@/lib/store/auth'
+
+function SimpleLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+ const [form] = Form.useForm()
+
+ useEffect(() => {
+ if (store.intervalId) {
+ clearIntervalId()
+ }
+ }, [store.intervalId])
Review Comment:
`clearIntervalId` is a Redux action creator, but it’s being called directly here (no dispatch), so the refresh interval will not actually be cleared. Dispatch the action from the effect.
##########
plugins/idp-basic/src/main/java/org/apache/gravitino/idp/IdpUserGroupManager.java:
##########
@@ -158,7 +158,7 @@ public IdpUser authenticate(String username, String password) {
"Invalid username or password", AuthConstants.AUTHORIZATION_BASIC_HEADER.trim());
}
return user;
- } catch (NotFoundException e) {
+ } catch (Exception e) {
throw new UnauthorizedException(
"Invalid username or password", AuthConstants.AUTHORIZATION_BASIC_HEADER.trim());
}
Review Comment:
Catching `Exception` here will convert unexpected failures (e.g., storage/IO/runtime bugs) into a 401 "Invalid username or password", which can hide real server-side errors and make incidents harder to debug. Limit this catch to the expected "user not found" case and let other exceptions surface as internal errors.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576654519
##########
web-v2/web/src/app/login/components/BasicLogin.js:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { basicLoginAction, setIntervalIdAction, clearIntervalId } from '@/lib/store/auth'
+
+const defaultValues = {
+ username: '',
+ password: ''
+}
+
+const schema = yup.object().shape({
+ username: yup.string().required(),
+ password: yup.string().required()
+})
+
+function BasicLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setError,
+ formState: { errors }
+ } = useForm({
+ defaultValues: Object.assign({}, defaultValues),
+ mode: 'onChange',
+ resolver: yupResolver(schema)
+ })
+
+ useEffect(() => {
+ if (store.intervalId) {
+ dispatch(clearIntervalId())
+ }
+ }, [store.intervalId, dispatch])
+
+ const onSubmit = async data => {
+ try {
+ // Using .unwrap() to catch failed login errors
+ await dispatch(basicLoginAction({ username: data.username, password: data.password, router })).unwrap()
+
+ // Clear the password after a successful login
+ reset({ username: data.username, password: '' })
+ } catch (error) {
+ setError('username', {
+ type: 'manual',
+ message: error?.message || 'Login failed'
+ })
+ }
+ }
+
+ const onError = errors => {
+ // Form validation errors are handled by the UI
+ }
+
+ return (
+ <form autoComplete='off' onSubmit={handleSubmit(onSubmit, onError)}>
+ <Form component={false} layout='vertical'>
+ <Form.Item label='Username' validateStatus={errors.username ? 'error' : ''} help={errors.username?.message}>
+ <Controller name='username' control={control} render={({ field }) => <Input {...field} placeholder='' />} />
+ </Form.Item>
+
+ <Form.Item label='Password' validateStatus={errors.password ? 'error' : ''} help={errors.password?.message}>
+ <Controller
+ name='password'
+ control={control}
+ render={({ field }) => <Input.Password {...field} placeholder='' />}
+ />
+ </Form.Item>
+
+ <Button block size='large' type='primary' htmlType='submit'>
Review Comment:
Can u add a loading status for the login button?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3600471700
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -98,6 +98,36 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
return { token: access_token, expired: expires_in }
})
+export const basicLoginAction = createAsyncThunk(
+ 'auth/basicLoginAction',
+ async ({ username, password, router }, { dispatch }) => {
+ const basicToken = `Basic ${btoa(`${username}:${password}`)}`
+
+ const [err, res] = await to(basicLoginApi(basicToken))
Review Comment:
@LauraXia123 I have started working on a test file, but I wanted to ask if I was dropping it in the right spot? Basically oidc test file was placed right in the provider folder alongside it, but since basicLoginAction is simply a function, would it make sense to write a index.test.js file in the store/auth folder? I get that the loginAction doesn't particularly need a test file because it's handled by the oidc provider test, but what about the simple auth case? Would that also need a test?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3584291995
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,14 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
-
Review Comment:
Do not change the position of filterAuthenticators.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4988055025
> If such changes are made, without modifying the backend code, it is possible to avoid the pop-up window. I think this is feasible.
Great, I had already implemented such changes, and they have proven to be successful on my end.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3593039531
##########
web-v2/web/src/app/login/components/SimpleLogin.js:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { clearIntervalId, setAuthUser } from '@/lib/store/auth'
+
+function SimpleLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+ const [form] = Form.useForm()
+
+ useEffect(() => {
+ if (store.intervalId) {
+ dispatch(clearIntervalId())
+ }
+ }, [dispatch, store.intervalId])
Review Comment:
intervalId is always null when SimpleLogin is mounted
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3567774993
##########
web-v2/web/src/app/login/page.js:
##########
@@ -28,36 +29,47 @@ import { useEffect, useState, Suspense } from 'react'
import OidcLogin from './components/OidcLogin'
import DefaultLogin from './components/DefaultLogin'
+import BasicLogin from './components/BasicLogin'
import { oauthProviderFactory } from '@/lib/auth/providers/factory'
import { resetMetalakeStore } from '@/lib/store/metalakes'
import { useAppDispatch } from '@/lib/hooks/useStore'
+import { to } from '@/lib/utils'
+import { getAuthConfigs } from '@/lib/store/auth'
+
const fonts = Roboto({ subsets: ['latin'], weight: ['400'], display: 'swap' })
const { Title } = Typography
const LoginContent = () => {
+ const router = useRouter()
const searchParams = useSearchParams()
const inactiveReason = searchParams.get('reason') === 'inactive'
const maxDurationReason = searchParams.get('reason') === 'max_duration'
+ const [authType, setAuthType] = useState(null)
const [providerType, setProviderType] = useState(null)
const dispatch = useAppDispatch()
useEffect(() => {
- const detectProviderType = async () => {
- try {
- const detectedType = await oauthProviderFactory.getProviderType()
- setProviderType(detectedType)
- } catch (error) {
- setProviderType('default') // fallback to default provider
+ const detectLoginType = async () => {
+ const [, resAuthConfigs] = await to(dispatch(getAuthConfigs()))
Review Comment:
In the initial stage of the project, getAuthConfigs() is called by default. You can see this in the initAuth function inside the session file. Therefore, you don’t need to call it again; just directly use authType from the store.auth object.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3567797836
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
On the web side, we decide whether to call basicLoginApi based on whether authType is 'basic'. Is it necessary to add the header here? Or is this requirement due to some conflict on the backend? @lasdf1234
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3577351133
##########
web-v2/web/src/app/login/page.js:
##########
@@ -94,7 +99,15 @@ const LoginContent = () => {
/>
)}
- {useOidcLogin ? <OidcLogin /> : <DefaultLogin />}
+ {authType === null ? null : authType === 'basic' ? (
+ <BasicLogin />
+ ) : authType === 'simple' ? (
+ <DefaultLogin />
+ ) : authType === 'oauth' && providerType === null ? null : authType === 'oauth' && providerType === 'oidc' ? (
+ <OidcLogin />
+ ) : authType === 'oauth' ? (
+ <DefaultLogin />
+ ) : null}
Review Comment:
I suggest splitting the simple login form and the OAuth login form within the DefaultLogin component into two separate components, so that loading components based on authType becomes clearer.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3503201144
##########
web/web/src/app/login/components/BasicLogin.js:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Grid, Button, TextField, FormControl, FormHelperText } from '@mui/material'
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { basicLoginAction, setIntervalIdAction, clearIntervalId } from '@/lib/store/auth'
+
+const defaultValues = {
+ username: '',
+ password: ''
+}
+
+const schema = yup.object().shape({
+ username: yup.string().required(),
+ password: yup.string().required()
+})
+
+function BasicLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setError,
+ formState: { errors }
+ } = useForm({
+ defaultValues: Object.assign({}, defaultValues),
+ mode: 'onChange',
+ resolver: yupResolver(schema)
+ })
+
+ useEffect(() => {
+ if (store.intervalId) {
+ dispatch(clearIntervalId())
+ }
+ }, [store.intervalId, dispatch])
+
+ const onSubmit = async data => {
+ try {
+ //Using .unwrap() to catch failed login errors
+ await dispatch(basicLoginAction({ username: data.username, password: data.password, router })).unwrap()
+ await dispatch(setIntervalIdAction())
+
+ reset({ ...data })
Review Comment:
basicLoginAction uses a static Basic credential (no expiry), but this component starts the refresh-token interval via setIntervalIdAction(). That interval calls refreshToken() (OAuth flow) and will keep firing in basic mode, causing repeated failing requests/toasts and potentially clearing auth state. Also, after successful login the form is reset to the submitted data, leaving the password in the input state; it should be cleared.
##########
web/web/src/app/login/components/BasicLogin.js:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Grid, Button, TextField, FormControl, FormHelperText } from '@mui/material'
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { basicLoginAction, setIntervalIdAction, clearIntervalId } from '@/lib/store/auth'
+
+const defaultValues = {
+ username: '',
+ password: ''
+}
+
+const schema = yup.object().shape({
+ username: yup.string().required(),
+ password: yup.string().required()
+})
+
+function BasicLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setError,
+ formState: { errors }
+ } = useForm({
+ defaultValues: Object.assign({}, defaultValues),
+ mode: 'onChange',
+ resolver: yupResolver(schema)
+ })
+
+ useEffect(() => {
+ if (store.intervalId) {
+ dispatch(clearIntervalId())
+ }
+ }, [store.intervalId, dispatch])
+
+ const onSubmit = async data => {
+ try {
+ //Using .unwrap() to catch failed login errors
+ await dispatch(basicLoginAction({ username: data.username, password: data.password, router })).unwrap()
+ await dispatch(setIntervalIdAction())
+
+ reset({ ...data })
+ } catch (error) {
+ // Insert UI error here
+ setError('password', {
+ type: 'manual',
+ message: 'Invalid username or password'
+ })
+ }
Review Comment:
The catch block always sets "Invalid username or password" on the password field, even for network/server errors thrown by basicLoginAction (e.g., connection refused). This can mislead users and hide the actual failure reason that basicLoginAction already computed.
##########
web/web/src/lib/utils/axios/index.js:
##########
@@ -213,16 +217,23 @@ const transform = {
const errorMessageMode = originConfig?.requestOptions?.errorMessageMode || 'none'
const msg = response?.data?.error?.message ?? response?.data?.message ?? ''
const err = error?.toString?.() ?? ''
+
+ const isFailedWebUILoginRequest =
+ response?.status === 401 &&
+ originConfig?.url === '/api/version' &&
+ originConfig?.headers?.['X-Gravitino-Web-Login'] === 'true'
+
Review Comment:
isFailedWebUILoginRequest relies on originConfig.headers['X-Gravitino-Web-Login'], but Axios may normalize header names (e.g. to lowercase) or store headers as an AxiosHeaders instance. This can cause the flag to be missed and fall into the normal 401 redirect flow, reloading the page instead of staying on the login form.
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,22 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
-
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
+
Review Comment:
Class member ordering: static constants should be declared before instance fields (per the project member-order guideline). WEB_LOGIN_HEADER is currently after instance fields, which will fail style/checkstyle expectations if enforced consistently.
##########
web/web/src/lib/auth/providers/factory.js:
##########
@@ -65,6 +65,18 @@ class OAuthProviderFactory {
}
const config = await response.json()
+ const authenticators = config['gravitino.authenticators'] || []
+
+ // Authenticator logic
+ if (authenticators.includes('org.apache.gravitino.idp.auth.BasicAuthenticator')) {
+ // If BasicAuthenticator is present, set provider type to 'basic' and do not initialize any OAuth provider
+ this.providerType = 'basic'
+ this.currentProvider = null
+
+ return null
+ }
Review Comment:
The new BasicAuthenticator detection branch (providerType='basic' and currentProvider=null) isn't covered by existing OAuthProviderFactory tests. Adding a unit test for this path (including getProviderType() and getAccessToken() behavior) would ensure basic mode doesn't regress while evolving OAuth logic.
##########
web/web/src/lib/store/auth/index.js:
##########
@@ -91,6 +91,36 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
return { token: access_token, expired: expires_in }
})
+export const basicLoginAction = createAsyncThunk(
+ 'auth/basicLoginAction',
+ async ({ username, password, router }, { dispatch }) => {
+ const basicToken = `Basic ${btoa(`${username}:${password}`)}`
+
+ const [err, res] = await to(basicLoginApi(basicToken))
+
+ if (err || !res) {
+ const message =
+ err?.response?.status === 401 ? 'Invalid username or password' : err?.response?.data?.err || err?.message
+
+ toast.error(message, {
+ id: `global_error_message_status_${err?.response?.status}`
+ })
+
+ throw new Error(message)
+ }
+
+ localStorage.setItem('accessToken', basicToken)
+ localStorage.setItem('isIdle', false)
+ localStorage.removeItem('expiredIn') // Basic auth does not have an expiration time
Review Comment:
basicLoginAction persists a Basic Authorization header (base64(username:password)) into localStorage. Unlike an OAuth access token, this is effectively the user's long-lived credentials and will survive browser restarts; storing it in localStorage significantly increases impact of any XSS or local profile compromise. Consider using sessionStorage (clears on tab close) or a server-issued short-lived token/cookie instead of persisting the Basic credential.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4954039001
@Octavi00 We shouldn't modify java code.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576347234
##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -144,25 +174,29 @@ export const logoutAction = createAsyncThunk(
} catch (error) {
console.warn('[Logout Action] Provider cleanup failed:', error)
}
+ }
- // Clear legacy auth tokens
- localStorage.removeItem('accessToken')
- localStorage.removeItem('authParams')
- localStorage.removeItem('expiredIn')
- localStorage.removeItem('version')
+ // Clear legacy auth tokens (local and session storage) after provider cleanup
+ localStorage.removeItem('accessToken')
+ sessionStorage.removeItem('accessToken')
- dispatch(clearIntervalId())
- dispatch(setAuthToken(''))
- }
+ localStorage.removeItem('authParams')
+ sessionStorage.removeItem('authParams')
+
+ localStorage.removeItem('expiredIn')
+ sessionStorage.removeItem('expiredIn')
+
+ localStorage.removeItem('version')
+ sessionStorage.removeItem('version')
+
+ dispatch(clearIntervalId())
+ dispatch(setAuthToken(''))
// Always clear authUser in Redux and sessionStorage on logout
// This ensures consistent behavior for both OAuth and simple auth
dispatch(setAuthUser(null))
sessionStorage.removeItem('simpleAuthToken')
- // Clear persisted authType to avoid stale auth mode on next visit
Review Comment:
I removed these lines due to logout -> login issues. Basically, the page would need to be refreshed to rerun initAuth and reset authType now that im no longer pulling Auth conf in longin.js
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576696773
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
@roryqi When the user enters an incorrect password, a pop-up window will appear on the browser. Do you think this is the correct scenario? If this behavior is to be corrected, the code in the backend needs to be modified. (The modified logic is to add a special judgment. If the browser calls the backend interface and encounters a 401 error, the response will not set the header.)
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3526344444
##########
web/web/src/lib/auth/providers/factory.js:
##########
@@ -65,6 +65,18 @@ class OAuthProviderFactory {
}
const config = await response.json()
+ const authenticators = config['gravitino.authenticators'] || []
+
+ // Authenticator logic
+ if (authenticators.includes('org.apache.gravitino.idp.auth.BasicAuthenticator')) {
+ // If BasicAuthenticator is present, set provider type to 'basic' and do not initialize any OAuth provider
+ this.providerType = 'basic'
+ this.currentProvider = null
+
+ return null
+ }
Review Comment:
In the case where authType === 'basic', the OAuth factory will not be called.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576493515
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
It doesn't matter if a default browser pop-up appears. Don't modify any backend code for now.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3567810450
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
@Octavi00 if "basic" is set as the first option, it will automatically enable the basic login function.What is this WEB_LOGIN_HEADER for?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 merged PR #11812:
URL: https://github.com/apache/gravitino/pull/11812
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592548598
##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -244,7 +253,7 @@ const transform = {
}
try {
- if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
+ if (code === 'ECONNABORTED' && message?.indexOf('timeout')) {
Review Comment:
This was a JS oversight on my part. It's definitely correct to change, otherwise will always be true unless 0.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592502996
##########
plugins/idp-basic/src/main/java/org/apache/gravitino/idp/IdpUserGroupManager.java:
##########
@@ -158,7 +158,7 @@ public IdpUser authenticate(String username, String password) {
"Invalid username or password", AuthConstants.AUTHORIZATION_BASIC_HEADER.trim());
}
return user;
- } catch (NotFoundException e) {
+ } catch (Exception e) {
throw new UnauthorizedException(
"Invalid username or password", AuthConstants.AUTHORIZATION_BASIC_HEADER.trim());
}
Review Comment:
Not applicable, I was directly requested to swap into Exception from previous NFE to strengthen catch.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4850733850
@Octavi00 Can u fix these comment issues above?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576261464
##########
web-v2/web/src/app/page.js:
##########
@@ -19,6 +19,16 @@
'use client'
+import { useEffect } from 'react'
+
+import { useRouter } from 'next/navigation'
+
export default function Home() {
- return <></>
+ const router = useRouter()
+
+ useEffect(() => {
+ router.replace('/metalakes')
Review Comment:
This was more of an issue with the URL adjustment that I had asked about previously. Basically, this is unrelated to my login function, and more so UX. If a user loads the main page, http://localhost:8090, they are greeted with a blank white page. Since I was previously explained that the main page for gravitino is the metalakes page, I had decided that it would be nice to include a redirect to the metalake page, which is the functional main page. This would happen regardless of authentication being enabled.
The nice thing about this change is that when auth is enabled, if the user is sent to metalakes page, they are then sent to login due to the metalakes page being locked without a token.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4976618888
@Octavi00 The modified Java code has no logical issues.
Don't forget to modify the IdpUserGroupManager class.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592505200
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -113,7 +113,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
// to let client to create correct authenticated request.
// Refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
for (String challenge : ue.getChallenges()) {
- resp.setHeader(AuthConstants.HTTP_CHALLENGE_HEADER, challenge);
+ if (!challenge.toLowerCase().startsWith("basic")) {
+ resp.setHeader(AuthConstants.HTTP_CHALLENGE_HEADER, challenge);
+ }
Review Comment:
NA, was advised against using headers during 401 responses
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592533636
##########
web-v2/web/src/lib/api/auth/index.js:
##########
@@ -44,3 +44,17 @@ export const loginApi = (url, params) => {
{ withToken: false }
)
}
+
+export const basicLoginApi = basicToken => {
+ return defHttp.get(
+ {
+ url: '/api/version',
+ headers: {
+ Authorization: basicToken,
+ Accept: 'application/vnd.gravitino.v1+json',
+ 'Content-Type': 'application/json'
+ }
Review Comment:
Irrelevant, im no longer implementing headers for 401 responses, and this was included to do just that. Content type shouldnt cause any issues, so i'd rather leave it than remove unless specifically requested
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4988234988
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|67.85% **`+0.03%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|76.53%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|47.82%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|80.23%|:green_circle:|
|catalog-glue|66.91%|:green_circle:|
|catalog-hive|79.42%|:green_circle:|
|catalog-jdbc-clickhouse|81.74%|:green_circle:|
|catalog-jdbc-common|44.22%|:green_circle:|
|catalog-jdbc-doris|81.6%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23%|:green_circle:|
|catalog-jdbc-oceanbase|80.91%|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|86.48%|:green_circle:|
|catalog-lakehouse-paimon|84.25%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.49% **`+0.3%`**|:green_circle:|
|client-java|78.29%|:green_circle:|
|common|51.95%|:green_circle:|
|core|82.53% **`-0.1%`**|:green_circle:|
|filesystem-hadoop3|77.3%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|47.09%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.29%|:green_circle:|
|iceberg-common|63.63%|:green_circle:|
|iceberg-rest-server|74.9%|:green_circle:|
|idp-basic|86.02% **`+0.59%`**|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.67%|:red_circle:|
|lance-rest-server|64.84%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|86.1%|:green_circle:|
|server-common|74.59% **`+0.05%`**|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|46.01%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|40.29%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|cli|[TypeConverter.java](https://github.com/Octavi00/gravitino/blob/6d437873ff7001f31b1305c1c3b0befc4024cfbd/clients/cli/src/main/java/org/apache/gravitino/cli/TypeConverter.java)|97.06%|:green_circle:|
|core|[IsolatedClassLoader.java](https://github.com/Octavi00/gravitino/blob/6d437873ff7001f31b1305c1c3b0befc4024cfbd/core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java)|56.12%|:red_circle:|
|idp-basic|[IdpUserGroupManager.java](https://github.com/Octavi00/gravitino/blob/6d437873ff7001f31b1305c1c3b0befc4024cfbd/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/IdpUserGroupManager.java)|92.59%|:green_circle:|
|server-common|[AuthenticationFilter.java](https://github.com/Octavi00/gravitino/blob/6d437873ff7001f31b1305c1c3b0befc4024cfbd/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java)|76.56%|:green_circle:|
</details>
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3504012506
##########
web/web/src/lib/auth/providers/factory.js:
##########
@@ -65,6 +65,18 @@ class OAuthProviderFactory {
}
const config = await response.json()
+ const authenticators = config['gravitino.authenticators'] || []
+
+ // Authenticator logic
+ if (authenticators.includes('org.apache.gravitino.idp.auth.BasicAuthenticator')) {
+ // If BasicAuthenticator is present, set provider type to 'basic' and do not initialize any OAuth provider
+ this.providerType = 'basic'
+ this.currentProvider = null
+
+ return null
+ }
Review Comment:
This file handles OAuth. Why is Basic authentication logic added here?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4911331950
@LauraXia123 Yes, I assumed all original changes would want to be removed, but I'm currently working on transferring my additions from v1 to v2 right now. In doing so, I have noticed a few differences that may need to be addressed, but I will hold off until I get to a more complete state.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3577465930
##########
web-v2/web/src/app/login/components/BasicLogin.js:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { basicLoginAction, setIntervalIdAction, clearIntervalId } from '@/lib/store/auth'
Review Comment:
`setIntervalIdAction` It's imported but never used,should remove
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3576138235
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -41,15 +41,21 @@
import org.apache.gravitino.utils.PrincipalUtils;
public class AuthenticationFilter implements Filter {
-
- private final List<Authenticator> filterAuthenticators;
+ private static final String WEB_LOGIN_HEADER = "X-Gravitino-Web-Login";
/**
* The matcher used to identify health check paths that bypass authentication. Subclasses may
* replace this with a server-specific matcher (e.g. {@code IcebergHealthCheckPathMatcher}).
*/
protected HealthCheckPathMatcher healthCheckMatcher = new HealthCheckPathMatcher();
+ private final List<Authenticator> filterAuthenticators;
+ // Skip HTTP challenge for Web UI login requests to avoid the browser's native Basic auth popup.
+ private boolean isWebLoginRequest(ServletRequest request) {
+ return request instanceof HttpServletRequest
+ && "true".equalsIgnoreCase(((HttpServletRequest) request).getHeader(WEB_LOGIN_HEADER));
+ }
+
Review Comment:
Im using isWebLoginRequest, as a way to avoid an unwanted web popup when an incorrect passsword is entered. Maybe I could add more description to these changes, but as of right now, removing the addition added to line 117 would recreate my issue.
<img width="1311" height="953" alt="Image" src="https://github.com/user-attachments/assets/71ec65a8-0d1b-411e-b664-39e65605b962" />
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3577461577
##########
web-v2/web/src/app/login/components/BasicLogin.js:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { basicLoginAction, setIntervalIdAction, clearIntervalId } from '@/lib/store/auth'
+
+const defaultValues = {
+ username: '',
+ password: ''
+}
+
+const schema = yup.object().shape({
+ username: yup.string().required(),
+ password: yup.string().required()
+})
+
+function BasicLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ setError,
+ formState: { errors }
+ } = useForm({
+ defaultValues: Object.assign({}, defaultValues),
+ mode: 'onChange',
+ resolver: yupResolver(schema)
+ })
+
+ useEffect(() => {
+ if (store.intervalId) {
+ dispatch(clearIntervalId())
+ }
+ }, [store.intervalId, dispatch])
Review Comment:
intervalId is always null when BasicLogin is mounted; logoutAction already clears it
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3577539569
##########
web-v2/web/src/lib/provider/session.js:
##########
@@ -100,6 +100,16 @@ const AuthProvider = ({ children }) => {
dispatch(setAuthUser(sessionUser))
goToMetalakeListPage()
}
+ } else if (authType === 'basic') {
+ const tokenToUse = sessionStorage.getItem('accessToken')
+
+ if (tokenToUse) {
+ basicAuthToken && dispatch(setAuthToken(basicAuthToken))
+ basicAuthUser && dispatch(setAuthUser(basicAuthUser))
+ goToMetalakeListPage()
Review Comment:
`basicAuthToken` & `basicAuthUser` These two variables are not declared or defined anywhere.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4967688257
Another issue is:
Coluld you modify IdpUserGroupManager?
public IdpUser authenticate(String username, String password) {
try {
IdpUser user = USER_SERVICE.getIdpUser(username);
if (user.passwordHash() == null || !passwordHasher.verify(password, user.passwordHash())) {
throw new UnauthorizedException("Invalid username or password", ...);
}
return user;
} catch (NotFoundException e) {
throw new UnauthorizedException("Invalid username or password", ...);
}
}
Could you use Exception instead of NotFoundException?
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "Octavi00 (via GitHub)" <gi...@apache.org>.
Octavi00 commented on code in PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#discussion_r3592509503
##########
web-v2/web/src/app/login/components/SimpleLogin.js:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+'use client'
+
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { Button, Form, Input } from 'antd'
+
+import { useAppDispatch, useAppSelector } from '@/lib/hooks/useStore'
+import { clearIntervalId, setAuthUser } from '@/lib/store/auth'
+
+function SimpleLogin() {
+ const router = useRouter()
+ const dispatch = useAppDispatch()
+ const store = useAppSelector(state => state.auth)
+ const [form] = Form.useForm()
+
+ useEffect(() => {
+ if (store.intervalId) {
+ clearIntervalId()
+ }
+ }, [store.intervalId])
Review Comment:
Yeah, since it is a redux this is necessary.
--
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] Web UI support for built-in IdP Basic login [gravitino]
Posted by "LauraXia123 (via GitHub)" <gi...@apache.org>.
LauraXia123 commented on PR #11812:
URL: https://github.com/apache/gravitino/pull/11812#issuecomment-4999478126
@Octavi00 Thank for your contribution, LGTM
--
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