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

[Request] Make session support issuing and validating #1199

Closed
zheeeng opened this issue Feb 18, 2019 · 5 comments
Closed

[Request] Make session support issuing and validating #1199

zheeeng opened this issue Feb 18, 2019 · 5 comments

Comments

@zheeeng
Copy link

zheeeng commented Feb 18, 2019

At present, no matter whether a user is signed or not, the session manager will always start a session for the context, we can only check user status by some session fields. It seems that the session provider is easy to be overwhelmed by meanless requests.

Can we only issue the session after login and validate the session by checking provider?

For issuing session, we have had the ability(check user and password then start a session). But we can't distinguish whether the user is logged in(generally we always start a session, if it is a fake user session, at present iris will create a one for this user).

@kataras
Copy link
Owner

kataras commented Feb 19, 2019

I don't understand the question, how you will check "if user is logged in" if you don't check the session? You want something like SessionExists(ctx).. to check only if the cookie is present in order to validate the "is logged in"? If that's the case then it is easy to add a method like this.

@zheeeng
Copy link
Author

zheeeng commented Feb 19, 2019

Yeah,SessionExists is what I want. I mean issuing is create and release a session ID to an authenticated user, and block a user without session ID or has no the correct session ID

@zheeeng
Copy link
Author

zheeeng commented Feb 19, 2019

@kataras There is one more request that can we create the session ID by myself, or let us be able to retrieve a session ID by user ID? I need a way to kick off some online users.

If we can create a session ID by myself, I could destroy the sessions which have a specific pattern, e.g. userIdXXX-radomXXX.

if we can add a user ID to mark a session ID, we can also retrieve the sessions belong to a specific user and destroy these sessions.

@kataras
Copy link
Owner

kataras commented Feb 20, 2019

Hello @zheeeng , sorry for the delay. Let me answer those questions...

There is one more request that can we create the session ID by myself?

Yes, take a look at the sessions/Config#SessionIDGenerator

f we can create a session ID by myself, I could destroy the sessions which have a specific pattern, e.g. userIdXXX-radomXXX.

Yes, you can destroy a session by its ID. Take a look at the sessions/Sessions#DestroyByID

I am working on some websocket improvements and a new library for all gophers as well. Tell me more about your idea(maybe share a pseuto code snippet?) and I will make my bests to fulfill your needs at the upcoming version.

Yours,
Gerasimos Maropoulos

@zheeeng
Copy link
Author

zheeeng commented Feb 20, 2019

Thx a lot.

@kataras kataras closed this as completed Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants