-
Notifications
You must be signed in to change notification settings - Fork 18
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
Session config #158
Session config #158
Conversation
…rapper into sessionConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is repeated:
sessionCache = SessionCache(sessionCacheDuration, TimeUnit.MINUTES);
sessionCache.setExpirationAfterAccess(true);
validationService = ValidationService(sessionCache);
I think it would be better to encapsulate this into a function that returns a ValidationService and keeps sessionCache and sessionCacheDuration only in the scope of that function. I can't see a reason to keep references to those instances.
fun createValidationServiceInstance() : ValidationService {
val sessionCacheDuration = System.getenv("SESSION_CACHE_DURATION")?.toLong() ?: SESSION_DEFAULT_DURATION;
val sessionCache = SessionCache(sessionCacheDuration, TimeUnit.MINUTES);
sessionCache.setExpirationAfterAccess(true);
return ValidationService(sessionCache);
}
@rpassas this looks good to me, thank you! I will release this after core gets a new release. |
Summary
Original thread here.
Allowing configurable session expiration by initializing a
ValidationService
in the wrapper with:sessionCacheDuration
(60 minutes by default)setExpirationAfterAccess
(whentrue
, accessing sessions will reset the expiration time)The required changes to core are reflected here.