lengoo-auth-validator
v1.0.1
Published
Authentication validator for lengoo BFF services
Downloads
3
Readme
Lengoo Auth Validator
Lengoo Auth Validator is a library that allows BFF projects to interact with the authentication service and validate a given token.
The token will be first retrieved from the authentication service and then cached in Redis. The key set in Redis will expire at the same expiration date of the token itself.
Usage
Set ENV variables:
AUTH_URL=http://localhost:3000/api
REDIS_URL=redis://localhost:6379
Import as following:
import { validate, InvalidTokenError, TokenExpiredError } from 'lengoo-auth-validator';
Call the function validate(token)
:
- Returns the token payload
- Throws
InvalidTokenError
if token invalid (wrong format) - Throws
TokenExpiredError
if token is expired