OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
encoded whole state
Lucas Oliveira7cbe69ad755d
diff --git a/frontend/app/api/mutations/useConnectConnectorMutation.ts b/frontend/app/api/mutations/useConnectConnectorMutation.tsindex ee7b063ea..8412f891e 100644--- a/frontend/app/api/mutations/useConnectConnectorMutation.ts+++ b/frontend/app/api/mutations/useConnectConnectorMutation.ts@@ -71,8 +71,8 @@ export const useConnectConnectorMutation = () => {localStorage.setItem("auth_purpose", "data_source");const returnUrl = result.public_return_url || window.location.origin;- const encodedReturnUrl = encodeBase64(returnUrl);- const state = `id=${result.connection_id}&return=${encodedReturnUrl}`;+ const stateQuery = `id=${result.connection_id}&return=${returnUrl}`;+ const state = encodeBase64(stateQuery);const authUrl =`${result.oauth_config.authorization_endpoint}?` +diff --git a/frontend/app/auth/callback/page.tsx b/frontend/app/auth/callback/page.tsxindex 68edff7d2..cff7e0e9f 100644--- a/frontend/app/auth/callback/page.tsx+++ b/frontend/app/auth/callback/page.tsx@@ -83,31 +83,42 @@ function AuthCallbackContent() {// Send callback data to backendconst stateParam = searchParams.get("state");let parsedConnectionId = finalConnectorId;- let stateReturnUrl = null;+ let stateReturnUrl: string | null = null;- if (stateParam && stateParam.includes("id=")) {+ if (stateParam) {try {- const params = new URLSearchParams(stateParam);- parsedConnectionId = params.get("id") || finalConnectorId;- const b64Return = params.get("return");- if (b64Return) {+ // The entire state is now Base64 encoded: id=<connection_id>&return=<return_url>+ const decodedState = decodeBase64(stateParam);+ const params = new URLSearchParams(decodedState);++ if (params.has("id")) {+ parsedConnectionId = params.get("id") || finalConnectorId;+ stateReturnUrl = params.get("return");+ console.log("Parsed Base64 state parameter:", {+ parsedConnectionId,+ stateReturnUrl,+ });+ } else if (stateParam.includes("id=")) {+ // Fallback: If not base64 but contains id=, try to parse as raw for backward compatibility+ const rawParams = new URLSearchParams(stateParam);+ parsedConnectionId = rawParams.get("id") || finalConnectorId;+ stateReturnUrl = rawParams.get("return");+ }+ } catch (e) {+ console.error(+ "Failed to Base64 decode or parse state parameter",+ e,+ );+ // Fallback: If decoding fails, try to parse as raw if it contains id=+ if (stateParam.includes("id=")) {try {- stateReturnUrl = decodeBase64(b64Return);- } catch (e) {- console.error(- "Failed to Base64 decode return URL:",- b64Return,- e,- );- stateReturnUrl = b64Return; // Fallback to raw if decoding fails+ const params = new URLSearchParams(stateParam);+ parsedConnectionId = params.get("id") || finalConnectorId;+ stateReturnUrl = params.get("return");+ } catch (innerE) {+ console.error("Failed to parse raw state parameter", innerE);}}- console.log("Parsed state parameter:", {- parsedConnectionId,- stateReturnUrl,- });- } catch (e) {- console.error("Failed to parse state parameter", e);}}diff --git a/frontend/contexts/auth-context.tsx b/frontend/contexts/auth-context.tsxindex 2600fe354..9ee1391c9 100644--- a/frontend/contexts/auth-context.tsx+++ b/frontend/contexts/auth-context.tsx@@ -152,8 +152,8 @@ export function AuthProvider({ children }: AuthProviderProps) {});const returnUrl = result.public_return_url || window.location.origin;- const encodedReturnUrl = encodeBase64(returnUrl);- const state = `id=${result.connection_id}&return=${encodedReturnUrl}`;+ const stateQuery = `id=${result.connection_id}&return=${returnUrl}`;+ const state = encodeBase64(stateQuery);const authUrl =`${result.oauth_config.authorization_endpoint}?` +