Skip to content

Commit

Permalink
Authz server check (#88)
Browse files Browse the repository at this point in the history
* remove beta server

* validate authz servers
  • Loading branch information
rohanharikr authored Dec 20, 2024
1 parent d66fe4f commit aeace40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
8 changes: 1 addition & 7 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { onMount } from 'svelte';
import { PARAMS, AUTHZ_SERVERS, BETA_SERVER } from '$lib/constants.js';
import { PARAMS, AUTHZ_SERVERS } from '$lib/constants.js';
import Header from '$components/Header.svelte';
import AuthorizationRequest from '$components/AuthorizationRequest.svelte';
import AuthorizationResponse from '$components/AuthorizationResponse.svelte';
Expand Down Expand Up @@ -90,7 +90,6 @@
if (params.has('id_token')) await processIdToken(params);
else if (params.has('code')) await processCode(params);
else if (params.has('error')) processError(params);
else if (params.has('beta')) selectBetaServer();
cleanUrl();
removeLoader();
Expand Down Expand Up @@ -263,11 +262,6 @@
authzResponse.url = params.toString();
showErrorNotification = true;
}
function selectBetaServer() {
selectedAuthzServer = BETA_SERVER;
dropdowns.server = true; // expand to show selected beta server
}
</script>
{#if mounted}
Expand Down
6 changes: 2 additions & 4 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ const PARAMS = {
HELLO_PARAM
};

const BETA_SERVER = 'https://wallet.hello-beta.net/authorize';

const SERVERS = ['https://wallet.hello.coop/authorize', BETA_SERVER];
const SERVERS = ['https://wallet.hello.coop/authorize'];

const AUTHZ_SERVERS = {
SERVERS,
Expand All @@ -174,4 +172,4 @@ const AUTHZ_SERVERS = {
]
};

export { PARAMS, AUTHZ_SERVERS, BETA_SERVER, PROFILE_CLAIMS };
export { PARAMS, AUTHZ_SERVERS, PROFILE_CLAIMS };
22 changes: 9 additions & 13 deletions src/lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@ function validateHelloParams({ param, protocolParams, helloParams, helloParamsVa
return true;
}

async function validateAuthzServer(_) {
// TBD CORS -- no way for browser to know for sure that a URL exists
// try {
// const res = await fetch(url, {
// method: 'HEAD', // Only fetch headers, no body
// cache: 'no-cache' // To avoid using cached responses
// });
// return res.status === 200
// } catch (error) {
// console.error('Failed to validate', url)
// return false;
// }
return true;
async function validateAuthzServer(url) {
const healthCheckUrl = new URL('/api/v1/health_check/playground', url);
try {
const res = await fetch(healthCheckUrl);
return res.status === 200;
} catch (error) {
console.warn('Failed to validate', healthCheckUrl);
return false;
}
}

export { validateScopes, validateProtocolParams, validateHelloParams, validateAuthzServer };

0 comments on commit aeace40

Please sign in to comment.