Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add envClientSessionBackend, ENV-based session key #876

Merged
merged 1 commit into from
Nov 25, 2014

Conversation

pbrisbin
Copy link
Member

This can be useful if:

  1. You can't rely on a persistent file system (e.g. Heroku)
  2. Your application is open source (e.g. you can't commit the key)

By keeping a consistent value in the environment variable, your users will have
consistent sessions without relying on the file system.

Usage:

makeSessionBackend _ = fmap Just $ envClientSessionBackend 120 "SESSION_KEY"

Related: #806

Totally open to bikeshedding the function name.

This can be useful if:

1. You can't rely on a persistent file system (e.g. Heroku)
2. Your application is open source (e.g. you can't commit the key)

By keeping a consistent value in the environment variable, your users will
have consistent sessions without relying on the file system.

Usage:

    makeSessionBackend _ = fmap Just $ envClientSessionBackend 120 "SESSION_KEY"
@gregwebs
Copy link
Member

This looks great and it follows the existing pattern. It seems to me though that there is a problem with the getKey and getKeyEnv from clientsession: they both silently default to generating a new key when one is missing.

Do you think it would be a good idea to change these functions (actually to add new ones) that return an Either? Left would be a default, and in that case a warning can be printed.

@meteficha
Copy link
Member

@gregwebs By "a default", you mean a predictable session key? I don't see how that would be an improvement.

@gregwebs
Copy link
Member

@meteficha I opened up an issue in clientsession that hopefully explains it a little better. I am probably using the wrong terminology, I am not talking about changing any functionality, just exposing more information in the API.

yesodweb/clientsession#27

gregwebs added a commit that referenced this pull request Nov 25, 2014
Add envClientSessionBackend, ENV-based session key
@gregwebs gregwebs merged commit b8d474e into master Nov 25, 2014
@gregwebs gregwebs deleted the pb-env-client-session-backend branch November 25, 2014 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants