first commit
CI / Type-check & Build (push) Failing after 5m50s
CI / Build & Push image (push) Skipped

This commit is contained in:
ysj7705 committed 2026-08-12 15:01:43 +09:00
commit 69b647145f
58 files changed
+15796

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { SignJWT, jwtVerify } from 'jose'
function getSecret() {
const config = useRuntimeConfig()
return new TextEncoder().encode(config.jwtSecret)
}
export async function signAdminToken(username: string) {
return new SignJWT({ role: 'admin', username })
.setProtectedHeader({ alg: 'HS256' })
.setIssuedAt()
.setExpirationTime('7d')
.sign(getSecret())
}
export async function verifyAdminToken(token: string) {
const { payload } = await jwtVerify(token, getSecret())
if (payload.role !== 'admin') {
throw createError({ statusCode: 401, statusMessage: 'Invalid admin token' })
}
return payload as { role: string; username: string }
}
export const ADMIN_COOKIE = 'sejong_admin_token'