From 19ff73cc3099d16cd53504eb7afcd319f86b721b Mon Sep 17 00:00:00 2001 From: DecDuck Date: Wed, 7 May 2025 22:14:04 +1000 Subject: [PATCH] feat: oidc --- components/Auth/OpenID.vue | 10 + components/Auth/Simple.vue | 124 ++++++++ package.json | 1 + pages/auth/register.vue | 10 +- pages/auth/signin.vue | 133 +-------- prisma/auth.prisma | 1 + .../migration.sql | 2 + prisma/migrations/migration_lock.toml | 2 +- server/api/v1/auth/index.get.ts | 9 + server/api/v1/auth/signin/simple.post.ts | 7 + server/internal/P2P.md | 15 - server/internal/oidc/index.ts | 281 ++++++++++++++++++ server/plugins/04.auth-init.ts | 37 +++ server/plugins/redirect.ts | 1 + server/routes/auth/callback/oidc.get.ts | 36 +++ server/routes/auth/oidc.get.ts | 10 + 16 files changed, 533 insertions(+), 146 deletions(-) create mode 100644 components/Auth/OpenID.vue create mode 100644 components/Auth/Simple.vue create mode 100644 prisma/migrations/20250507120031_add_openid_authmek/migration.sql create mode 100644 server/api/v1/auth/index.get.ts delete mode 100644 server/internal/P2P.md create mode 100644 server/internal/oidc/index.ts create mode 100644 server/plugins/04.auth-init.ts create mode 100644 server/routes/auth/callback/oidc.get.ts create mode 100644 server/routes/auth/oidc.get.ts diff --git a/components/Auth/OpenID.vue b/components/Auth/OpenID.vue new file mode 100644 index 0000000..926e110 --- /dev/null +++ b/components/Auth/OpenID.vue @@ -0,0 +1,10 @@ + diff --git a/components/Auth/Simple.vue b/components/Auth/Simple.vue new file mode 100644 index 0000000..c248f2f --- /dev/null +++ b/components/Auth/Simple.vue @@ -0,0 +1,124 @@ + + + diff --git a/package.json b/package.json index 43e321f..5489fb3 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "eslint": "^9.24.0", "eslint-config-prettier": "^10.1.1", "h3": "^1.15.1", + "ofetch": "^1.4.1", "postcss": "^8.4.47", "prettier": "^3.5.3", "sass": "^1.79.4", diff --git a/pages/auth/register.vue b/pages/auth/register.vue index 1abf5ed..3ee5bd4 100644 --- a/pages/auth/register.vue +++ b/pages/auth/register.vue @@ -56,7 +56,7 @@ type="email" autocomplete="email" required - :disabled="!!invitation.data.value?.email" + :disabled="!!invitation?.email" placeholder="me@example.com" class="block w-full rounded-md border-0 py-1.5 px-3 bg-zinc-800 disabled:bg-zinc-900/80 text-zinc-100 disabled:text-zinc-400 shadow-sm ring-1 ring-inset ring-zinc-700 disabled:ring-zinc-800 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6" /> @@ -87,7 +87,7 @@ type="text" autocomplete="username" required - :disabled="!!invitation.data.value?.username" + :disabled="!!invitation?.username" placeholder="myUsername" class="block w-full rounded-md border-0 py-1.5 px-3 bg-zinc-800 disabled:bg-zinc-900/80 text-zinc-100 disabled:text-zinc-400 shadow-sm ring-1 ring-inset ring-zinc-700 disabled:ring-zinc-800 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6" /> @@ -199,13 +199,13 @@ if (!invitationId) statusMessage: "Invitation required to sign up.", }); -const invitation = await useFetch( +const invitation = await $dropFetch( `/api/v1/auth/signup/simple?id=${encodeURIComponent(invitationId)}`, ); -const email = ref(invitation.data.value?.email); +const email = ref(invitation?.email); const displayName = ref(""); -const username = ref(invitation.data.value?.username); +const username = ref(invitation?.username); const password = ref(""); const confirmPassword = ref(undefined); diff --git a/pages/auth/signin.vue b/pages/auth/signin.vue index 9d9dd4f..d833a4c 100644 --- a/pages/auth/signin.vue +++ b/pages/auth/signin.vue @@ -18,92 +18,13 @@
-
-
- -
- -
-
- -
- -
- -
-
- -
-
- - -
- -
- Forgot password? -
-
- -
- - Sign in -
- -
-
-
-
-
-

- {{ error }} -

-
-
-
-
+ +
+ + OR + +
+
@@ -119,47 +40,9 @@