🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

hapi-auth-bearer-mw

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version

to
1.3.2

test/auth-tests.coffee

45

lib/index.js

@@ -64,6 +64,8 @@ (function() {

credentials = {
id: infoResult.actor.actorId,
id: infoResult.actor.actorId.toString(),
_id: infoResult.actor.actorId.toString(),
clientId: infoResult.clientId,
isValid: !!infoResult.isValid,
isClientValid: !!infoResult.isClientValid,
isAnonymous: false,
scopes: scopes,

@@ -75,33 +77,24 @@ scope: scopes,

};
return internals.users().get(credentials.id, {}, function(err, user) {
return internals.users().get(credentials.id, {}, function(err, userResult) {
if (err) {
return cb(err);
}
credentials.name = user.username;
credentials.user = user;
if (_.isArray(user.roles)) {
credentials.roles = user.roles;
/*
If user is not found, we need to return an unauthorized error
*/
if (!userResult) {
return cb(null, null);
}
if (_.isFunction(userResult.toObject)) {
userResult = userResult.toObject();
}
userResult._id = userResult._id.toString();
credentials.name = userResult.username;
credentials.user = userResult;
if (_.isArray(userResult.roles)) {
credentials.roles = userResult.roles;
}
return cb(null, credentials);
});
/*
if (!info) {
return cb(null, null);
}
info.isValid = !!(info.actor && info.actor.actorId && info.expiresIn);
if (info.isValid) {
user = {
isServerToken: false,
isActsAsActorId: false,
username: info.actor.actorId,
userId: info.actor.actorId,
scopes: []
};
_.extend(user, info);
user.scopes.push('user');
return cb(null, user);
} else {
return cb(null, null);
*/
});

@@ -108,0 +101,0 @@ };

{
"name": "hapi-auth-bearer-mw",
"version": "1.3.1",
"version": "1.3.2",
"private": false,

@@ -17,6 +17,6 @@ "main": "lib/index.js",

"boom": ">=2.5.1",
"underscore": ">=1.6.0"
"underscore": ">=1.7.0"
},
"peerDependencies": {
"hapi": ">=6.5.0"
"hapi": ">=6.5.0 <8"
},

@@ -23,0 +23,0 @@ "devDependencies": {

@@ -8,2 +8,3 @@ [![Build Status](https://travis-ci.org/codedoctor/hapi-auth-bearer-mw.svg?branch=master)](https://travis-ci.org/codedoctor/hapi-auth-bearer-mw)

[![HAPI 6.0](http://img.shields.io/badge/hapi-6.0-blue.svg)](http://hapijs.com)
[![HAPI 7.0](http://img.shields.io/badge/hapi-7.0-blue.svg)](http://hapijs.com)
[![API Documentation](http://img.shields.io/badge/API-Documentation-ff69b4.svg)](http://coffeedoc.info/github/codedoctor/hapi-auth-bearer-mw)

@@ -22,2 +23,6 @@

## Versions
1.3.2
Requires the use of hapi-user-store-multi-tenant v1.1.1 or up.
## See also

@@ -24,0 +29,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet