fix(oidc): allow paths in wellknown lookup

pull/2792/head
Jakob Ankarhem 2 years ago
parent cefe1fe1ba
commit 6e899480d5
No known key found for this signature in database
GPG Key ID: 149CBB661002B3BE

@ -4,15 +4,13 @@ import * as yup from 'yup';
/** Fetch the oidc configuration blob */ /** Fetch the oidc configuration blob */
export async function getOIDCWellknownConfiguration(domain: string) { export async function getOIDCWellknownConfiguration(domain: string) {
const wellKnownInfo: WellKnownConfiguration = await fetch( // remove trailing slash from url if it exists and add /.well-known/openid-configuration path
new URL( const wellKnownUrl = new URL(
'/.well-known/openid-configuration', `https://${domain}`.replace(/\/$/, '') + '/.well-known/openid-configuration'
`https://${domain}` ).toString();
).toString(), const wellKnownInfo: WellKnownConfiguration = await fetch(wellKnownUrl, {
{ headers: new Headers([['Content-Type', 'application/json']]),
headers: new Headers([['Content-Type', 'application/json']]), }).then((r) => r.json());
}
).then((r) => r.json());
return wellKnownInfo; return wellKnownInfo;
} }

@ -26,8 +26,9 @@ function OIDCLoginButton({ revalidate, oidcName }: Props) {
} catch (e) { } catch (e) {
setLoading(false); setLoading(false);
return; return;
} finally {
setLoading(false);
} }
setLoading(false);
}; };
return ( return (

Loading…
Cancel
Save