Skip to content

ExpressJS middleware to read the authentication token from the request

Notifications You must be signed in to change notification settings

ravivarma1192/expressjs-authtoken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

expressjs-authtoken is the middleware to read the authentication token from the request

How to use?

var authToken = require("expressjs-authtoken");
app.use(authToken());

if we don't specify any props, it will take from headers and with authorization key

passing custom props

by passing the custom props you can read the key from headers, body and params

Example

app.use(
  authToken({
    key: "authorization", //key to read from the request , default value is authorization
    readFrom: "headers", // read from headers/body/params, default value is headers
    isMandatory: true, // is authorization key mandatory, if mandatory is true then it will throw an error, defaut value is false,
    ignore: 7, // ignore characters from start to remove such as Bearer
  })
);

About

ExpressJS middleware to read the authentication token from the request

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published