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

hapi-auth-bearer-simple

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-auth-bearer-simple - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

25

lib/index.js

@@ -21,3 +21,2 @@ 'use strict';

internals.implementation = function (server, options) {
Hoek.assert(options, 'Missing bearerAuthentication strategy options');

@@ -31,3 +30,3 @@ Hoek.assert(typeof options.validateFunction === 'function', 'options.validateFunc must be a valid function in bearerAuthentication scheme');

if (!request.headers.authorization || request.headers.authorization === null || request.headers.authorization === undefined) {
reply(Boom.unauthorized('NO_AUTH_HEADER', 'bearerAuth'), null);
reply(Boom.unauthorized('NO_AUTHORIZATION_HEADER', 'bearerAuth'), null);
} else {

@@ -37,14 +36,24 @@ var headerParts = request.headers.authorization.split(' ');

if (headerParts[0].toLowerCase() !== 'bearer') {
return reply(Boom.notAcceptable('Token should be given in the Authorization header in "Bearer [token]" form. Example: "Authorization: Bearer azertyuiop0123"'), null);
return reply(Boom.notAcceptable('Token should be given in the Authorization header in "Bearer [token]" form. Example: "Authorization: Bearer azertyuiop0123"'));
}
// use provided validate function to return
settings.validateFunction(headerParts[1], function (err, isValid, result) {
if (err || !isValid || !result) {
return reply(Boom.unauthorized('UNAUTHORIZED_INVALID_TOKEN cause: ' + err, 'bearerAuth'), isValid);
settings.validateFunction(headerParts[1], function (err, isValid, credentials) {
if (!isValid || !credentials) {
return reply(Boom.unauthorized(null, 'bearerAuth', {
isValid: isValid,
credentials: credentials
}));
}
result.token = headerParts[1];
if (err) {
return reply(Boom.unauthorized(err, 'bearerAuth'), {
isValid: isValid,
credentials: credentials
});
}
credentials.token = headerParts[1];
return reply.continue({
credentials: result
credentials: credentials
});

@@ -51,0 +60,0 @@ });

{
"name": "hapi-auth-bearer-simple",
"description": "Custom authentication plugin for Hapi using Bearer tokens",
"version": "1.0.0",
"version": "1.0.1",
"author": "Adri Van Houdt <adri@salesflare.com>",

@@ -9,2 +9,11 @@ "private": false,

"multiple": true,
"keywords": [
"hapijs",
"authentication",
"hapi",
"plugin",
"token",
"auhtorization",
"simple"
],
"repository": {

@@ -24,3 +33,3 @@ "type": "git",

"peerDependencies": {
"hapi": ">=8.x.x < 9.x.x"
"hapi": ">=8.x.x"
},

@@ -27,0 +36,0 @@ "engines": {

@@ -1,2 +0,4 @@

[![Build Status](https://travis-ci.org/Salesflare/hapi-auth-bearer-simple.svg?branch=master)](https://travis-ci.org/Salesflare/hapi-auth-bearer-simple)
![Build Status](https://travis-ci.org/Salesflare/hapi-auth-bearer-simple.svg?branch=master) ![](https://david-dm.org/salesflare/hapi-auth-bearer-simple.svg) ![](https://david-dm.org/salesflare/hapi-auth-bearer-simple/dev-status.svg) ![](https://david-dm.org/salesflare/hapi-auth-bearer-simple/peer-status.svg)
[![Code Climate](https://codeclimate.com/github/Salesflare/hapi-auth-bearer-simple/badges/gpa.svg)](https://codeclimate.com/github/Salesflare/hapi-auth-bearer-simple)
# Hapi authentication plugin

@@ -3,0 +5,0 @@

@@ -28,3 +28,2 @@ 'use strict';

server.route({

@@ -54,3 +53,2 @@ method: 'GET',

done();

@@ -57,0 +55,0 @@ });

Sorry, the diff of this file is not supported yet

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