Skip to content

wdalmut/mini-auth-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express mini auth middleware

npm install --save @wdalmut/mini-auth

A simple auth middleware to simplify the authentication layer

const auth = require('mini-auth');
app.get("/", auth(all), homePage);

Allow

to create a authentication method just prepare a function that returns a promise.

let all = () => {
    return Promise.resolve({
        id: 1,
        username: "wdalmut",
    });
};

The promise information will be propagated to the application in the req.user field.

Deny

If the promise will be rejected the auth layer fails and will reply with 401.

let deny = () => {
    return Promise.reject({
        error: "no body in here",
    });
};

About

Mini authentication middleware for express

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published