budibase/packages/auth/src/middleware/passport/jwt.js

17 lines
350 B
JavaScript
Raw Normal View History

const { Cookies } = require("../../constants")
2021-04-07 12:33:16 +02:00
exports.options = {
secretOrKey: process.env.JWT_SECRET,
jwtFromRequest: function(ctx) {
return ctx.cookies.get(Cookies.Auth)
},
2021-04-07 12:33:16 +02:00
}
exports.authenticate = async function(jwt, done) {
try {
return done(null, jwt)
} catch (err) {
return done(new Error("JWT invalid."), false)
}
}