Add Docker Registry AIO with Nuxt Token Auth and admin UI.
Compose brings up registry:3 plus a Prisma/SQLite Nuxt app for docker login, ACL management, and image browsing with shadcn-vue. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
0fd00bfa37
120 files changed
+17094
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const bodySchema = z.object({
|
||||
username: z.string().min(1),
|
||||
password: z.string().min(1),
|
||||
})
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await ensureBootstrap()
|
||||
const body = bodySchema.parse(await readBody(event))
|
||||
|
||||
const user = await prisma.user.findUnique({ where: { username: body.username } })
|
||||
if (!user || !user.active) {
|
||||
throw createError({ statusCode: 401, statusMessage: 'Invalid credentials' })
|
||||
}
|
||||
|
||||
const ok = await verifyPassword(body.password, user.passwordHash)
|
||||
if (!ok) {
|
||||
throw createError({ statusCode: 401, statusMessage: 'Invalid credentials' })
|
||||
}
|
||||
|
||||
const token = await createSessionToken({
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
role: user.role,
|
||||
})
|
||||
setSessionCookie(event, token)
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
role: user.role,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
clearSessionCookie(event)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = await readSessionUser(event)
|
||||
if (!user) {
|
||||
return { user: null }
|
||||
}
|
||||
return { user }
|
||||
})
|
||||
Reference in new issue
Block a user