Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add keycloak config #51

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5df5f93
Install oidc-client-ts dependency
daniellrgn Nov 13, 2024
8a6101d
Add auth-related env vars and config
daniellrgn Nov 13, 2024
6ddabc7
Add basic auth wrapper class
daniellrgn Nov 13, 2024
b2488db
Add basic auth component
daniellrgn Nov 13, 2024
e10058f
Initial stab at auth flow with custom redirect url
daniellrgn Dec 3, 2024
727ad62
Add checks to scrollbar to handle auth preload state
daniellrgn Dec 3, 2024
a1d84de
Add auth component to app layout
daniellrgn Dec 3, 2024
0a75dad
Initial bump auth service instance up to layout to share between comp…
daniellrgn Dec 3, 2024
a9dd2b3
Merge branch 'main' into add-keycloak-config
daniellrgn Dec 20, 2024
0477e6d
Merge branch 'main' into add-keycloak-config
daniellrgn Dec 24, 2024
f13b31c
Move to singleton AuthService, handle token renewal errors
daniellrgn Jan 2, 2025
60309e7
Update home button plus
daniellrgn Jan 2, 2025
6a411a7
Handle small selector error in scroll event
daniellrgn Jan 2, 2025
d360f58
Move footer out of base layout to improve pre-login pop-in
daniellrgn Jan 2, 2025
66a8fa8
Remove WADOH plain text from navbar
daniellrgn Jan 2, 2025
bcbeeea
Fix navbar scroll handler error
daniellrgn Jan 2, 2025
33f019a
Add /auth page
daniellrgn Jan 2, 2025
efb9b48
Add account nav menu item; rearrange nav items appropriately
daniellrgn Jan 2, 2025
75f25f9
Add csp for XSS
daniellrgn Jan 6, 2025
af2a2d6
Put language menu on separate line above others to declutter navbar
daniellrgn Jan 6, 2025
9dacdc8
Update preload to correct logo image
daniellrgn Jan 7, 2025
d66d0c7
Fix up scrolling for two-layered nav
daniellrgn Jan 7, 2025
e6007f3
Install oidc-client-ts dependency
daniellrgn Nov 13, 2024
12b5307
Add auth-related env vars and config
daniellrgn Nov 13, 2024
8305fc9
Add basic auth wrapper class
daniellrgn Nov 13, 2024
288329a
Add basic auth component
daniellrgn Nov 13, 2024
8bfad2e
Initial stab at auth flow with custom redirect url
daniellrgn Dec 3, 2024
5694f50
Add checks to scrollbar to handle auth preload state
daniellrgn Dec 3, 2024
8e88401
Add auth component to app layout
daniellrgn Dec 3, 2024
c1a6df0
Initial bump auth service instance up to layout to share between comp…
daniellrgn Dec 3, 2024
8fb3793
Move to singleton AuthService, handle token renewal errors
daniellrgn Jan 2, 2025
120d958
Update home button plus
daniellrgn Jan 2, 2025
475fd96
Handle small selector error in scroll event
daniellrgn Jan 2, 2025
6c80ccc
Move footer out of base layout to improve pre-login pop-in
daniellrgn Jan 2, 2025
f2fbc4d
Remove WADOH plain text from navbar
daniellrgn Jan 2, 2025
076b83a
Fix navbar scroll handler error
daniellrgn Jan 2, 2025
dbf2262
Add /auth page
daniellrgn Jan 2, 2025
2fe88bf
Add account nav menu item; rearrange nav items appropriately
daniellrgn Jan 2, 2025
da2562b
Add csp for XSS
daniellrgn Jan 6, 2025
15aff2f
Put language menu on separate line above others to declutter navbar
daniellrgn Jan 6, 2025
e92bc4c
Update preload to correct logo image
daniellrgn Jan 7, 2025
83182d8
Fix up scrolling for two-layered nav
daniellrgn Jan 7, 2025
3d90071
WIP server hooks to check api auth
daniellrgn Jan 15, 2025
f27745e
Merge branch 'add-keycloak-config' of https://github.com/uwcirg/shl-i…
daniellrgn Jan 28, 2025
3c7972f
WIP Update server hook
daniellrgn Jan 30, 2025
68c65ef
WIP bad commit
daniellrgn Jan 30, 2025
87697fd
Revert bad commit
daniellrgn Jan 30, 2025
c17b750
Updates to support shl server user auth updates
daniellrgn Feb 3, 2025
3c43891
Update default patient name
daniellrgn Feb 3, 2025
997168d
Fix issues with user id, passcode flag, silent auth, bugs
daniellrgn Feb 3, 2025
001599e
Move Auth.svelte component functionality into main app layout [fixes …
daniellrgn Feb 3, 2025
836ac08
Parse encoded SHLink returned on create
daniellrgn Feb 3, 2025
6cfbbfe
Fix bugs with new create response decoding and update post-creation w…
daniellrgn Feb 3, 2025
9156d0d
Add logout page
daniellrgn Feb 4, 2025
c30f7b6
Merge branch 'main' into add-keycloak-config
daniellrgn Feb 4, 2025
4430c96
Ihe projectathon (#64)
daniellrgn Feb 19, 2025
4477486
Fix unauthenticated page flash after logging in
daniellrgn Feb 19, 2025
724c483
Refactor to support splash page and align layout site-wide
daniellrgn Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ VITE_VERSION_STRING=
### Variables with VITE_ prefix will be available to the client
###

# Auth environment variables for user oidc idp
#VITE_AUTH_URL=
#VITE_AUTH_CLIENT_ID=
#VITE_AUTH_REDIRECT_URI=
#VITE_AUTH_SILENT_REDIRECT_URI=
#VITE_AUTH_POST_LOGOUT_URI=

# SMART on FHIR client id configurations:
# Ensure that your development client is registered with the proper redirect uris
VITE_EPIC_CLIENT_ID=
Expand Down
66 changes: 54 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.0",
"@sveltejs/kit": "^1.5.0",
"base64url": "^3.0.1",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.55.1",
Expand All @@ -30,10 +31,11 @@
"@types/node": "^20.8.7",
"@types/pako": "^2.0.0",
"@types/qrcode": "^1.5.0",
"base64url": "^3.0.1",
"bootstrap": "^5.2.3",
"buffer": "^6.0.3",
"fhirclient": "^2.5.2",
"jose": "^4.11.4",
"oidc-client-ts": "^3.1.0",
"pako": "^2.1.0",
"qrcode": "^1.5.1",
"serve": "^14.2.0",
Expand Down
5 changes: 5 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_AUTH_URL: string
readonly VITE_AUTH_CLIENT_ID: string
readonly VITE_AUTH_REDIRECT_URI: string
readonly VITE_AUTH_SILENT_REDIRECT_URI: string
readonly VITE_AUTH_POST_LOGOUT_URI: string
readonly VITE_EPIC_HIMSS_CLIENT_ID: string
readonly VITE_ECW_HIMSS_CLIENT_ID: string
readonly VITE_EPIC_CLIENT_ID: string
Expand Down
30 changes: 30 additions & 0 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { redirect, type Handle } from '@sveltejs/kit';

const public_paths = [
'/home',
'/ips'
];

function isPathAllowed(pathname: string) {
return public_paths.some((path) =>
path === pathname || pathname.startsWith(path)
);
}

export const handle: Handle = async ({ event, resolve }) => {

// Validate keycloak token
let authorized = false;
try {
authorized = true;
} catch (e) {
console.error(e);
}

if (!authorized && !isPathAllowed(event.url.pathname)) {
throw redirect(302, '/home');
}

const response = await resolve(event);
return response;
};
2 changes: 1 addition & 1 deletion src/lib/components/app/AddFile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

let shcsToAdd: SHCFile[] = [];
let singleIPS = true;
let patientName = "My";
let patientName = "";
let patient: Patient | undefined;

let label = 'Health Summary ' + new Date().toISOString().slice(0, 10);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/app/FetchUrl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
color: rgb(50, 50, 50);"/>
</div>
</DropdownToggle>
<DropdownMenu style="width:100%">
<DropdownMenu style="max-height: 400px; width:100%; overflow:scroll">
{#if Object.keys(PATIENT_IPS).length > 0}
<DropdownItem header>Actual Patient Data (permitted for use)</DropdownItem>
{#each Object.entries(PATIENT_IPS) as [title, url]}
Expand Down
42 changes: 19 additions & 23 deletions src/lib/components/app/HealthLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@
async function getUrl(shl: SHLAdminParams) {
let shlMin = {
id: shl.id,
url: shl.url,
managementToken: shl.managementToken,
encryptionKey: shl.encryptionKey,
passcode: shl.passcode,
key: shl.key,
passcode: shl.passcode ?? "",
exp: shl.exp ?? 0,
files: []
}
return await shlClient.toLink(shlMin);
Expand All @@ -133,10 +135,12 @@
}

async function deleteShl() {
shlClient.deleteShl(shl);
$shlStore = $shlStore.filter((l) => l.id !== shl.id);
toggle();
goto('/');
let success = await shlClient.deleteShl(shl);
if (success) {
$shlStore = await shlClient.getUserShls();
toggle();
goto('/');
}
}

async function addFile() {
Expand All @@ -145,11 +149,11 @@

async function deleteFile(fileContent:string) {
shl = await shlClient.deleteFile(shl, fileContent).then((shl) => {
let updatedFiles = shl.files.filter((f) => f.contentEncrypted !== fileContent);
let updatedFiles = shl.files.filter((f) => f.contentHash !== fileContent);
shl.files = updatedFiles;
return shl;
});
$shlStore[$shlStore.findIndex(obj => obj.id === shl.id)] = shl;
$shlStore = await shlClient.getUserShls();
}
</script>
{#if linkNotFound}
Expand Down Expand Up @@ -274,14 +278,8 @@
color="primary"
disabled={(shl.label || '') === (shlControlled.label || '')}
on:click={async () => {
$shlStore = $shlStore.map((e) => {
if (e.id === shl.id) {
shl = { ...shl, label: shlControlled.label };
return shl;
} else {
return e;
}
});
await shlClient.resetShl({ ...shl, label: shlControlled.label });
$shlStore = await shlClient.getUserShls();
}}>
<Icon name="sticky" /> Update Label
</Button>
Expand Down Expand Up @@ -310,9 +308,7 @@
disabled={(shl.passcode || '') === (shlControlled.passcode || '')}
on:click={async () => {
await shlClient.resetShl({ ...shl, passcode: shlControlled.passcode });
$shlStore = $shlStore.map((e) =>
e.id === shl.id ? { ...shl, passcode: shlControlled.passcode } : e
);
$shlStore = await shlClient.getUserShls();
}}><Icon name="lock" /> Update Passcode</Button>
<Button size="sm" on:click={toggle} color="danger"><Icon name="trash3" /> Delete SMART Health Link</Button>
<Modal isOpen={open} backdrop="static" {toggle}>
Expand All @@ -335,19 +331,19 @@
{#if shl.files.length == 0}
<p><em>No Summaries found</em></p>
{/if}
{#each shl.files as file (file.contentEncrypted)}
{#each shl.files as file (file.contentHash)}
<Card class="mb-2" color="light">
<CardHeader>
<Row class="align-items-center">
<Col xs=6 class="align-items-center">
{#if file.date}
<strong><Icon name="calendar"></Icon> {file.date}</strong>
{#if file.added}
<strong><Icon name="calendar"></Icon> {file.added.split(' ')[0]}</strong>
{/if}
</Col>
<Col xs=6>
<Row class="justify-content-end">
<Button size="sm" color="danger" class="my-0 mx-1" style="width: fit-content" on:click={(e) => {
deleteFile(file.contentEncrypted);
deleteFile(file.contentHash);
}}>
<Icon name="trash3" />
</Button>
Expand Down
Loading