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

Session config #158

Merged
merged 7 commits into from
Dec 18, 2023
Merged

Session config #158

merged 7 commits into from
Dec 18, 2023

Conversation

rpassas
Copy link
Member

@rpassas rpassas commented Nov 28, 2023

Summary

Original thread here.
Allowing configurable session expiration by initializing a ValidationService in the wrapper with:

  • configurable sessionCacheDuration (60 minutes by default)
  • ability to setExpirationAfterAccess (when true, accessing sessions will reset the expiration time)

The required changes to core are reflected here.

Copy link
Collaborator

@dotasek dotasek left a 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 rpassas requested a review from dotasek December 8, 2023 20:12
@dotasek dotasek merged commit 662990e into master Dec 18, 2023
5 checks passed
@dotasek
Copy link
Collaborator

dotasek commented Dec 18, 2023

@rpassas this looks good to me, thank you! I will release this after core gets a new release.

@rpassas rpassas deleted the sessionConfig branch December 19, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants