@constlab/vesper-jwt-auth
v0.1.0
Published
vesper + jwt auth
Downloads
57
Readme
Vesper JWT Auth
Early access. Not for production use
Initial setup
npm i @constlab/vesper-jwt-auth- Add
AuthModuleto bootstrap - Add
UserRepositoryto DI container - Add authorization checker function
- Add salt to parameters (see https://github.com/vesper-framework/vesper/blob/master/src/options/SchemaBuilderOptions.ts#L85)
import { AuthModule, jwtAuthorizationCheck } from "@constlab/vesper-jwt-auth";
bootstrap({
port: 3000,
parameters: {
"salt": "<random string>"
},
modules: [AuthModule, UserModule],
setupContainer: async (container, action) => {
container.set("user.repository", getRepository(User));
},
authorizationChecker: (roles: string[], action) => jwtAuthorizationCheck(roles, action)
});