Skip to content

Commit

Permalink
Auth: Prevent scheduled token rotation jobs with large delay from rol…
Browse files Browse the repository at this point in the history
…ling back to 1 ms (grafana#93242)

Auth: prevent scheduled token rotation jobs with large delay from rolling back to 1 ms
  • Loading branch information
colin-stuart authored Sep 12, 2024
1 parent 03c4884 commit 04d9fa0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions public/app/core/services/context_srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ export class ContextSrv {
// to distribute the scheduling of the job. For now this can be between 1 and 20 seconds
const expiresWithDistribution = expires - Math.floor(Math.random() * (20 - 1) + 1);

// nextRun is when the job should be scheduled for
let nextRun = expiresWithDistribution * 1000 - Date.now();

// nextRun is when the job should be scheduled for in ms. setTimeout ms has a max value of 2147483647.
let nextRun = Math.min(expiresWithDistribution * 1000 - Date.now(), 2147483647);
// @ts-ignore
this.tokenRotationJobId = setTimeout(() => {
// if we have a new expiry time from the expiry cookie another tab have already performed the rotation
Expand Down

0 comments on commit 04d9fa0

Please sign in to comment.