You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flowchart LR
S["Scheduled auth refresh"]:::node
DB["DB: most recent auth"]:::node
R["Redis: auth token (4h TTL)"]:::node
P["Playwright: steal new cookie"]:::node
M["Update in-memory cookie/csrf"]:::node
S -- "check token freshness" --> DB
DB -- "fresh" --> M
DB -- "missing/expired" --> R
R -- "hit" --> M
R -- "miss" --> P
P -- "persist to DB + Redis" --> DB
P -- "set cookie/csrf" --> M
classDef node fill:#eef,stroke:#889;
The code uses tryLock() without checking its return value and still proceeds to unlock in the finally block. This can throw IllegalMonitorStateException and break the scheduled job. Use lock() or guard unlock() based on the acquisition result.
LOCK.writeLock().tryLock();
try {
AuthmostRecentAuth = authRepository.getMostRecentAuth();
// The auth token should be refreshed every 4 hours.if (mostRecentAuth != null
&& mostRecentAuth
.getCreatedAt()
.isAfter(StandardizedOffsetDateTime.now().minus(4, ChronoUnit.HOURS))) {
log.info("Auth token already exists, using token from database.");
cookie = mostRecentAuth.getToken();
csrf = mostRecentAuth.getCsrf();
return;
}
log.info("falling back to checking redis client...");
Optional<String> authToken = redisClient.getAuth();
log.info("auth token in redis = {}", authToken.isPresent());
if (authToken.isPresent()) {
log.info("auth token found in redis client");
cookie = authToken.get();
csrf = null; // don't care in ci.return;
}
log.info("auth token not found in redis client");
log.info("Auth token is missing/expired. Attempting to receive token...");
stealCookieImpl();
} finally {
When a valid DB token is found, it returns without caching it in Redis. This may violate the AC to cache all auth keys and undermines fallback if the DB is wiped before a fresh steal. Consider setting the Redis key (with 4h TTL) when using a DB-sourced token.
if (mostRecentAuth != null
&& mostRecentAuth
.getCreatedAt()
.isAfter(StandardizedOffsetDateTime.now().minus(4, ChronoUnit.HOURS))) {
log.info("Auth token already exists, using token from database.");
cookie = mostRecentAuth.getToken();
csrf = mostRecentAuth.getCsrf();
return;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
716
Description of changes
Checklist before review
Screenshots
Local
Staging