Skip to content

impl(auth): Integrate service account with token cache#1628

Merged
sai-sunder-s merged 1 commit intogoogleapis:mainfrom
sai-sunder-s:tokencachesa
Mar 27, 2025
Merged

impl(auth): Integrate service account with token cache#1628
sai-sunder-s merged 1 commit intogoogleapis:mainfrom
sai-sunder-s:tokencachesa

Conversation

@sai-sunder-s
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.71%. Comparing base (60e5a14) to head (4524f8f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1628   +/-   ##
=======================================
  Coverage   95.71%   95.71%           
=======================================
  Files          43       43           
  Lines        1821     1822    +1     
=======================================
+ Hits         1743     1744    +1     
  Misses         78       78           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sai-sunder-s sai-sunder-s enabled auto-merge (squash) March 27, 2025 01:04
let captures = re.captures(&token.token).unwrap();

let claims = b64_decode_to_json(captures["claims"].to_string());
let first_iat = claims["iat"].as_f64().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: here and below, as_i64() seems more appropriate, even though all json numbers are floats

https://docs.rs/time/latest/src/time/serde/timestamp/mod.rs.html#24
https://docs.rs/time/latest/src/time/offset_date_time.rs.html#452

Comment on lines +406 to +407
// Need real sleep because iat is not built using tokio::time::Instant.
// Need 1 second sleep because OffsetDateTime's granularity is seconds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe:

        // The `iat` claim encodes the unix timestamp, in seconds. Sleeping for
        // one second ensures that a subsequent claim has a different `iat`. We
        // need a real sleep, because we cannot fake the current unix timestamp.

let claims = b64_decode_to_json(captures["claims"].to_string());
let second_iat = claims["iat"].as_f64().unwrap();

// Validate that the issued at claim is exactly same for the 2 tokens.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/exactly/the/

@sai-sunder-s sai-sunder-s merged commit dae1606 into googleapis:main Mar 27, 2025
20 checks passed
@dbolduc
Copy link
Member

dbolduc commented Mar 27, 2025

oops, I did not notice the automerge

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.

2 participants