Gathering detailed insights and metrics for auth-header
Gathering detailed insights and metrics for auth-header
Gathering detailed insights and metrics for auth-header
Gathering detailed insights and metrics for auth-header
Deal with obscene HTTP `Authorization` and `WWW-Authenticate` headers.
npm install auth-header
Typescript
Module System
Node Version
NPM Version
99.5
Supply Chain
87.3
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
19,444,352
Last Day
29,284
Last Week
138,767
Last Month
588,138
Last Year
6,703,894
23 Stars
38 Commits
6 Forks
4 Watching
2 Branches
4 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
auth-header@1.0.0
Size
6.76 kB
NPM Version
6.1.0
Node Version
10.4.1
Publised On
21 Aug 2018
Cumulative downloads
Total Downloads
Last day
17.4%
29,284
Compared to previous day
Last week
-6.8%
138,767
Compared to previous week
Last month
-0.5%
588,138
Compared to previous month
Last year
38.1%
6,703,894
Compared to previous year
Deal with obscene HTTP Authorization
and WWW-Authenticate
headers.
Type | Parse | Format |
---|---|---|
Basic | ✓ | ✓ |
Digest | ✓ | ✓ |
AWS | ✓ | ✓ |
Bearer/OAuth | ✓ | ✓ |
RFC7235 | ✓ | ✓ |
Note: If you're looking for an all-on-one solution to do authentication against these headers check out express-authentication-header which uses this library behind the scenes.
The HTTP Authorization
and WWW-Authenticate
family of headers are both pretty nightmareish; there has been, up until recently, no wide consensus about how they should be formatted and so parsing them is lots of fun if fun is pulling your hair out.
This library provides an implementation of RFC7235 which allows for the parsing of many known existing authorization headers (like Basic and Digest) as well as any future ones which follow the standard. Noteably, this library is less strict than it could be to parse some of these legacy formats.
In addition to the format of the header itself being in flux, WWW-Authenticate has its own nasty surprise: sometimes multiple authentication prompts can appear in one header, sometimes they can appear in multiple headers; we ONLY support the latter case since trying to disambiguate between a second prompt and parameters for the first is just about impossible.
1import * as authorization from 'auth-header'; 2import express from 'express'; 3 4const app = express(); 5 6app.get('/', function(req, res) { 7 8 // Something messed up. 9 function fail() { 10 res.set('WWW-Authenticate', authorization.format('Basic')); 11 res.status(401).send(); 12 } 13 14 // Get authorization header. 15 var auth = authorization.parse(req.get('authorization')); 16 17 // No basic authentication provided. 18 if (auth.scheme !== 'Basic') { 19 return fail(); 20 } 21 22 // Get the basic auth component. 23 var [un, pw] = Buffer(auth.token, 'base64').toString().split(':', 2); 24 25 // Verify authentication. 26 if (pw !== 'admin') { 27 return fail(); 28 } 29 30 // We've reached the promise land. 31 res.send('Hello world.'); 32});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 3/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More