10.0.0 • Published 3 years ago

auth0-node v10.0.0

Weekly downloads
4
License
-
Repository
-
Last release
3 years ago

API authentication using auth0 JSON WEB TOKENS

Installation

npm install auth0-node

Usage

Validating API tokens needs express-jwt and jwks-rsa to validate the API

const jwt = require('express-jwt')
const jwks = require('jwks-rsa');

process.env.AUDIENCE optional parameter takes clientId, for which the api to be validated

ex: vskjvjdb(clientId of a specific application)

process.env.DOMAIN parameter takes the domain name from the auth0

ex: https://xyz.com/

authentication.jwtCheck = (audience = null) => jwt({
    secret: jwks.expressJwtSecret({
        cache: true,
        rateLimit: true,
        jwksRequestsPerMinute: 15,
        jwksUri: `https://${process.env.DOMAIN}/.well-known/jwks.json`
    }),
    //AUDIENCE is the clientId of an application, provide this if you need an API to be validated specifically for a single client
    audience: audience ? process.env.AUDIENCE : null,
    issuer: `https://${process.env.DOMAIN}/`,
    algorithms: ['RS256']
});

Permission validation

Middleware function that takes apipermissions as input to check whether the user holds that api permissions

apiPermissions.filter(value => req.user.permissions.includes(value)).length
10.0.0

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago