Socket
Socket
Sign inDemoInstall

@fastify/basic-auth

Package Overview
Dependencies
Maintainers
20
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/basic-auth - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

5

index.js

@@ -133,3 +133,6 @@ 'use strict'

if (err.statusCode === 401) {
reply.header('WWW-Authenticate', authenticateHeader(req))
const header = authenticateHeader(req)
if (header) {
reply.header('WWW-Authenticate', header)
}
}

@@ -136,0 +139,0 @@ next(err)

2

package.json
{
"name": "@fastify/basic-auth",
"version": "5.1.0",
"version": "5.1.1",
"description": "Fastify basic auth plugin",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -465,2 +465,50 @@ 'use strict'

test('WWW-Authenticate (authenticate: false)', t => {
t.plan(6)
const fastify = Fastify()
const authenticate = false
fastify.register(basicAuth, { validate, authenticate, utf8: false })
function validate (username, password, req, res, done) {
if (username === 'user' && password === 'pwd') {
done()
} else {
done(new Error('Unauthorized'))
}
}
fastify.after(() => {
fastify.route({
method: 'GET',
url: '/',
preHandler: fastify.basicAuth,
handler: (req, reply) => {
reply.send({ hello: 'world' })
}
})
})
fastify.inject({
url: '/',
method: 'GET'
}, (err, res) => {
t.error(err)
t.equal(res.headers['www-authenticate'], undefined)
t.equal(res.statusCode, 401)
})
fastify.inject({
url: '/',
method: 'GET',
headers: {
authorization: basicAuthHeader('user', 'pwd')
}
}, (err, res) => {
t.error(err)
t.equal(res.headers['www-authenticate'], undefined)
t.equal(res.statusCode, 200)
})
})
test('WWW-Authenticate Realm (authenticate: {realm: "example"}, utf8: false)', t => {

@@ -467,0 +515,0 @@ t.plan(6)

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