Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/constlab/vesper-jwt-auth


https://github.com/constlab/vesper-jwt-auth

graphql jwt jwt-auth typescript vesper

Last synced: 18 days ago
JSON representation

Awesome Lists containing this project

README

        

# Vesper JWT Auth

[![Build Status](https://travis-ci.org/constlab/vesper-jwt-auth.svg?branch=master)](https://travis-ci.org/constlab/vesper-jwt-auth)

## Early access. Not for production use

## Initial setup

1. `npm i @constlab/vesper-jwt-auth`
2. Add `AuthModule` to bootstrap
3. Add `UserRepository` to DI container
4. Add authorization checker function
5. Add salt to parameters (see https://github.com/vesper-framework/vesper/blob/master/src/options/SchemaBuilderOptions.ts#L85)

```typescript
import { AuthModule, jwtAuthorizationCheck } from "@constlab/vesper-jwt-auth";

bootstrap({
port: 3000,
parameters: {
"salt": ""
},
modules: [AuthModule, UserModule],
setupContainer: async (container, action) => {
container.set("user.repository", getRepository(User));
},
authorizationChecker: (roles: string[], action) => jwtAuthorizationCheck(roles, action)
});
```