-
Notifications
You must be signed in to change notification settings - Fork 67
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
Session support #60
Comments
Indeed it is planned. We should have something that's based on https://github.com/inhabitedtype/ocaml-session |
I've been experimenting with One thing that makes me think we will probably have to build our own solution is that |
Is it not possible to create a a cookie backend for session? |
Not at the moment, the types for val get : t -> key -> (value * period, error) result
val set : ?expiry:period -> t -> key -> value -> unit
Similarly, So, from what I can see, the API of |
I would like to see cookie-based session support, too. I tried to implement something simple myself but without luck so far: set a cookie when a form posts correct credentials and later check for the presence of the cookie. I also struggle with composing the app such that some routes require authentication while others don't. It seems that once you have an authentication test in the stack, it affects all routes and not just the one below it. |
@lindig I have selective session checking (and selective CSRF token checking) support built as middlewares based on this: #263 (comment) You can probably do something similar; else I can probably either PR some of these middlewares to Opium, or publish them in their own repo. I have a nice composable chain of these things, something like a nice logger with colors and request ids, followed by session checking (I do check them unconditionally, because I generate pre-sessions for non-logged-in users; the session middleware exposes a function for replacing the session if one of the handlers logs it in). This is followed by routing, with POST routes being strictly filtered by Content-type, which is then followed by CSRF token checking. Forms are loaded into pattern-matching-friendly values. I even have middlewares for choosing the UI language, any path prefix, and the whole URL structure. Overall, Opium middlewares seem to compose very well. |
Thanks. I have solved the problem of requiring authentication only for some routes but my session support is primitive as it relies on simple tokens. My
|
Is it planned to support session?
The text was updated successfully, but these errors were encountered: