mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(oidc): normalize discovery doc issuer before comparison
Trailing slash in doc.issuer (e.g. Authentik) caused a mismatch against the already-normalized configured issuer, breaking OIDC login entirely. Closes #834
This commit is contained in:
@@ -143,7 +143,7 @@ export async function discover(issuer: string, discoveryUrl?: string | null): Pr
|
|||||||
// Validate that the discovery doc's issuer matches the operator-configured
|
// Validate that the discovery doc's issuer matches the operator-configured
|
||||||
// one. A MITM or compromised doc could otherwise supply a crafted issuer
|
// one. A MITM or compromised doc could otherwise supply a crafted issuer
|
||||||
// that passes jwt.verify() because we used doc.issuer as the expected value.
|
// that passes jwt.verify() because we used doc.issuer as the expected value.
|
||||||
if (doc.issuer && doc.issuer !== issuer) {
|
if (doc.issuer && doc.issuer.replace(/\/+$/, '') !== issuer) {
|
||||||
throw new Error(`OIDC discovery issuer mismatch: expected "${issuer}", got "${doc.issuer}"`);
|
throw new Error(`OIDC discovery issuer mismatch: expected "${issuer}", got "${doc.issuer}"`);
|
||||||
}
|
}
|
||||||
doc._issuer = url;
|
doc._issuer = url;
|
||||||
|
|||||||
Reference in New Issue
Block a user