fix(gsm): support user (authorized_user) ADC via the official google-cloud SDK#323
Open
suzak wants to merge 1 commit into
Open
fix(gsm): support user (authorized_user) ADC via the official google-cloud SDK#323suzak wants to merge 1 commit into
suzak wants to merge 1 commit into
Conversation
…cloud SDK Replace the `google-secretmanager1` (google-apis-rs) + `yup-oauth2` stack with the official Google Cloud SDK crates `google-cloud-secretmanager-v1` and `google-cloud-gax`. The previous client authenticated only with service-account keys. When `GOOGLE_APPLICATION_CREDENTIALS` pointed at (or ADC fell back to) the `authorized_user` credentials written by `gcloud auth application-default login`, it failed with `Bad service account key: missing field 'private_key'`. The official `google-cloud-auth` ADC resolver handles authorized_user, service-account, impersonated and external accounts, and the metadata server out of the box, so the manual `resolve_auth` wiring is no longer needed. Other changes: - NOT_FOUND detection now uses `err.http_status_code() == Some(404)` instead of string-matching the error's Display. - Drop the internal `get_hub` seam that leaked the backend hub type. The change is contained to the `google_secretmanager` provider; the `Provider` trait, the registry and the other providers are untouched.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #322.
What
Replace the
google_secretmanagerprovider's backend —google-secretmanager1(google-apis-rs) +yup-oauth2— with Google's official SDK cratesgoogle-cloud-secretmanager-v1andgoogle-cloud-gax.Why
The old client authenticated only with service-account keys. With
gcloud auth application-default login(user /authorized_usercredentials) andGOOGLE_APPLICATION_CREDENTIALSset, it failed withBad service account key: missing field 'private_key'(see #322).google-cloud-auth's ADC resolver handlesauthorized_user, service-account, impersonated / external accounts and the metadata server out of the box, so the manualresolve_authwiring is no longer needed.Changes
resolve_auth(); build the client withSecretManagerService::builder().build().await(ADC resolved automatically).access_secret_version,list_secrets(viaItemPaginator),get_secret,create_secret,add_secret_version,delete_secret.putNOT_FOUND detection now useserr.http_status_code() == Some(404)instead of string-matching the error'sDisplay.get_hubseam that leaked the backend hub type; theGSMtrait keeps thelist/get/put/delvalue-level seam (and its in-memoryMockClient).google-secretmanager1+crc32c→google-cloud-secretmanager-v1+google-cloud-gax(google-cloud-authis pulled in transitively).Transport is HTTP/REST (reqwest) via
gaxi; no gRPC/tonic is added for this crate.Testing
cargo check -p teller-providers— green.GOOGLE_APPLICATION_CREDENTIALSset to the user ADC file (the exact case that failed before):teller showandteller runnow resolve secrets successfully.sanity_testunchanged.Notes
google_secretmanagerprovider; theProvidertrait, the registry and the other providers are untouched.google_secretmanagerfeature specifically — flagging in case that matters.teller-core/src/exec.rsusesduct::cmd(Path::new(first), rest), which treats the program as a literal path, soteller run -- <bare-cmd>fails to resolve it viaPATH(No such file or directory). Passingfirst(a&str) instead letsductdo thePATHlookup. Happy to send this as a separate PR.