@axiljs/auth
v0.2.8
Published
AxilJS JWT authentication, password hashing, and RBAC
Maintainers
Readme
@axiljs/auth
JWT authentication, password hashing with scrypt, and RBAC middleware.
Part of the AxilJS ecosystem.
Install
npm install @axiljs/authUsage
import { JWT, hashPassword, verifyPassword,
authenticate, requireRole } from '@axiljs/auth'
const jwt = new JWT(process.env.JWT_SECRET)
const hashed = await hashPassword('password123')
const valid = await verifyPassword('password123', hashed)
const token = jwt.sign({ sub: '1', role: 'admin' }, { expiresIn: '7d' })
app.get('/profile', authenticate(jwt), (req, res) => {
res.success(req.locals.user, 'Profile fetched')
})
app.delete('/users/:id', authenticate(jwt), requireRole('admin'), handler)Full docs: github.com/SyntaxilitY/AxilJS
