Laravel Sentry Auth Expired Time - laravel

How to set expired time for Sentry auth / token?
I Need to set the time to 60 minute or 1 day maybe.
Is it can be set at config? but i don't find the setting for expired time login.

Go to config\session.php.
Change the lifetime value to any number of minutes. Sentry will use that value as its session expiry time.
As per the laravel documentation:
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.

Related

Set different santum token expiration base on user role using laravel

I know I can set sanctum token expiration time in config/sanctum.php but this expiration seems to be global. How can I set a different expiration time base on their role. e.g super admin token should expire after 30 minutes while admin should expire after 15 minute.
While authenticating a user, You can dynamically set 'expiration' key of sanctum configuration based on your user type.
config(['sanctum.expiration' => 525600]);

Is it possible to "lock" a session in Laravel 5.8?

I want to implement a "lock window" function into my application. Is it possible to lock a session and reactivate it?
Case: After x minutes the application will get locked. The user must now type in his password and will be redirected to the former route and logged in again.
In /config/session.php you can set the amount of idle time before the session expires:
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120, // edit this
If you want to include non idle time, you can create some middleware which can auto log-out your user. You can store the time the user logged-in in the session, and in the middleware store your $timeout variable. You can force log-out of an auth user like so:
auth()->logout()
if the time logged in + $timeout has passed.

Session Timeout & Sliding Timeout

I am implementing Identityserver where sliding expiration value is set at client side. So is it secure?
Does asp.net session timeout work in similar way? i.e. client side comparison?
Just need theory about whether session timeout is client side thing or server side thing.
What exactly happens when session timeout. Cookie clear or any server value clear?
Sliding expiration means that each time the session is accessed it will reset the timer back to 20 minutes again.
Also, by default sliding expiration is used so you don't need to write any code.
If the user does not access the session for the timeout period then the session will expire. If the user accesses the session at(for instance) 3:01 then the session will expire at 3:21. If the user accesses the session at 3:10 then the session will then expire at 3:30. It is always 20 minutes after the user last accessed the session (that is the meaning of sliding expiration). If the user does not access the session in that 20 minutes then the session will expire.
Hope the answer gets you a glimpse of sliding expiration...

Express connect session expiry not working as expected

In a web app am developing using express.js am having a problem expiring sessions when a user has not been active for more than 10 minutes. Am using connect-couchdb as the session store.
I tried setting the req.session.cookie.maxAge = 600000. But this causes the session to expire 10 mins after logging in irrespective of user activity. My understanding of the documentation is that req.session.touch() will be called automatically by the connect middleware and hence maxAge (and the expires date) should get refreshed so it lasts another 10 mins, but it is not happening!!
I also tried setting maxAge to 600000 on each request and calling req.session.save() but even then there is no effect.
What am I doing wrong?
You are not doing anything wrong---this is a bug in Connect. The session cookie gets updated in the server, but not pushed to the client, and so the client keeps trying to use the old cookie, which will expire sooner than you want.
More details and discussion here.

delete cookies on session timeout in java

I am developing a java web application in which I have configured session-timeout to be equal to 4 minutes.This application also uses cookies.
My problem is after 4 minutes of inactivity the HttpSession expires but the cookies remain in the browser (age is set to -1). Is there any way to delete cookies after session timeout?
P.S. setting cookie age equal to 4 minutes wont help.cookies should be deleted after 4 minutes of inactivity .
If you set the cookie age to 4 minutes, and reset the cookie age every time your server sends a response, then the cookie will time out after 4 minutes of inactivity.

Resources