refactor: auth

This commit is contained in:
wancat committed 2024-02-19 18:05:01 +08:00
1 parent d6c95cea4a
commit 5489de2432
8 files changed
+120 -22

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt'
import type { VerifyCallback } from 'passport-jwt'
import config from '../config.js'
const jwtOptions = {
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: config.secret,
}
function verifyJwt(jwtPayload: any, done: VerifyCallback) {
return done(null, jwtPayload)
}
export default new JwtStrategy(jwtOptions, verifyJwt)