Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Ag okta 404546 pr 1010 (#1020)
Browse files Browse the repository at this point in the history
* chore[oidc-middleware]: Updating UUID version

Avoids deprecation message and insecure random usages

* chore[oidc-middleware]: Updated yarn.lock for package updates

* fix[oidc-middleware]: Fixed UUID returning null value

Caused by update without reading migration guide.
Test > e2e > harness > server.js > DemoServer > start now uses random UUID like it used to.

* refactor[oidc-middleware]: Replaced Promise.reject with throw

Fixed error in linting where eslint complained about using Promise.reject. This should function the same, without the error while linting

* remove comment

Co-authored-by: Nova <novaw@warrenservices.co.uk>
Co-authored-by: Nova Wittam <novawittam@gmail.com>
  • Loading branch information
3 people committed Jul 2, 2021
1 parent 920a499 commit f643ce6
Show file tree
Hide file tree
Showing 4 changed files with 1,736 additions and 1,169 deletions.
2 changes: 1 addition & 1 deletion packages/oidc-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"node-fetch": "^2.3.0",
"openid-client": "3.12.2",
"passport": "^0.4.1",
"uuid": "^3.1.0"
"uuid": "^8.3.2"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/oidc-middleware/src/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const makeTokenRevoker = ({ issuer, client_id, client_secret, errorHandler }) =>
body: querystring.stringify({token, token_type_hint: token_hint}),
})
// eslint-disable-next-line promise/no-nesting
.then( r => r.ok ? r : r.text().then(message => Promise.reject(new OIDCMiddlewareError('revokeError', message)) ))
.then( r => r.ok ? r : r.text().then((message) => {
throw new OIDCMiddlewareError('revokeError', message);
}))
.catch( errorHandler ) // catch and emit - this promise chain can never fail
};
};
Expand Down
17 changes: 10 additions & 7 deletions packages/oidc-middleware/test/e2e/harness/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = class DemoServer {
const app = express();
this.app = app;
app.use(session({
secret: uuid(), // this will invalidate all sessions on each restart
secret: uuid.v4(), // this will invalidate all sessions on each restart
resave: true,
saveUninitialized: false
}));
Expand Down Expand Up @@ -75,13 +75,16 @@ module.exports = class DemoServer {
stop() {
console.log('Server shutting down');
return new Promise((resolve, reject) => {
this.httpServer.destroy((err) => {
console.log('Server destroyed')
if (err) {
return reject(err);
}
if (this.httpServer) {
this.httpServer.destroy((err) => {
console.log('Server destroyed')
if (err) {
return reject(err);
}
return resolve();
});
} else
return resolve();
});
});
}
}
Expand Down

0 comments on commit f643ce6

Please sign in to comment.