Skip to content

Commit

Permalink
handle iss
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanharikr committed Jun 17, 2024
1 parent a70a234 commit 2f3238a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@
}
async function processFragmentOrQuery() {
if (!window.location.hash && !window.location.search) return;
if (!window.location.hash && !window.location.search)
return;
let queryParams;
if (window.location.hash) {
queryParams = new URLSearchParams(window.location.hash.substring(1));
Expand All @@ -296,10 +298,25 @@
const id_token = queryParams.get("id_token");
const code = queryParams.get("code");
const initiate_login = queryParams.get("initiate-login");
const iss = queryParams.get("iss");
const error = queryParams.get("error")
if(error) {
errorNotification = error?.replaceAll("_", " ")
}
if(iss) {
try {
const res = await fetch(iss + "/.well-known/openid-configuration");
const { authorization_endpoint } = await res.json();
const requestUrl = new URL(authorization_endpoint)
if(queryParams.has('login_hint')) {
requestUrl.searchParams.set('login_hint', queryParams.get('login_hint'))
}
window.location.href = requestURL;
} catch(err) {
console.error(err)
errorNotification = 'Invalid Issuer URL'
}
}
if (initiate_login) {
await tick(); //wait for requestURL to compute
const url = new URL(initiate_login);
Expand Down

0 comments on commit 2f3238a

Please sign in to comment.