Skip to content

Add support for service account impersonation #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

andrewnicolalde
Copy link

@andrewnicolalde andrewnicolalde commented May 6, 2025

Superseded by #14

This PR adds support for service account impersonation.

Note: I have not been able to get a binary written to disk so that I can test that these changes produce the desired result. If you have any advice as to how I can do so, that would be much appreciated!

> mage test
ok      github.com/grafana/grafana-google-sdk-go/pkg/tokenprovider      (cached)
?       github.com/grafana/grafana-google-sdk-go/pkg/utils      [no test files]

See also: grafana/google-bigquery-datasource#336

@CLAassistant
Copy link

CLAassistant commented May 6, 2025

CLA assistant check
All committers have signed the CLA.

func (source *impersonatedGceSource) getToken(ctx context.Context) (*oauth2.Token, error) {
tokenSource, err := impersonate.CredentialsTokenSource(ctx, impersonate.CredentialsConfig{
TargetPrincipal: source.TargetPrincipal,
Scopes: []string{"https://www.googleapis.com/auth/cloud-platform.read-only"},
Copy link
Author

@andrewnicolalde andrewnicolalde May 9, 2025

Choose a reason for hiding this comment

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

Perhaps the value of Scopes should actually be cfg.Scopes or source.scopes

@zoltanbedi
Copy link
Member

I'll do some house keeping and then the go.mod changes won't be necessary.

@andrewnicolalde
Copy link
Author

I'll do some house keeping and then the go.mod changes won't be necessary.

Thanks! Feel free to change this PR.

@andrewnicolalde
Copy link
Author

@zoltanbedi Let me know if you have any feedback! Happy to make the requisite changes myself, if there are any 🫡 .

@zoltanbedi
Copy link
Member

Hey @andrewnicolalde,

I checked your branch and did some changes but I still want to verify it and try it out.

@zoltanbedi
Copy link
Member

I'm going to close this one.

@zoltanbedi zoltanbedi closed this May 23, 2025
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.

3 participants