Skip to content

feat(auth): support universe domain for service account creds#5248

Open
alvarowolfx wants to merge 2 commits intogoogleapis:mainfrom
alvarowolfx:feat-auth-service-account-universe-domain
Open

feat(auth): support universe domain for service account creds#5248
alvarowolfx wants to merge 2 commits intogoogleapis:mainfrom
alvarowolfx:feat-auth-service-account-universe-domain

Conversation

@alvarowolfx
Copy link
Copy Markdown
Collaborator

Towards #3646

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.02%. Comparing base (5aad976) to head (9438807).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5248   +/-   ##
=======================================
  Coverage   98.01%   98.02%           
=======================================
  Files         214      214           
  Lines       44703    44744   +41     
=======================================
+ Hits        43817    43859   +42     
+ Misses        886      885    -1     

☔ 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.

@alvarowolfx alvarowolfx marked this pull request as ready for review April 2, 2026 17:25
@alvarowolfx alvarowolfx requested review from a team as code owners April 2, 2026 17:25
Comment on lines +280 to +284
/// # let config = json!({
/// # "type": "service_account",
/// # "client_email": "foo@bar.com",
/// # "private_key": "---BEGIN---"
/// # });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: this could just be json!({}) if we are hiding it.

let credentials = Builder::new(json_value).build()?;

let universe_domain = credentials.universe_domain().await;
assert_eq!(universe_domain, None, "{universe_domain:?}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: no need for the extra printing when using assert_eq!. It only adds value for like assert!(universe_domain.is_none(), "{universe_domain:?}");

here and below.

/// .build()?;
/// # Ok(()) }
/// ```
pub fn with_universe_domain<S: Into<String>>(mut self, universe_domain: S) -> Self {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment: hmm, if we can override things with a builder function, why can't we override things with the GOOGLE_CLOUD_UNIVERSE_DOMAIN env var?

w/e. Not my spec.


/// Sets the universe domain for this credentials.
///
/// The universe domain is the default service domain for a given cloud universe.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I don't think "default" is correct.

I asked Gemini to rewrite this and it spat out:

/// Sets the Google Cloud universe domain for these credentials.
///
/// A "universe" is an isolated Google Cloud environment, such as the public 
/// cloud or a sovereign/air-gapped deployment (e.g., Google Distributed Cloud). 
/// The universe domain acts as the base URL for constructing API endpoints 
/// within that environment.
///
/// By default, this is set to `googleapis.com`. You should only override this 
/// if your application is operating within a custom Cloud universe and needs 
/// to direct authentication and service requests to a different base endpoint.

Consider taking any pieces of that that look good.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, #5259.

Maybe this should be the documentation for the Credentials::universe_domain accessor, and here we just say "override the value" without needing to explain what is a universe.

@dbolduc dbolduc changed the title impl(auth): read and allow overrides of universe_domain for Service Accounts feat(auth): support universe domain for service account creds Apr 3, 2026
@dbolduc
Copy link
Copy Markdown
Member

dbolduc commented Apr 3, 2026

Also, double check the title. The builder option is public, so this should be a feat. If we are missing pieces of the implementation and the title is inaccurate (1) sorry, (2) please fix it :)

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