Comparing version 0.3.1 to 0.3.2
@@ -14,3 +14,4 @@ 'use strict'; | ||
options.odicConfig = options.oidcServer + '/.well-known/openid-configuration'; | ||
options.oidcConfig = options.oidcServer + '/.well-known/openid-configuration'; | ||
options.additionalScopes = options.additionalScopes || []; | ||
@@ -25,6 +26,6 @@ let handlerFactory = new HandlerFactory(); | ||
rest | ||
.get(options.odicConfig) | ||
.get(options.oidcConfig) | ||
.on('complete', result => { | ||
// parse the hostname out | ||
options.odicConfig = result; | ||
options.oidcConfig = result; | ||
debug('Config loaded dynamically'); | ||
@@ -36,7 +37,6 @@ | ||
.on('complete', result => { | ||
options.odicConfig.jwks = result.keys; | ||
options.oidcConfig.jwks = result.keys; | ||
debug('JWKS loaded dynamically'); | ||
if(done) { done(); } | ||
}); | ||
}); | ||
@@ -48,3 +48,3 @@ | ||
response_type: 'code', | ||
scope: 'openid profile email groups offline_access', | ||
scope: 'openid profile email', | ||
client_id: options.clientId, | ||
@@ -54,3 +54,3 @@ state: uid(24), | ||
}; | ||
var location = options.odicConfig.authorization_endpoint + '?' + querystring.stringify(params); | ||
var location = options.oidcConfig.authorization_endpoint + '?' + querystring.stringify(params); | ||
debug('redirecting to the open id connect server'); | ||
@@ -62,3 +62,17 @@ return middleware.redirect(location); | ||
let validateScopesVsSupported = function(middleware) { | ||
let valid = true; | ||
options.additionalScopes.forEach(scope => { | ||
if(options.oidcConfig.scopes_supported.indexOf(scope) === -1) { | ||
valid = false; | ||
middleware.fail(new Error(scope + ' is not a supported scope')); | ||
} | ||
}); | ||
return valid; | ||
}; | ||
self.handle = (req, middleware, handlerOptions) => { | ||
if(validateScopesVsSupported(middleware) === false) { | ||
return; | ||
} | ||
/* jshint maxcomplexity: 5 */ | ||
@@ -65,0 +79,0 @@ handlerOptions = handlerOptions || {}; |
'use strict'; | ||
let AuthorizationToken = require('../models').AuthorizationToken; | ||
let debug = require('debug')('oidc:handler:authorizationToken'); | ||
function AuthorizationTokenHandler() { | ||
@@ -11,2 +12,3 @@ let self = {}; | ||
result.token = new AuthorizationToken(data); | ||
debug('Authorization Token:', result.token); | ||
next(); | ||
@@ -13,0 +15,0 @@ }; |
@@ -28,3 +28,3 @@ 'use strict'; | ||
rest | ||
.post(options.odicConfig.token_endpoint, postOptions) | ||
.post(options.oidcConfig.token_endpoint, postOptions) | ||
.on('complete', (accessTokenResult) => { | ||
@@ -31,0 +31,0 @@ handlerFactory.handlerFor(accessTokenResult, result, next); |
@@ -19,4 +19,5 @@ 'use strict'; | ||
}, | ||
fail: () => { | ||
res.send(401); | ||
fail: (err) => { | ||
if(err === undefined) { return res.send(401); } | ||
res.send(401, err.message); | ||
}, | ||
@@ -23,0 +24,0 @@ redirect: location => { |
@@ -12,4 +12,5 @@ 'use strict'; | ||
}, | ||
fail: () => { | ||
res.send(401); | ||
fail: (err) => { | ||
if(err === undefined) { return res.send(401); } | ||
res.send(401, err.message); | ||
}, | ||
@@ -16,0 +17,0 @@ redirect: location => { |
@@ -28,3 +28,3 @@ 'use strict'; | ||
// Lookup the matching signing key | ||
let signingKey = options.odicConfig.jwks.find(k => { | ||
let signingKey = options.oidcConfig.jwks.find(k => { | ||
return (k.kid === self.header.kid && k.alg === self.header.alg); | ||
@@ -31,0 +31,0 @@ }); |
{ | ||
"name": "oidc", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Middleware for a bunch of common web servers to handle OIDC authentication.", | ||
@@ -35,5 +35,5 @@ "keywords": [ | ||
"dependencies": { | ||
"async": "^2.0.1", | ||
"debug": "^2.2.0", | ||
"jsonwebtoken": "^7.1.7", | ||
"async": "^2.1.4", | ||
"debug": "^2.6.0", | ||
"jsonwebtoken": "^7.2.1", | ||
"restler": "^3.4.0", | ||
@@ -44,20 +44,20 @@ "rsa-pem-from-mod-exp": "^0.8.4", | ||
"devDependencies": { | ||
"deride": "^0.5.4", | ||
"deride": "^1.1.0", | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-jshint": "^1.0.0", | ||
"grunt-contrib-jshint": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-env": "^0.4.4", | ||
"grunt-mocha-istanbul": "^5.0.1", | ||
"grunt-mocha-test": "^0.12.7", | ||
"grunt-mocha-istanbul": "^5.0.2", | ||
"grunt-mocha-test": "^0.13.2", | ||
"grunt-wait-server": "^0.3.0", | ||
"istanbul": "^0.4.4", | ||
"mocha": "^2.2.5", | ||
"mocha-jenkins-reporter": "^0.2.2", | ||
"mocha-junit-reporter": "^1.11.1", | ||
"mocha-multi": "^0.9.0", | ||
"mock-require": "^1.3.0", | ||
"restify": "^4.1.1", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.2.0", | ||
"mocha-jenkins-reporter": "^0.3.5", | ||
"mocha-junit-reporter": "^1.13.0", | ||
"mocha-multi": "^0.10.0", | ||
"mock-require": "^2.0.1", | ||
"restify": "^4.3.0", | ||
"rewire": "^2.5.2", | ||
"should": "^9.0.2" | ||
"should": "^11.2.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "scripts": { |
@@ -64,3 +64,4 @@ # oidc | ||
clientSecret: 'clientsecret-here', | ||
callbackURL: 'http://127.0.0.1:9000/auth/okta/callback' | ||
callbackURL: 'http://127.0.0.1:9000/auth/okta/callback', | ||
additionalScopes: ['address'] | ||
}); | ||
@@ -67,0 +68,0 @@ let middleware = new oidc.middleware.Restify(auth); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168417
22
448
106
2
70
Updatedasync@^2.1.4
Updateddebug@^2.6.0
Updatedjsonwebtoken@^7.2.1