From fe2d7cb57af76e36d59fc30bdbbd5adf1a2b5ac1 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Thu, 3 Apr 2025 23:44:19 -0400 Subject: [PATCH] chore: v0.5.10 --- CHANGELOG.md | 3 ++ app/layouts/shell.tsx | 88 ++++++++++++++++++++++------------------- docs/Integrated-Mode.md | 4 +- docs/Simple-Mode.md | 2 +- package.json | 2 +- 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a13fb8..b6ac135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 0.5.10 (April 4, 2025) +- Fix an issue where other prefernences to skip onboarding affected every user. + ### 0.5.9 (April 3, 2025) - Filter out empty users from the pre-auth keys page which could possibly cause a crash with unmigrated users. - OIDC users cannot be renamed, so that functionality has been disabled in the menu options. diff --git a/app/layouts/shell.tsx b/app/layouts/shell.tsx index 584f8d4..ddb1e7e 100644 --- a/app/layouts/shell.tsx +++ b/app/layouts/shell.tsx @@ -36,48 +36,56 @@ export async function loader({ if (context.oidc && !request.url.endsWith('/onboarding')) { let onboarded = false; - try { - const { users } = await context.client.get<{ users: User[] }>( - 'v1/user', - session.get('api_key')!, - ); - - if (users.length === 0) { - onboarded = false; - } - - const user = users.find((u) => { - if (u.provider !== 'oidc') { - return false; - } - - // For some reason, headscale makes providerID a url where the - // last component is the subject, so we need to strip that out - const subject = u.providerId?.split('/').pop(); - if (!subject) { - return false; - } - - const sessionUser = session.get('user'); - if (!sessionUser) { - return false; - } - - if (context.sessions.onboardForSubject(sessionUser.subject)) { - // Assume onboarded - return true; - } - - return subject === sessionUser.subject; - }); - - if (user) { + const sessionUser = session.get('user'); + if (sessionUser) { + if (context.sessions.onboardForSubject(sessionUser.subject)) { + // Assume onboarded onboarded = true; + } else { + try { + const { users } = await context.client.get<{ users: User[] }>( + 'v1/user', + session.get('api_key')!, + ); + + if (users.length === 0) { + onboarded = false; + } + + const user = users.find((u) => { + if (u.provider !== 'oidc') { + return false; + } + + // For some reason, headscale makes providerID a url where the + // last component is the subject, so we need to strip that out + const subject = u.providerId?.split('/').pop(); + if (!subject) { + return false; + } + + const sessionUser = session.get('user'); + if (!sessionUser) { + return false; + } + + if (context.sessions.onboardForSubject(sessionUser.subject)) { + // Assume onboarded + return true; + } + + return subject === sessionUser.subject; + }); + + if (user) { + onboarded = true; + } + } catch (e) { + // If we cannot lookup users, just assume our user is onboarded + log.debug('api', 'Failed to lookup users %o', e); + onboarded = true; + } } - } catch (e) { - // If we cannot lookup users, just assume our user is onboarded - log.debug('api', 'Failed to lookup users %o', e); - onboarded = true; } if (!onboarded) { diff --git a/docs/Integrated-Mode.md b/docs/Integrated-Mode.md index 7f5e6ad..99c90d0 100644 --- a/docs/Integrated-Mode.md +++ b/docs/Integrated-Mode.md @@ -34,7 +34,7 @@ Here is what a sample Docker Compose deployment would look like: services: headplane: # I recommend you pin the version to a specific release - image: ghcr.io/tale/headplane:0.5.9 + image: ghcr.io/tale/headplane0.5.10: container_name: headplane restart: unless-stopped ports: @@ -151,7 +151,7 @@ spec: serviceAccountName: default containers: - name: headplane - image: ghcr.io/tale/headplane:0.5.9 + image: ghcr.io/tale/headplane0.5.10: env: # Set these if the pod name for Headscale is not static # We will use the downward API to get the pod name instead diff --git a/docs/Simple-Mode.md b/docs/Simple-Mode.md index 4583eac..874b6de 100644 --- a/docs/Simple-Mode.md +++ b/docs/Simple-Mode.md @@ -19,7 +19,7 @@ Here is what a sample Docker Compose deployment would look like: services: headplane: # I recommend you pin the version to a specific release - image: ghcr.io/tale/headplane:0.5.9 + image: ghcr.io/tale/headplane0.5.10: container_name: headplane restart: unless-stopped ports: diff --git a/package.json b/package.json index 2314163..6897fdd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "headplane", "private": true, "sideEffects": false, - "version": "0.5.9", + "version": "0.5.10", "type": "module", "scripts": { "build": "react-router build",