From 9620ffbc7e6ff2d7919354f98f2c9e27d6e73de7 Mon Sep 17 00:00:00 2001 From: tgt Date: Wed, 30 Oct 2024 10:41:29 -0400 Subject: [PATCH] style: a tiny change makes a huge difference (+1rem to border radius) deps(update/auth): update authjs so that it works with nextjs 15 fix(ui/navbar): fix the hydration error refactor: make container auth thing less sped, and middleware more granular --- package.json | 2 +- pnpm-lock.yaml | 46 ++++++++++++++--------------- src/app/api/container-auth/route.ts | 5 +++- src/app/globals.css | 2 +- src/components/navbar.tsx | 17 +++++------ src/middleware.ts | 4 +-- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index e415f99..f9eb02f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "input-otp": "^1.2.4", "lucide-react": "^0.358.0", "next": "15.0.2-canary.9", - "next-auth": "5.0.0-beta.18", + "next-auth": "5.0.0-beta.24", "next-themes": "^0.3.0", "node-loader": "^2.0.0", "otplib": "^12.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea5bc64..ee8b769 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,8 +106,8 @@ importers: specifier: 15.0.2-canary.9 version: 15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021) next-auth: - specifier: 5.0.0-beta.18 - version: 5.0.0-beta.18(next@15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021) + specifier: 5.0.0-beta.24 + version: 5.0.0-beta.24(next@15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021) next-themes: specifier: ^0.3.0 version: 0.3.0(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021) @@ -203,8 +203,8 @@ packages: resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} - '@auth/core@0.31.0': - resolution: {integrity: sha512-UKk3psvA1cRbk4/c9CkpWB8mdWrkKvzw0DmEYRsWolUQytQ2cRqx+hYuV6ZCsngw/xbj9hpmkZmAZEyq2g4fMg==} + '@auth/core@0.37.2': + resolution: {integrity: sha512-kUvzyvkcd6h1vpeMAojK2y7+PAV5H+0Cc9+ZlKYDFhDY31AlvsB+GW5vNO4qE3Y07KeQgvNO9U0QUx/fN62kBw==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 @@ -1753,8 +1753,8 @@ packages: resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} engines: {node: ^14.18.0 || >=16.10.0} - cookie@0.6.0: - resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} + cookie@0.7.1: + resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} engines: {node: '>= 0.6'} cpu-features@0.0.10: @@ -2124,8 +2124,8 @@ packages: resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} hasBin: true - jose@5.8.0: - resolution: {integrity: sha512-E7CqYpL/t7MMnfGnK/eg416OsFCVUrU/Y3Vwe7QjKhu/BkS1Ms455+2xsqZQVN57/U2MHMBvEb5SrmAZWAIntA==} + jose@5.9.6: + resolution: {integrity: sha512-AMlnetc9+CV9asI19zHmrgS/WYsWUwCn2R7RzlbJWD7F9eWYUTGyBmU9o6PxngtLGOiDGPRu+Uc4fhKzbpteZQ==} js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -2223,14 +2223,14 @@ packages: neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - next-auth@5.0.0-beta.18: - resolution: {integrity: sha512-x55L8wZb8PcPGCYA3e/l9tdpd7YL3FDuhas4W8pxq3PjrWJ9OoDxNN0otK9axJamJBbBgjfzTJjVQB6hXoe0ZQ==} + next-auth@5.0.0-beta.24: + resolution: {integrity: sha512-LcZNox0EAvXmk0/olhGRX+e4FGBVglHtc4RHp+vEWmAgm97/7niH15Jed5PVgcmjFPrJaN8DlwTsNjz776HF6A==} peerDependencies: '@simplewebauthn/browser': ^9.0.1 '@simplewebauthn/server': ^9.0.2 - next: ^14 + next: ^14.0.0-0 || ^15.0.0-0 nodemailer: ^6.6.5 - react: ^18.2.0 + react: ^18.2.0 || ^19.0.0-0 peerDependenciesMeta: '@simplewebauthn/browser': optional: true @@ -2291,8 +2291,8 @@ packages: resolution: {integrity: sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==} engines: {node: '>=0.10.0'} - oauth4webapi@2.12.0: - resolution: {integrity: sha512-WFmcHzhFtq2Ar91crpGQZUD8DS0SG7Zti1AgbansUAfdpIsoRXE+hcMNi8MW6bGNNObWis0x8BZRl6K+FR4oQg==} + oauth4webapi@3.1.2: + resolution: {integrity: sha512-KQZkNU+xn02lWrFu5Vjqg9E81yPtDSxUZorRHlLWVoojD+H/0GFbH59kcnz5Thdjj7c4/mYMBPj/mhvGe/kKXA==} object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} @@ -2869,13 +2869,13 @@ snapshots: '@alloc/quick-lru@5.2.0': {} - '@auth/core@0.31.0': + '@auth/core@0.37.2': dependencies: '@panva/hkdf': 1.2.1 '@types/cookie': 0.6.0 - cookie: 0.6.0 - jose: 5.8.0 - oauth4webapi: 2.12.0 + cookie: 0.7.1 + jose: 5.9.6 + oauth4webapi: 3.1.2 preact: 10.11.3 preact-render-to-string: 5.2.3(preact@10.11.3) @@ -4186,7 +4186,7 @@ snapshots: consola@3.2.3: {} - cookie@0.6.0: {} + cookie@0.7.1: {} cpu-features@0.0.10: dependencies: @@ -4511,7 +4511,7 @@ snapshots: jiti@1.21.6: {} - jose@5.8.0: {} + jose@5.9.6: {} js-tokens@4.0.0: {} @@ -4585,9 +4585,9 @@ snapshots: neo-async@2.6.2: {} - next-auth@5.0.0-beta.18(next@15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021): + next-auth@5.0.0-beta.24(next@15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021): dependencies: - '@auth/core': 0.31.0 + '@auth/core': 0.37.2 next: 15.0.2-canary.9(babel-plugin-react-compiler@19.0.0-beta-6fc168f-20241025)(react-dom@19.0.0-rc-69d4b800-20241021(react@19.0.0-rc-69d4b800-20241021))(react@19.0.0-rc-69d4b800-20241021) react: 19.0.0-rc-69d4b800-20241021 @@ -4637,7 +4637,7 @@ snapshots: normalize-range@0.1.2: {} - oauth4webapi@2.12.0: {} + oauth4webapi@3.1.2: {} object-assign@4.1.1: {} diff --git a/src/app/api/container-auth/route.ts b/src/app/api/container-auth/route.ts index 9339418..582960a 100644 --- a/src/app/api/container-auth/route.ts +++ b/src/app/api/container-auth/route.ts @@ -11,7 +11,10 @@ export async function GET(req: NextRequest) { if (req.nextUrl.hostname !== "localhost") { return new Response("Unauthorized - IP does not match", { status: 401 }); } - const [{ Id }] = (await docker.listContainers()).filter((container) => container.Id.startsWith(containerId)); + const { Id } = (await docker.listContainers()).find((container) => container.Id.startsWith(containerId)) || {}; + if (!Id) { + return new Response("Unauthorized - ehh this aint supposed to happen: container not found", { status: 401 }); + } const [dbEntry] = await db .select() .from(session) diff --git a/src/app/globals.css b/src/app/globals.css index e39c30b..3be6f18 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -24,7 +24,7 @@ --destructive-foreground: 220 21.951% 91.961%; --ring: 233.793 16.022% 35.49%; - --radius: 0.5rem; + --radius: 1.5rem; } .dark { diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index cd0b374..4d2b4f0 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -2,14 +2,7 @@ import packageJson from "@/../package.json"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; +import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { DropdownMenu, DropdownMenuContent, @@ -75,6 +68,10 @@ export default function Navigation({ name: "Next.js", url: "https://nextjs.org/", }, + { + name: "Docker", + url: "https://www.docker.com/", + }, { name: "noVNC", url: "https://github.com/noVNC/noVNC", @@ -120,7 +117,7 @@ export default function Navigation({ Stardust {packageJson.version} - +
Stardust is the platform for streaming isolated desktop containers.
Stardust uses the following things in an important way: @@ -200,7 +197,7 @@ export default function Navigation({ Spaceness - +
diff --git a/src/middleware.ts b/src/middleware.ts index d5b9e18..edc4a57 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -2,7 +2,7 @@ import { config as authConfig } from "@/lib/auth.config"; import NextAuth from "next-auth"; import { NextResponse } from "next/server"; const { auth } = NextAuth(authConfig); -const allowedPaths = ["/auth/login", "/auth/error", "/auth/verify", "/auth/signup"]; +const allowedPaths = ["/auth/login", "/auth/error", "/auth/verify", "/auth/signup", "/api/container-auth"]; export const middleware = auth(async (req) => { if (req.auth || allowedPaths.includes(req.nextUrl.pathname)) { return NextResponse.next(); @@ -12,5 +12,5 @@ export const middleware = auth(async (req) => { return NextResponse.redirect(url); }); export const config = { - matcher: ["/((?!_next/static|_next/image|icon.svg|websockify|api/container-auth|api/auth|manifest.webmanifest).*)"], + matcher: ["/((?!_next/static|_next/image|icon.svg|websockify|api/auth|manifest.webmanifest).*)"], };