From 923a1d56995f6b90531f6819396ba7e17be63601 Mon Sep 17 00:00:00 2001 From: rohanharikr Date: Tue, 17 Sep 2024 15:06:41 +0100 Subject: [PATCH 1/4] dedupe custom authz server, cleanup --- src/App.svelte | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 21d051f..97ac625 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -157,14 +157,6 @@ greenfield: 'app_GreenfieldFitnessDemoApp_s9z' }; - const opendidConfigEndpoint = '.well-known/openid-configuration'; - const helloIssuers = [ - 'https://issuer.hello.coop', - 'https://issuer.hello-staging.net', - 'https://issuer.hello-beta.net', - 'https://issuer.hello-dev.net', - 'https://issuer.hello-local.net' - ]; const betaAuthzServer = 'https://wallet.hello-beta.net/authorize'; // const updateScopes = ['name', 'email', 'picture', 'phone', 'profile']; @@ -351,33 +343,21 @@ const error = protocolParams.get('error'); if (error) { errorNotification = error?.replaceAll('_', ' '); + //tbd show error description? } - if (iss) { - let authorization_endpoint; - if (helloIssuers.includes(iss)) { - const wallet = iss.replace('issuer', 'wallet'); - authorization_endpoint = new URL('/authorize', wallet).href; - } else { - const openidConfig = new URL(opendidConfigEndpoint, iss); - try { - const res = await fetch(openidConfig.href); - const json = await res.json(); - authorization_endpoint = json.authorization_endpoint; - } catch (err) { - console.error(err); - errorNotification = 'Error fetching ' + openidConfig.href; - } - } + if (iss && iss.startsWith('https://issuer.hello')) { + const wallet = iss.replace('issuer', 'wallet'); + const authorization_endpoint = new URL('/authorize', wallet).href; //reset all params and settings resetAll(); //add issuer authz endpoint to existing authz servers states.custom_authorization_servers = [ - ...states.custom_authorization_servers, - authorization_endpoint + ...new Set([...states.custom_authorization_servers, authorization_endpoint]) //dedupe ]; states.selected_authorization_server = authorization_endpoint; + let _requestUrl = makeRequestURL({ server: authorization_endpoint, scopes: states.scopes, From e7d37081cd838b0d0237e0fb989558add40dc83d Mon Sep 17 00:00:00 2001 From: rohanharikr Date: Tue, 17 Sep 2024 15:07:03 +0100 Subject: [PATCH 2/4] comment --- src/App.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.svelte b/src/App.svelte index 97ac625..a96e755 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -605,7 +605,7 @@ url = new URL(custom_authorization_server); } states.custom_authorization_servers = [ - ...new Set([...states.custom_authorization_servers, url.href]) + ...new Set([...states.custom_authorization_servers, url.href]) //dedupe ]; states.selected_authorization_server = url.href; custom_authorization_server = ''; From 61a0a514df4e6a52b6d812cadee71f8060dbab2a Mon Sep 17 00:00:00 2001 From: rohanharikr Date: Tue, 17 Sep 2024 15:13:45 +0100 Subject: [PATCH 3/4] placeholder for login_hint and error text if login_hint does not start with mailto: --- src/App.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App.svelte b/src/App.svelte index a96e755..8b7bb1c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1106,7 +1106,11 @@ states.protocol_params.includes('response_mode') && states.protocol_param_values.response_mode === 'query' && states.protocol_params.includes('response_type') && - states.protocol_param_values.response_type === 'id_token')} + states.protocol_param_values.response_type === 'id_token') || + //login_hint should start with mailto: + (param === 'login_hint' && + states.protocol_params.includes('login_hint') && + !states.protocol_param_values.login_hint.startsWith('mailto:'))} > {param} {required ? '*' : ''} @@ -1173,6 +1177,7 @@ > Date: Tue, 17 Sep 2024 15:15:19 +0100 Subject: [PATCH 4/4] normalize custom authz server before saving --- src/App.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 8b7bb1c..fb3c3c6 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -354,7 +354,7 @@ //add issuer authz endpoint to existing authz servers states.custom_authorization_servers = [ - ...new Set([...states.custom_authorization_servers, authorization_endpoint]) //dedupe + ...new Set([...states.custom_authorization_servers, authorization_endpoint.toLowerCase()]) //dedupe ]; states.selected_authorization_server = authorization_endpoint; @@ -605,7 +605,7 @@ url = new URL(custom_authorization_server); } states.custom_authorization_servers = [ - ...new Set([...states.custom_authorization_servers, url.href]) //dedupe + ...new Set([...states.custom_authorization_servers, url.href.toLowerCase()]) //dedupe ]; states.selected_authorization_server = url.href; custom_authorization_server = '';