UNPKG

authkit-js

Version:

Express auth toolkit (JWT, Sessions with Redis, Google/GitHub OAuth) in JavaScript

12 lines (8 loc) 257 B
function attachAuth(kit, strategyName) { return async function (req, _res, next) { try { req.auth = await kit.authenticate(req, strategyName) || undefined; } catch { /* ignore */ } next(); }; } module.exports = { attachAuth };