Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

OIDC session key fails to serialize for certain session middleware options #328

Closed
yangchristian opened this issue Jul 5, 2017 · 3 comments
Assignees

Comments

@yangchristian
Copy link

Version: v3.0.4
Setup (not specific to these deps though):

Repro:

  • Set the connect-mongo option stringify: false (details)

Result:
The dotted field 'OIDC: {redirectUrl}' in 'session.OIDC: {redirectUrl}' is not valid for storage

I believe the default value for the session key here is at fault
(https://github.com/AzureAD/passport-azure-ad/blob/master/lib/oidcstrategy.js#L382):

this._key = options.sessionKey || ('OIDC: ' + options.redirectUrl);

Depending on your setup, there's a decent chance that the key will have invalid characters and fail to serialize since we're using a raw URL. It just happens that for default Mongo setups you're ok since it will stringify the entire object.

Might I suggest using the clientId instead since that is more serializable? That's basically what we're doing in application code as a workaround (passing the option sessionKey: 'OIDC: {clientId}'). Alternatively, could do some escaping of the redirect url.

@lovemaths
Copy link
Contributor

lovemaths commented Jul 6, 2017

@yangchristian I can reproduce this issue. Yes, clientId is better choice, we will include this change in the next release. Thank you!

@lovemaths lovemaths self-assigned this Jul 6, 2017
lovemaths added a commit that referenced this issue Jul 6, 2017
@lovemaths lovemaths added the done label Jul 6, 2017
@faradayfan
Copy link

I have the same issue with v3.0.7
I just added oidcStrategy.sessionKey: clientID as a temporary work around.

@lovemaths
Copy link
Contributor

@yangchristian @faradayfan We just shipped v3.0.8 with the change. Closing the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants