@@ -22,6 +22,9 @@ namespace {
2222// This handles concurrent access from multiple threads/processes
2323constexpr int SQLITE_BUSY_TIMEOUT_MS = 5000 ;
2424
25+ // Default time before expiry when next_update should occur (4 hours)
26+ constexpr int64_t DEFAULT_NEXT_UPDATE_OFFSET_S = 4 * 3600 ;
27+
2528void initialize_cachedb (const std::string &keycache_file) {
2629
2730 sqlite3 *db;
@@ -257,7 +260,7 @@ bool scitokens::Validator::get_public_keys_from_db(const std::string issuer,
257260 sqlite3_close (db);
258261 iter = top_obj.find (" next_update" );
259262 if (iter == top_obj.end () || !iter->second .is <int64_t >()) {
260- next_update = expiry - 4 * 3600 ;
263+ next_update = expiry - DEFAULT_NEXT_UPDATE_OFFSET_S ;
261264 } else {
262265 next_update = iter->second .get <int64_t >();
263266 }
@@ -406,7 +409,7 @@ scitokens::Validator::get_all_issuers_from_db(int64_t now) {
406409 if (next_update_iter == top_obj.end () ||
407410 !next_update_iter->second .is <int64_t >()) {
408411 // If next_update is not set, default to 4 hours before expiry
409- next_update = expiry - 4 * 3600 ;
412+ next_update = expiry - DEFAULT_NEXT_UPDATE_OFFSET_S ;
410413 } else {
411414 next_update = next_update_iter->second .get <int64_t >();
412415 }
@@ -516,7 +519,7 @@ std::string scitokens::Validator::get_jwks_metadata(const std::string &issuer) {
516519 next_update = iter->second .get <int64_t >();
517520 } else if (expires != -1 ) {
518521 // Default next_update to 4 hours before expiry
519- next_update = expires - 4 * 3600 ;
522+ next_update = expires - DEFAULT_NEXT_UPDATE_OFFSET_S ;
520523 }
521524
522525 // Build metadata JSON
0 commit comments