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

Proposal: std/session #646

Closed
getspooky opened this issue Oct 7, 2020 · 4 comments
Closed

Proposal: std/session #646

getspooky opened this issue Oct 7, 2020 · 4 comments

Comments

@getspooky
Copy link
Contributor

Hello deno community ,
I think it would be an enrichment to std to have session included by default with several great drivers out of the box

  • cookie - sessions are stored in secure, encrypted cookies.
  • database - sessions are stored in a relational database.
  • memcached / redis - sessions are stored in one of these fast, cache based stores.

What are your thoughts on that?

@ry
Copy link
Member

ry commented Oct 7, 2020

We're open to adding it to std, but it would be great if there was already some existing code to look at. Are the modules you have in mind already in deno.land/x ?

@andreespirela
Copy link

andreespirela commented Oct 9, 2020

@ry @getspooky Mandarine frameworks has a built-in session system. This one works as follows:
1- A request is received
2- A middleware verifies whether a “cookie for session” exists
3- An encrypted cookie is created (this cookie contains the session id) if it doesn’t already exist
4- A session object is created in the request context
5- If the session object contains new data, the session is stored (if new) or updated (if session object already had data and was already stored)

Few concepts:

Session Container: A Registry in memory which contains the active sessions & a couple methods for manipulation.

Resources about Mandarine sessions:

https://www.mandarinets.org/docs/mandarine/session-middleware (Explains the lifecycle, and relation to/with the request)

https://www.mandarinets.org/docs/master/mandarine/session-container (explains the session container)

I will gladly port this to STD @ry if it’s wanted, this can be made minimalist & adaptable to Deno std http. I believe there’s definately work to do here & I will gladly port these concepts to STD in a Deno & Global way outside any framework concept.

Note: This would be a sessions-in-memory concept as they are stored in a javascript registry. There can be work done on overriding these kind of behaviors like providing interfaces to the users (kind of like Go does with its interface for Database drivers) but we could alternatively provide an interface for session storage & container, besides the default implementation

@kitsonk
Copy link
Contributor

kitsonk commented Oct 9, 2020

I tend to feel these are all framework concerns, and really don't belong in std.

@bartlomieju bartlomieju transferred this issue from denoland/deno Feb 1, 2021
@bartlomieju
Copy link
Member

I agree with @kitsonk that this is not something that should belong to std. Respectfully declined.

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

5 participants