Admin Dashboard enhancements, OAuth session fixes, and tracking script improvements #37
@@ -56,12 +56,15 @@ function AuthCallbackContent() {
|
|||||||
const storedState = localStorage.getItem('oauth_state')
|
const storedState = localStorage.getItem('oauth_state')
|
||||||
const codeVerifier = localStorage.getItem('oauth_code_verifier')
|
const codeVerifier = localStorage.getItem('oauth_code_verifier')
|
||||||
|
|
||||||
// * Full OAuth flow (app-initiated): validate state + use PKCE
|
// * Session flow (from auth hub): redirect has code but no state. Clear stale PKCE
|
||||||
// * Session-authorized flow (from auth hub): no stored state or verifier
|
// * data from any previous app-initiated OAuth so exchange proceeds without validation.
|
||||||
const isFullOAuth = !!storedState && !!codeVerifier
|
if (!state) {
|
||||||
|
localStorage.removeItem('oauth_state')
|
||||||
if (isFullOAuth) {
|
localStorage.removeItem('oauth_code_verifier')
|
||||||
if (state !== storedState) {
|
} else {
|
||||||
|
// * Full OAuth flow (app-initiated): validate state + use PKCE
|
||||||
|
const isFullOAuth = !!storedState && !!codeVerifier
|
||||||
|
if (isFullOAuth && state !== storedState) {
|
||||||
logger.error('State mismatch', { received: state, stored: storedState })
|
logger.error('State mismatch', { received: state, stored: storedState })
|
||||||
setError('Invalid state')
|
setError('Invalid state')
|
||||||
|
|
|||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user
Accepting OAuth callbacks without
stateparameter creates a CSRF vulnerability. An attacker could craft a malicious callback URL with their own authorization code and trick users into executing it, logging them into the attacker's account.The PR description mentions "trusted origins" but there's no code validating the origin. At minimum, check
document.referrerto ensure it starts with the auth domain whenstateis missing:Prompt To Fix With AI