This is an automated email from the ASF dual-hosted git repository.

LauraXia123 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 43893ab649 [#14957] The /configs endpoint not requires authentication 
(#14958)
43893ab649 is described below

commit 43893ab6495d98cd7ae7edb1132aec636b377d1d
Author: Qian Xia <[email protected]>
AuthorDate: Mon Nov 16 15:32:35 2026 +0800

    [#14957] The /configs endpoint not requires authentication (#14958)
    
    ### What changes were proposed in this pull request?
    The /configs endpoint not requires authentication
    
    ### Why are the changes needed?
    N/A
    
    Fixes #14957
    
    ### Does this PR introduce _any_ user-facing change?
    N/A
    
    ### How was this patch tested?
    
    1. Start Gravitino with Basic Authentication enabled.
    2. Clear the browser’s local and session storage.
    3. Open the frontend and check the /configs request in the Network tab.
    4. Confirm that the request has no Authorization header.
---
 web-v2/web/src/lib/api/auth/index.js      |  9 ++--
 web-v2/web/src/lib/api/auth/index.test.js | 74 +++++++++++++++++++++++++++++++
 web-v2/web/src/lib/utils/axios/index.js   | 10 +++--
 3 files changed, 87 insertions(+), 6 deletions(-)

diff --git a/web-v2/web/src/lib/api/auth/index.js 
b/web-v2/web/src/lib/api/auth/index.js
index 7e22d23885..a02aecc33f 100644
--- a/web-v2/web/src/lib/api/auth/index.js
+++ b/web-v2/web/src/lib/api/auth/index.js
@@ -21,9 +21,12 @@ import { defHttp } from '@/lib/utils/axios'
 import { ContentTypeEnum } from '@/lib/enums/httpEnum'
 
 export const getAuthConfigsApi = () => {
-  return defHttp.get({
-    url: '/configs'
-  })
+  return defHttp.get(
+    {
+      url: '/configs'
+    },
+    { withToken: false }
+  )
 }
 
 export const getAuthMeApi = () => {
diff --git a/web-v2/web/src/lib/api/auth/index.test.js 
b/web-v2/web/src/lib/api/auth/index.test.js
new file mode 100644
index 0000000000..e289068468
--- /dev/null
+++ b/web-v2/web/src/lib/api/auth/index.test.js
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { getAuthConfigsApi } from '@/lib/api/auth'
+import { oauthProviderFactory } from '@/lib/auth/providers/factory'
+import { defHttp } from '@/lib/utils/axios'
+
+describe('getAuthConfigsApi', () => {
+  let adapter
+  let originalAdapter
+  let getAccessToken
+
+  beforeEach(() => {
+    localStorage.clear()
+    sessionStorage.clear()
+
+    const axiosInstance = defHttp.getAxios()
+    originalAdapter = axiosInstance.defaults.adapter
+    adapter = vi.fn(async config => ({
+      data: {},
+      status: 200,
+      statusText: 'OK',
+      headers: {},
+      config
+    }))
+    axiosInstance.defaults.adapter = adapter
+    getAccessToken = vi.spyOn(oauthProviderFactory, 
'getAccessToken').mockResolvedValue('oauth-token')
+  })
+
+  afterEach(() => {
+    defHttp.getAxios().defaults.adapter = originalAdapter
+    vi.restoreAllMocks()
+    localStorage.clear()
+    sessionStorage.clear()
+  })
+
+  it.each(['oauth', 'basic', 'simple', null])('omits Authorization for auth 
type %s', async authType => {
+    if (authType) {
+      localStorage.setItem('authType', authType)
+    }
+
+    if (authType === 'basic') {
+      sessionStorage.setItem('accessToken', 'basic-token')
+    } else if (authType === 'simple') {
+      sessionStorage.setItem('simpleAuthUser', JSON.stringify({ name: 
'simple-user' }))
+    } else if (authType === null) {
+      localStorage.setItem('accessToken', 'stale-token')
+    }
+
+    await getAuthConfigsApi()
+
+    const requestConfig = adapter.mock.calls[0][0]
+    expect(requestConfig.url).toBe('/configs')
+    expect(requestConfig.headers.get('Authorization')).toBeUndefined()
+    expect(getAccessToken).not.toHaveBeenCalled()
+  })
+})
diff --git a/web-v2/web/src/lib/utils/axios/index.js 
b/web-v2/web/src/lib/utils/axios/index.js
index 1573a5c207..708f0ddb9c 100644
--- a/web-v2/web/src/lib/utils/axios/index.js
+++ b/web-v2/web/src/lib/utils/axios/index.js
@@ -175,6 +175,10 @@ const transform = {
   requestInterceptors: async (config, options) => {
     // ** Pre-Request Configuration Handling
 
+    if (config.requestOptions?.withToken === false) {
+      return config
+    }
+
     // Skip token retrieval for GitHub API calls entirely
     if (config.url === githubApis.GET) {
       return config
@@ -189,7 +193,7 @@ const transform = {
         // OAuth auth: use Bearer token from OAuth provider
         const token = await oauthProviderFactory.getAccessToken()
 
-        if (token && config?.requestOptions?.withToken !== false) {
+        if (token) {
           // ** jwt token
           config.headers.Authorization = options.authenticationScheme
             ? `${options.authenticationScheme} ${token}`
@@ -204,7 +208,7 @@ const transform = {
       } else if (authType === 'basic') {
         // Basic auth: use token from sessionStorage
         const token = sessionStorage.getItem('accessToken')
-        if (token && config?.requestOptions?.withToken !== false) {
+        if (token) {
           const isFullAuthHeader = token.startsWith('Basic ') || 
token.startsWith('Bearer ')
 
           config.headers.Authorization =
@@ -215,7 +219,7 @@ const transform = {
         // Fall back to persisted auth artifacts to avoid spurious 401s.
         // localStorage.accessToken indicates a prior OAuth session (simple 
auth doesn't persist tokens).
         const persistedToken = localStorage.getItem('accessToken')
-        if (persistedToken && config?.requestOptions?.withToken !== false) {
+        if (persistedToken) {
           config.headers.Authorization = options.authenticationScheme
             ? `${options.authenticationScheme} ${persistedToken}`
             : persistedToken

Reply via email to