Saturday, 15 June 2013

c# - How to advance the session timeout in ServiceStack -



c# - How to advance the session timeout in ServiceStack -

the authentication, repository , caching providers in servicestack provide simple way add together login sessions web application no additional code. have found session timeout authentication provider can configured, example:

class="lang-cs prettyprint-override">new credentialsauthprovider { sessionexpiry = timespan.fromminutes(10) }

this provides expiry point of login. if developing secure scheme must log user out after short time alter default of 2 weeks illustration above. has problem 10 minutes logging in user kicked out regardless of whether or not still interacting application.

is there simple way tell session provider extend expiry time when services called?

ideally allow extend session specific services/requests (so session extended when user actively interacts application , hence polled services can ignored).

update

based on reply given mythz have simple solution provides level of command require extending responsefilterattribute.

servicestack doesn't back upwards "sliding session expiration" automatically yet. need reset session cache entry on every successful request. i.e. have response filter (since they're executed authenticated requests) re-saves session have effect of extending it's life-time expiry time:

var usersession = httpreq.getsession(); httpreq.savesession(usersession, slidingexpirytimespan);

if know caching provider you're using, e.g. redis can manually update expiry timeout without re-reading entry, e.g:

var sessionkey = sessionfeature.getsessionkey(httpreq.getsessionid()); redis.expireentryin(sessionkey, slidingexpiry); //"urn:iauthsession:{sessionid}"

c# servicestack

No comments:

Post a Comment