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

Optional authentication #43

Open
felixSchl opened this issue Jan 10, 2018 · 1 comment
Open

Optional authentication #43

felixSchl opened this issue Jan 10, 2018 · 1 comment

Comments

@felixSchl
Copy link

felixSchl commented Jan 10, 2018

Hey, thank you for this library and the example code. I have a use-case I cannot figure out how to go about. Some of my routes work both for authenticated and unauthenticated requests. Naturally, I'd like a Maybe Session. I saw getSession is pretty much what I am after, but if I don't throw a 403 at the AuthHandler level, all my other routes have to take a missing session into account and I have to sprinkle the 403 logic everywhere. If I want to keep throwing 403s at the AuthHandler level, I cannot seem to figure out how to pull the session out of other requests. I assume I need something akin to AuthProtect that calls a different auth handler function. Reading this back, it seems this might be a issue (or question) better situated in servant-auth servant, so feel free to close it if you think so, too.

@zohl
Copy link
Owner

zohl commented Jan 13, 2018

Hello!

You're right, it can be achieved with two auth-handlers, one for cookie/err403 cases and one for cookie/no-cookie cases, that returns Maybe Session. However, at the moment it's not possible to reuse library's code for another handler.

I'll be thinking, in which way to tweak the library to make it possible.

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

No branches or pull requests

2 participants