Skip to content

Commit

Permalink
fix: custom authz server
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanharikr committed Jan 16, 2025
1 parent dc27ef0 commit a8e780c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
});
// derived - (re-computed when states change)
const authzServer = $derived(
selectedAuthzServer === 'custom-authz-server' ? customAuthzServer : selectedAuthzServer
);
const claims = $derived(
// id_token flow // code flow
authzResponse.introspect || authzResponse.parsed
);
const canInvite = $derived(Boolean(claims?.sub && claims?.name && claims?.email));
const authzUrl = $derived(
makeAuthzUrl({
authzServer: selectedAuthzServer,
customAuthzServer,
authzServer,
scopes: selectedScopes,
customScope,
protocolParams: selectedProtocolParams,
Expand All @@ -66,7 +68,7 @@
);
const inviteUrl = $derived(
makeInviteUrl({
authzServer: selectedAuthzServer,
authzServer,
claims,
protocolParamsValues: selectedProtocolParamsValues
})
Expand Down Expand Up @@ -194,7 +196,7 @@
const code = params.get('code');
if (!code) throw new Error('Missing code');
const tokenRes = await fetch(new URL('/oauth/token', selectedAuthzServer), {
const tokenRes = await fetch(new URL('/oauth/token', authzServer), {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
Expand All @@ -221,7 +223,7 @@
if (!profile) throw new Error('Did not get profile from token');
authzResponse.parsed = profile;
const userinfoRes = await fetch(new URL('/oauth/userinfo', selectedAuthzServer), {
const userinfoRes = await fetch(new URL('/oauth/userinfo', authzServer), {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
Expand Down
4 changes: 1 addition & 3 deletions src/lib/request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
function makeAuthzUrl({
authzServer,
customAuthzServer = null,
scopes,
customScope = null,
protocolParams,
Expand All @@ -9,8 +8,7 @@ function makeAuthzUrl({
helloParamsValues
}) {
try {
const server = authzServer === 'custom-authz-server' ? customAuthzServer : authzServer;
const url = new URL(server);
const url = new URL(authzServer);

// scope is not overridden in protocol params section
if (scopes.length && !protocolParams.includes('scope')) {
Expand Down

0 comments on commit a8e780c

Please sign in to comment.