Gathering detailed insights and metrics for xprezzo-basic-auth
Gathering detailed insights and metrics for xprezzo-basic-auth
npm install xprezzo-basic-auth
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
1,819
Last Day
1
Last Week
18
Last Month
42
Last Year
668
3 Stars
5 Commits
1 Watching
1 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.3
Package Id
xprezzo-basic-auth@1.1.3
Unpacked Size
8.47 kB
Size
3.28 kB
File Count
5
NPM Version
8.5.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
5.9%
18
Compared to previous week
Last month
1,300%
42
Compared to previous month
Last year
225.9%
668
Compared to previous year
Basic auth Authorization header field parser for xprezzo.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install xprezzo-basic-auth
1var auth = require('xprezzo-basic-auth')
Get the basic auth credentials from the given request. The Authorization
header is parsed and if the header is invalid, undefined
is returned,
otherwise an object with name
and pass
properties.
Parse a basic auth authorization header string. This will return an object
with name
and pass
properties, or undefined
if the string is invalid.
Pass a Node.js request object to the module export. If parsing fails
undefined
is returned, otherwise an object with .name
and .pass
.
1var auth = require('xprezzo-basic-auth') 2var user = auth(req) 3// => { name: 'something', pass: 'whatever' }
A header string from any other location can also be parsed with
auth.parse
, for example a Proxy-Authorization
header:
1var auth = require('xprezzo-basic-auth') 2var user = auth.parse(req.getHeader('Proxy-Authorization'))
1var http = require('http') 2var auth = require('xprezzo-basic-auth') 3var compare = require('tsscmp') 4 5// Create server 6var server = http.createServer(function (req, res) { 7 var credentials = auth(req) 8 9 // Check credentials 10 // The "check" function will typically be against your user store 11 if (!credentials || !check(credentials.name, credentials.pass)) { 12 res.statusCode = 401 13 res.setHeader('WWW-Authenticate', 'Basic realm="example"') 14 res.end('Access denied') 15 } else { 16 res.end('Access granted') 17 } 18}) 19 20// Basic function to validate credentials for example 21function check (name, pass) { 22 var valid = true 23 24 // Simple method to prevent short-circut and use timing-safe compare 25 valid = compare(name, 'john') && valid 26 valid = compare(pass, 'secret') && valid 27 28 return valid 29} 30 31// Listen 32server.listen(3000)
Xprezzo and related projects are maintained by Cloudgen Wong.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-20
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