Skip to content

Commit

Permalink
LP2034956: Check authtoken validity more frequently
Browse files Browse the repository at this point in the history
Just hard-code the validity check to 3 minutes. Since the timer will start
at an essentially random time for each tab there shouldn't be much threat of
overwhelming the auth service with this relatively fast call.

This should help keep staff authtokens "fresher" in memcached until lp 1753565
is addressed.

Release-note: Check the staff client authentication session every three minutes, reducing chances of hidden eviction of the session

Co-authored-by: Galen Charlton <[email protected]>
Signed-off-by: Jason Boyer <[email protected]>
Signed-off-by: Galen Charlton <[email protected]>
Signed-off-by: Mike Rylander <[email protected]>
  • Loading branch information
2 people authored and spaceisntsyntax committed Sep 13, 2024
1 parent 8bc3308 commit fd93448
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
16 changes: 4 additions & 12 deletions Open-ILS/src/eg2/src/app/core/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,10 @@ export class AuthService {
*/
sessionPoll(): void {

// add a 5 second delay to give the token plenty of time
// to expire on the server.
let pollTime = this.authtime() * 1000 + 5000;

if (pollTime < 60000) {
// Never poll more often than once per minute.
pollTime = 60000;
} else if (pollTime > 2147483647) {
// Avoid integer overflow resulting in $timeout() effectively
// running with timeout=0 in a loop.
pollTime = 2147483647;
}
// Check every 3 minutes. This still won't reset the authtoken timeout
// but it WILL reset the memcached LRU for the authtoken so staff authtokens
// are less likely to be evicted.
const pollTime = 60 * 1000 * 3;

this.pollTimeout = setTimeout(() => {
this.net.request(
Expand Down
16 changes: 4 additions & 12 deletions Open-ILS/web/js/ui/default/staff/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,10 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch , $i
}
}

// add a 5 second delay to give the token plenty of time
// to expire on the server.
var pollTime = service.authtime() * 1000 + 5000;

if (pollTime < 60000) {
// Never poll more often than once per minute.
pollTime = 60000;
} else if (pollTime > 2147483647) {
// Avoid integer overflow resulting in $timeout() effectively
// running with timeout=0 in a loop.
pollTime = 2147483647;
}
// Check every 3 minutes. This still won't reset the authtoken timeout
// but it WILL reset the memcached LRU for the authtoken so staff authtokens
// are less likely to be evicted.
var pollTime = 60 * 1000 * 3;

$timeout(
function() {
Expand Down

0 comments on commit fd93448

Please sign in to comment.