Skip to content

reecefenwick/express-auth-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

express-auth-parser

Express based middleware, can be used to parse any Basic like authorization headers.

Installation

npm install express-auth-parser

Usage

var express = require('express')
var authParser = require('express-auth-parser');

var app = express();

app.use(authParser);

app.get('/', function (req, res) {
    // Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
    console.log(req.authorization)
    
    { 
        scheme: 'Basic',
        credentials: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
        basic: { username: 'username', password: 'password' }
    }

    // Authorization: Bearer ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjFjMlZ5Ym1GdFpTST...
    { 
        scheme: 'Bearer',
        credentials: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InVzZXJuYW1l...' 
    }
    
    res.send('Hello World');
});

app.listen(3000);

About

Auth parser middleware for connect/expres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published