-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Auto sign-out #4107
Comments
can someone tell me about the DB structure and a bit of the API documentation? my plan to implement this is to store the last-login-time and log-out-after data in the db and check if the curr-time subracted from the last-login time is greater than the log-out-after time and log out the user based on that. we can add the UI for setting the "log out after time" in the preferences page. |
@JodhwaniMadhur I think the point of this issue is to make the access token duration configurable, which is now 1 week by default. https://github.com/usememos/memos/blob/main/server/router/api/v1/auth.go#L18 |
oh ok, thanks for the guidance, will make the feature work this way. |
To add to @johnnyjoygh 's comment. I believe there are 2 places to take into consideration. At registration the expiry is set to 7 days in the future, subsequent logins set the expiry 1 year in the future. |
I found the reference to the two locations #4009 (comment) |
@JodhwaniMadhur, out of interest, how are you intending to capture a large range of expiry possibilities? Current expiry is in days (multiplied for years), OP seems like they need expiry in minutes |
I was thinking along the lines of store the time in db and check if every time they access the site that it is valid or not and log them out based on that, and every time the user logs in/ does access the site, we reset it for the time they set in preferences and have a 1-60 mins timer option for auto log out. same could be done for access token, like refresh it every time the person logs in and log them out if it isn't valid. However, I need to deep dive in the code to see if I can fit it in properly or not. |
ok, i saw the code and i don't think we pass the acess token to the frontend, do we? there is no way to edit it's attributes or the expireAt setting in the frontend, isn't it? I feel we need to create a Also, will need to create an API for the same to update this in the database frequently. Also, I will need some help with the proto file to create the API for this. Does this sound good? |
The access token is passed to the FE on signin and is stored in a cookie. Creating new tokens are done on the BE in I believe there is a simpler way using the existing mechanisms of Memos to achieve OPs goal. The idea is:
|
THANKS for the response first of all. my concern is wouldn't this be client heavy and not so reliable with only frontend. I am not sure of the scenario where in say auto_signout_mins have passed but due to SSO, cookies, user is still able to login. Plus wouldn't this be client heavy and be easily cheated with? But again this is a tradeoff situation. I am pro-DB, like have another column in the user table which has session-timeout and we read from it on every access and decide whether to let the user go in or not. I certainly understand that DB reads and writes are expensive but again, as I said, it is a tradeoff between security and time. |
The reasons I suggested tracking changes on the FE were:
Adding the FE and db storage options together could look as follows:
|
not the auth token but my original approach of saving just the number_of_mins as a field in the db, periodically check for activity and if not done till x mins. then log out. no need to hamper the access token in any scenario |
any updates on what solution I should proceed with? |
Discussed in https://github.com/orgs/usememos/discussions/4075
Originally posted by rathmannm October 31, 2024
Hi,
I'm storing sensitive contents in Memos so it would be nice to have an auto sign-out feature where you can specify after how many minutes you get signed out automatically.
The text was updated successfully, but these errors were encountered: