File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -2112,10 +2112,13 @@ export default class GoTrueClient {
21122112 return this . detectSessionInUrl ( new URL ( window . location . href ) , params )
21132113 }
21142114 // Check for Supabase Auth identifier
2115- // Fall back to legacy detection for backwards compatibility with older Auth servers
21162115 if ( 'sb' in params ) {
2117- return true
2116+ // sb is just an identifier
2117+ // Still require OAuth params to prevent forced logout via crafted URLs with only 'sb'
2118+ return Boolean ( params . access_token || params . error || params . error_description )
21182119 }
2120+ // TODO @mandarini : Remove this legacy fallback in next major version and return false instead
2121+ // Legacy detection for backwards compatibility with older Auth servers that don't include 'sb'
21192122 return Boolean ( params . access_token || params . error_description )
21202123 }
21212124
Original file line number Diff line number Diff line change @@ -93,10 +93,13 @@ export type GoTrueClientOptions = {
9393 * @example
9494 * ```ts
9595 * detectSessionInUrl: (url, params) => {
96- * // Prefer sb identifier (available on newer Auth servers)
97- * if ('sb' in params) return true
9896 * // Ignore known third-party OAuth paths
9997 * if (url.pathname === '/facebook/redirect') return false
98+ * // Check for sb identifier (available on newer Auth servers)
99+ * // Still require OAuth params to prevent issues with crafted URLs
100+ * if ('sb' in params) {
101+ * return Boolean(params.access_token || params.error || params.error_description)
102+ * }
100103 * // Fall back to legacy detection for older Auth servers
101104 * return Boolean(params.access_token || params.error_description)
102105 * }
Original file line number Diff line number Diff line change @@ -63,10 +63,13 @@ export type SupabaseClientOptions<SchemaName> = {
6363 * @example
6464 * ```ts
6565 * detectSessionInUrl: (url, params) => {
66- * // Prefer sb identifier (available on newer Auth servers)
67- * if ('sb' in params) return true
6866 * // Ignore known third-party OAuth paths
6967 * if (url.pathname === '/facebook/redirect') return false
68+ * // Check for sb identifier (available on newer Auth servers)
69+ * // Still require OAuth params to prevent issues with crafted URLs
70+ * if ('sb' in params) {
71+ * return Boolean(params.access_token || params.error || params.error_description)
72+ * }
7073 * // Fall back to legacy detection for older Auth servers
7174 * return Boolean(params.access_token || params.error_description)
7275 * }
You can’t perform that action at this time.
0 commit comments