express-openid-connect
Advanced tools
Comparing version 1.0.1 to 1.0.2
# CHANGELOG | ||
## [v1.0.2](https://github.com/auth0/express-openid-connect/tree/v1.0.2) (2020-05-12) | ||
[Full Changelog](https://github.com/auth0/express-openid-connect/compare/v1.0.1...v1.0.2) | ||
**Fixed** | ||
- Fix returnTo on Login [\#95](https://github.com/auth0/express-openid-connect/pull/95) ([davidpatrick](https://github.com/davidpatrick)) | ||
## [v1.0.1](https://github.com/auth0/express-openid-connect/tree/v1.0.1) (2020-04-17) | ||
@@ -4,0 +10,0 @@ [Full Changelog](https://github.com/auth0/express-openid-connect/compare/v1.0.0...v1.0.1) |
@@ -45,4 +45,12 @@ const { strict: assert } = require('assert'); | ||
function setCookie (req, res, { uat = epoch(), iat = uat, exp = uat + sessionDuration }) { | ||
const cookieOptions = {}; | ||
Object.keys(sessionConfig).filter(key => /^cookie/.test(key)).forEach((key) => { | ||
const cookieOptionKey = key.replace(/^cookie([A-Z])/, (match, p1) => p1.toLowerCase()); | ||
cookieOptions[cookieOptionKey] = sessionConfig[key]; | ||
}); | ||
const expires = cookieOptions.transient ? 0 : new Date(exp * 1000); | ||
delete cookieOptions.transient; | ||
if ((!req[sessionName] || !Object.keys(req[sessionName]).length) && sessionName in req[COOKIES]) { | ||
res.clearCookie(sessionName); | ||
res.clearCookie(sessionName, cookieOptions); | ||
return; | ||
@@ -54,12 +62,3 @@ } | ||
const cookieOptions = {}; | ||
Object.keys(sessionConfig).filter(key => /^cookie/.test(key)).forEach(function(key) { | ||
const cookieOptionKey = key.replace(/^cookie([A-Z])/, (match, p1) => p1.toLowerCase()); | ||
cookieOptions[cookieOptionKey] = sessionConfig[key]; | ||
}); | ||
cookieOptions.expires = cookieOptions.transient ? 0 : new Date(exp * 1000); | ||
delete cookieOptions.transient; | ||
res.cookie(sessionName, value, cookieOptions); | ||
res.cookie(sessionName, value, { expires, ...cookieOptions }); | ||
} | ||
@@ -66,0 +65,0 @@ } |
@@ -58,6 +58,13 @@ const cb = require('cb'); | ||
// Set default returnTo value, allow passed-in options to override. | ||
// Set default returnTo value, allow passed-in options to override or use originalUrl on GET | ||
let returnTo = this._config.baseURL; | ||
if (options.returnTo) { | ||
returnTo = options.returnTo; | ||
} else if (req.method === 'GET' && req.originalUrl) { | ||
returnTo = req.originalUrl; | ||
} | ||
options = { | ||
returnTo: this._config.baseURL, | ||
authorizationParams: {}, | ||
returnTo, | ||
...options | ||
@@ -64,0 +71,0 @@ }; |
{ | ||
"name": "express-openid-connect", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Express middleware to protect web applications using OpenID Connect.", | ||
@@ -40,3 +40,2 @@ "homepage": "https://github.com/auth0/express-openid-connect", | ||
"chai-as-promised": "^7.1.1", | ||
"cookie-session": "^2.0.0-rc.1", | ||
"eslint": "^5.16.0", | ||
@@ -43,0 +42,0 @@ "express": "^4.17.1", |
# Express OpenID Connect | ||
Express.js middleware for OpenID Relying Party (aka OAuth 2.0 Client). Easily add secure and standards-based authentication to Express applications. | ||
Express JS middleware implementing sign on for Express web apps using OpenID Connect. | ||
@@ -44,7 +44,5 @@ This library requires: | ||
The library needs [the following required configuration keys](https://github.com/auth0/express-openid-connect/blob/master/API.md#required-keys) to request and accept authentication. These can be configured in a `.env` file in the root of your application: | ||
The library needs [the following required configuration keys](https://github.com/auth0/express-openid-connect/blob/master/API.md#required-keys) to request and accept authentication. These can be configured with environmental variables: | ||
```text | ||
# .env | ||
ISSUER_BASE_URL=https://YOUR_DOMAIN | ||
@@ -51,0 +49,0 @@ CLIENT_ID=YOUR_CLIENT_ID |
48167
15
866
129