hydra-express
Advanced tools
Comparing version 1.3.8 to 1.4.1
@@ -74,3 +74,3 @@ ![logo](hydra-express.png) | ||
HydraExpress includes a `log` member which allows you to log into to both the console and log file. | ||
HydraExpress includes a `log` member which allows you to log into to both the console and log file. | ||
@@ -212,12 +212,7 @@ ```javascript | ||
#### validateJwtToken | ||
Express middleware to validate a JWT sent via the req.authorization header | ||
```javascript | ||
/** | ||
* @name validateJwtToken | ||
* @summary Express middleware to validate a JWT sent via the req.authorization header | ||
* @return {function} Middleware function | ||
*/ | ||
validateJwtToken() | ||
``` | ||
*DEPRECATED* | ||
This functionality has been extracted to the [jwt-auth plugin](http://github.com/flywheelsports/hydra-express-plugin-jwt-auth). | ||
## Hydra / Express configuration | ||
@@ -224,0 +219,0 @@ |
80
index.js
@@ -36,3 +36,2 @@ /** | ||
const responseTime = require('response-time'); | ||
const jwtAuth = require('fwsp-jwt-auth'); | ||
@@ -182,10 +181,3 @@ let app = express(); | ||
return Promise.series(this.registeredPlugins, (plugin) => plugin.setConfig(config)) | ||
.then((..._results) => { | ||
if (config.jwtPublicCert) { | ||
return jwtAuth.loadCerts(null, config.jwtPublicCert) | ||
.catch((_err) => reject(new Error('Can\'t load public cert'))); | ||
} | ||
}) | ||
.then(() => this.start(resolve, reject)) | ||
return Promise.try(this.start(resolve, reject)) | ||
.catch((err) => this.log('error', err.toString())); | ||
@@ -237,11 +229,2 @@ } | ||
/** | ||
* @name getJwtAuth | ||
* @summary Retrieve the underlying jwtAuth object | ||
* @return {object} jwtAuth - jwtAuth object | ||
*/ | ||
getJwtAuth() { | ||
return jwtAuth; | ||
} | ||
/** | ||
* @name getRuntimeConfig | ||
@@ -308,4 +291,5 @@ * @summary Retrieve loaded configuration object | ||
this.config = config; | ||
return hydra.registerService(); | ||
return Promise.series(this.registeredPlugins, plugin => plugin.setConfig(config)); | ||
}) | ||
.then(() => hydra.registerService()) | ||
.then((_serviceInfo) => { | ||
@@ -316,3 +300,3 @@ serviceInfo = _serviceInfo; | ||
this.initService(); | ||
return Promise.series(this.registeredPlugins, (plugin) => plugin.onServiceReady()); | ||
return Promise.series(this.registeredPlugins, plugin => plugin.onServiceReady()); | ||
}) | ||
@@ -530,41 +514,2 @@ .then((..._results) => { | ||
/** | ||
* @name _validateJwtToken | ||
* @summary Express middleware to validate a JWT sent via the req.authorization header | ||
* @return {function} Middleware function | ||
*/ | ||
_validateJwtToken() { | ||
return (req, res, next) => { | ||
let authHeader = req.headers.authorization; | ||
if (!authHeader) { | ||
this.sendResponse(ServerResponse.HTTP_UNAUTHORIZED, res, { | ||
result: { | ||
reason: 'Invalid token' | ||
} | ||
}); | ||
} else { | ||
let token = authHeader.split(' ')[1]; | ||
if (token) { | ||
return jwtAuth.verifyToken(token) | ||
.then((decoded) => { | ||
req.authToken = decoded; | ||
next(); | ||
}) | ||
.catch((err) => { | ||
this.sendResponse(ServerResponse.HTTP_UNAUTHORIZED, res, { | ||
result: { | ||
reason: err.message | ||
} | ||
}); | ||
}); | ||
} else { | ||
this.sendResponse(ServerResponse.HTTP_UNAUTHORIZED, res, { | ||
result: { | ||
reason: 'Invalid token' | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
@@ -662,11 +607,2 @@ | ||
/** | ||
* @name getJwtAuth | ||
* @summary Retrieve the underlying jwtAuth object | ||
* @return {object} jwtAuth - jwtAuth object | ||
*/ | ||
getJwtAuth() { | ||
return super.getJwtAuth(); | ||
} | ||
/** | ||
* @name getRuntimeConfig | ||
@@ -714,12 +650,4 @@ * @summary Retrieve loaded configuration object | ||
/** | ||
* @name validateJwtToken | ||
* @summary Express middleware to validate a JWT sent via the req.authorization header | ||
* @return {function} Middleware function | ||
*/ | ||
validateJwtToken() { | ||
return super._validateJwtToken(); | ||
} | ||
} | ||
module.exports = new IHydraExpress; |
{ | ||
"name": "hydra-express", | ||
"version": "1.3.8", | ||
"version": "1.4.1", | ||
"description": "A module which wraps Hydra and ExpressJS to provide an out of the box microservice which can support API routes and handlers.", | ||
@@ -46,4 +46,3 @@ "author": { | ||
"hydra": "1.3.6", | ||
"fwsp-jwt-auth": "0.1.0", | ||
"helmet": "3.5.0", | ||
"helmet": "3.6.0", | ||
"moment": "2.18.1", | ||
@@ -50,0 +49,0 @@ "response-time": "2.3.2" |
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
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
8
900711
740
+ Addedexpect-ct@0.1.0(transitive)
+ Addedhelmet@3.6.0(transitive)
- Removedfwsp-jwt-auth@0.1.0
- Removedassertion-error@1.1.0(transitive)
- Removedbluebird@3.4.6(transitive)
- Removedbuffer-equal-constant-time@1.0.1(transitive)
- Removedchai@3.5.0(transitive)
- Removedchai-as-promised@6.0.0(transitive)
- Removedcheck-error@1.0.3(transitive)
- Removeddeep-eql@0.1.3(transitive)
- Removedecdsa-sig-formatter@1.0.11(transitive)
- Removedfwsp-cacher@1.0.3(transitive)
- Removedfwsp-jsutils@1.0.10(transitive)
- Removedfwsp-jwt-auth@0.1.0(transitive)
- Removedfwsp-redis-connection@0.0.3(transitive)
- Removedget-func-name@2.0.2(transitive)
- Removedhelmet@3.5.0(transitive)
- Removedhoek@2.16.3(transitive)
- Removedisemail@1.2.0(transitive)
- Removedjoi@6.10.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonwebtoken@7.2.1(transitive)
- Removedjwa@1.4.1(transitive)
- Removedjws@3.2.2(transitive)
- Removedlodash.once@4.1.1(transitive)
- Removedredis@2.7.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedtopo@1.1.0(transitive)
- Removedtype-detect@0.1.11.0.0(transitive)
- Removedxtend@4.0.2(transitive)
Updatedhelmet@3.6.0