From 9be3289181e52b147a76e944ef1cf422b100badd Mon Sep 17 00:00:00 2001 From: glasstiger <94906625+glasstiger@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:17:07 +0000 Subject: [PATCH] chore(ui): fix token refresh (#357) --- packages/browser-tests/questdb | 2 +- packages/web-console/src/providers/AuthProvider.tsx | 4 +--- packages/web-console/src/store/Telemetry/epics.ts | 2 +- packages/web-console/src/utils/questdb.ts | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index ad57a7eff..f5366cf6a 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit ad57a7effc10ba1c9d59db5edd6e0ca7ffca3ebc +Subproject commit f5366cf6a3279aad6bfeac2ca8f1e165b5d8cae6 diff --git a/packages/web-console/src/providers/AuthProvider.tsx b/packages/web-console/src/providers/AuthProvider.tsx index 1b1eae9e3..942a09fd7 100644 --- a/packages/web-console/src/providers/AuthProvider.tsx +++ b/packages/web-console/src/providers/AuthProvider.tsx @@ -78,7 +78,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => { const [state, dispatch] = useReducer(reducer, initialState) const setAuthToken = (tokenResponse: AuthPayload, settings: Settings) => { - if (tokenResponse.access_token && tokenResponse.id_token) { + if (tokenResponse.access_token) { tokenResponse.groups_encoded_in_token = settings["acl.oidc.groups.encoded.in.token"] tokenResponse.expires_at = getTokenExpirationDate(tokenResponse.expires_in).toString() // convert from the sec offset setValue( @@ -110,11 +110,9 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => { } const refreshAuthToken = async (settings: Settings) => { - const code_verifier = getValue(StoreKey.PKCE_CODE_VERIFIER) const response = await getAuthToken(settings, { grant_type: "refresh_token", refresh_token: getValue(StoreKey.AUTH_REFRESH_TOKEN), - code_verifier, client_id: settings["acl.oidc.client.id"], }) const tokenResponse = await response.json() diff --git a/packages/web-console/src/store/Telemetry/epics.ts b/packages/web-console/src/store/Telemetry/epics.ts index 082a0be24..66d19c8a9 100644 --- a/packages/web-console/src/store/Telemetry/epics.ts +++ b/packages/web-console/src/store/Telemetry/epics.ts @@ -59,7 +59,7 @@ export const getConfig: Epic = ( ? getValue(StoreKey.AUTH_PAYLOAD) : "{}" const token = JSON.parse(authPayload) as AuthPayload - if (token.access_token && token.id_token) { + if (token.access_token) { quest.setCommonHeaders({ Authorization: `Bearer ${token.groups_encoded_in_token ? token.id_token : token.access_token}`, }) diff --git a/packages/web-console/src/utils/questdb.ts b/packages/web-console/src/utils/questdb.ts index 9c16ad98a..7cafb9864 100644 --- a/packages/web-console/src/utils/questdb.ts +++ b/packages/web-console/src/utils/questdb.ts @@ -344,7 +344,7 @@ export class Client { if (Client.numOfPendingQueries === 0) { clearInterval(interval) const newToken = await this.refreshTokenMethod() - if (newToken.access_token && newToken.id_token) { + if (newToken.access_token) { this.setCommonHeaders({ ...this.commonHeaders, Authorization: `Bearer ${newToken.groups_encoded_in_token ? newToken.id_token : newToken.access_token}`,