From b72e1ef7a45ea16bee1da6271daae70966fcc522 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Fri, 1 Aug 2025 13:11:56 +1000 Subject: [PATCH] Code-based authorization for Drop clients (#145) * feat: code-based authorization * fix: final touches * fix: require session on code fetch endpoint * feat: better error handling * refactor: move auth send to client handler * fix: lint --- assets/tailwindcss.css | 9 ++ components/UserHeader/UserWidget.vue | 5 + i18n/locales/en_us.json | 4 + .../{[id]/callback.vue => authorize/[id].vue} | 79 ++++++---- pages/client/code/index.vue | 135 ++++++++++++++++++ .../api/v1/client/auth/callback/index.post.ts | 10 +- server/api/v1/client/auth/code/index.get.ts | 21 +++ server/api/v1/client/auth/code/index.post.ts | 35 +++++ server/api/v1/client/auth/code/ws.get.ts | 25 ++++ .../client/auth/{callback => }/index.get.ts | 12 +- server/api/v1/client/auth/initiate.post.ts | 35 +++-- server/internal/clients/handler.ts | 77 +++++++++- server/internal/tasks/index.ts | 1 + 13 files changed, 396 insertions(+), 52 deletions(-) rename pages/client/{[id]/callback.vue => authorize/[id].vue} (78%) create mode 100644 pages/client/code/index.vue create mode 100644 server/api/v1/client/auth/code/index.get.ts create mode 100644 server/api/v1/client/auth/code/index.post.ts create mode 100644 server/api/v1/client/auth/code/ws.get.ts rename server/api/v1/client/auth/{callback => }/index.get.ts (71%) diff --git a/assets/tailwindcss.css b/assets/tailwindcss.css index 5c2596b..97cf5d4 100644 --- a/assets/tailwindcss.css +++ b/assets/tailwindcss.css @@ -2,3 +2,12 @@ @plugin "@tailwindcss/typography"; @plugin "@tailwindcss/forms"; @config "../tailwind.config.js"; + +@layer base { + input[type="number"]::-webkit-outer-spin-button, + input[type="number"]::-webkit-inner-spin-button, + input[type="number"] { + -webkit-appearance: none; + -moz-appearance: textfield !important; + } +} diff --git a/components/UserHeader/UserWidget.vue b/components/UserHeader/UserWidget.vue index 35e238d..cf75bba 100644 --- a/components/UserHeader/UserWidget.vue +++ b/components/UserHeader/UserWidget.vue @@ -100,6 +100,11 @@ const navigation = computed(() => route: "/account", prefix: "", }, + { + label: "Authorize client", + route: "/client/code", + prefix: "", + }, ].filter((e) => e !== undefined), ); diff --git a/i18n/locales/en_us.json b/i18n/locales/en_us.json index 58e16c9..84097d8 100644 --- a/i18n/locales/en_us.json +++ b/i18n/locales/en_us.json @@ -38,6 +38,10 @@ "requestedAccess": "\"{name}\" has requested access to your Drop account.", "success": "Successful!" }, + "code": { + "title": "Connect your Drop client", + "description": "Use a code to connect your Drop client if you are unable to open a web browser on your device." + }, "confirmPassword": "Confirm @:auth.password", "displayName": "Display Name", "email": "Email", diff --git a/pages/client/[id]/callback.vue b/pages/client/authorize/[id].vue similarity index 78% rename from pages/client/[id]/callback.vue rename to pages/client/authorize/[id].vue index 71277b8..a3d2a9d 100644 --- a/pages/client/[id]/callback.vue +++ b/pages/client/authorize/[id].vue @@ -1,7 +1,7 @@