Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-auth-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-auth-parser

Parses known HTTP headers and places them in req.auth

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
25
decreased by-21.87%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Dependency Status devDependency Status

http-auth-parser

This little library is used to parse and put the auth header data at req.auth. It can currently handle basic and bearer authentication types.

This has support for JWT tokens when bearer auth is being used. The token value will attempt to be parsed by the JWT parser. It ONLY does decode. If you would like to verify the token it is available at req.auth.jwt.token.

Auth Object

req.auth = {
  type: 'basic|bearer',
  username: 'username',
  password: 'password',
  token: 'token',
  jwt: {
    token: 'rawjwttoken',
    claims: 'Object of Claims from Token'
  }
}

Example Code

var authparser = require('http-auth-parser')

var http = require('http');
http.createServer(function (req, res) {
  authparser(req)

  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end(JSON.stringify(req.auth, null, 4));
}).listen(8000, '127.0.0.1');

curl -XGET -H 'Authorization: Bearer mytoken' http://localhost:8000

Example Auth Object

{
    "type": "basic",
    "username": "Aladdin",
    "password": "open sesame"
}

FAQs

Package last updated on 06 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc