Skip to content
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

feat: Makes ComputeCredential support scopes #2103

Merged
merged 2 commits into from Apr 19, 2022

Conversation

amanda-tarafa
Copy link
Contributor

This is requiered for supporting GKE Workload Identity.

As always, one commit at a time.

@amanda-tarafa amanda-tarafa requested a review from a team as a code owner April 11, 2022 11:34
Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

The binary compatibility part bothers me - I'll need to check that. Otherwise fine.

/// Scopes to request during the authorization grant. May be null or empty.
/// </summary>
/// <remarks>
/// If the scopes are pre-granted through the environement, like in GCE where scopes are granted to the VM,
Copy link
Collaborator

Choose a reason for hiding this comment

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

environement => environment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -153,5 +155,99 @@ public async Task FetchesOidcToken_WithOptions(OidcTokenFormat format, string ta

Assert.Equal(expectedQueryString, messageHandler.LatestRequest.RequestUri.Query);
}

public static IEnumerable<object[]> Scoped_WithDefaultTokenUrl_Data
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use TheoryData?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
else
{
uriBuilder.Query = $"{uriBuilder.Query.Substring(1)}&{scopesQuery}";
Copy link
Collaborator

Choose a reason for hiding this comment

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

So setting the query you don't want the leading "?" (prior to .NET 5), but fetching it you receive it? That sucks so much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's all very "weird", some tests failed and some tests didn't when I first just appended the scopes with the potential & only, until I found those docs with the example. Anyway...

}

public IEnumerable<HttpRequestMessage> Requests { get => _requests; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just public IEnumerable<HttpRequestMessage> Requests => _requests;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

All comments addressed. PTAL

}
else
{
uriBuilder.Query = $"{uriBuilder.Query.Substring(1)}&{scopesQuery}";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's all very "weird", some tests failed and some tests didn't when I first just appended the scopes with the potential & only, until I found those docs with the example. Anyway...

/// Scopes to request during the authorization grant. May be null or empty.
/// </summary>
/// <remarks>
/// If the scopes are pre-granted through the environement, like in GCE where scopes are granted to the VM,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

public IEnumerable<HttpRequestMessage> Requests { get => _requests; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -153,5 +155,99 @@ public async Task FetchesOidcToken_WithOptions(OidcTokenFormat format, string ta

Assert.Equal(expectedQueryString, messageHandler.LatestRequest.RequestUri.Query);
}

public static IEnumerable<object[]> Scoped_WithDefaultTokenUrl_Data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@amanda-tarafa amanda-tarafa merged commit bd80f0a into googleapis:main Apr 19, 2022
@amanda-tarafa amanda-tarafa deleted the compute-scopes branch April 19, 2022 12:34
amanda-tarafa added a commit to amanda-tarafa/google-api-dotnet-client that referenced this pull request Oct 18, 2022
Features
- googleapis#2228 Supports Quota Project environment variable for ADC.
- googleapis#2219 Removes obsolete OOB code.
   BREAKING CHANGE: We have removed OOB support from the library because the feature is not supported by Google OAuth as of October 3rd 2022. See the [official announcement](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob) for more information.
- googleapis#2216 Log errors when trying to reach Compute's metadata server.
- googleapis#2177, googleapis#2197, googleapis#2200, googleapis#2206, googleapis#2215, googleapis#2235 Support for Workload Identity Federation and Worforce Identity Federation.
- googleapis#2103 Compute credentials support explicit scopes.
- googleapis#2096 Improves deserialization error handling.
amanda-tarafa added a commit that referenced this pull request Oct 18, 2022
Features
- #2228 Supports Quota Project environment variable for ADC.
- #2219 Removes obsolete OOB code.
   BREAKING CHANGE: We have removed OOB support from the library because the feature is not supported by Google OAuth as of October 3rd 2022. See the [official announcement](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob) for more information.
- #2216 Log errors when trying to reach Compute's metadata server.
- #2177, #2197, #2200, #2206, #2215, #2235 Support for Workload Identity Federation and Worforce Identity Federation.
- #2103 Compute credentials support explicit scopes.
- #2096 Improves deserialization error handling.
amanda-tarafa added a commit to amanda-tarafa/google-api-dotnet-client that referenced this pull request Nov 30, 2022
And support version: 1.58.0-beta02 => 1.58.0

Bug fixes:

- googleapis#2273 Don't attempt to use an empty/null media type in batch responses
- googleapis#2251 Which fixes a typo on then name of one of the AWS Credential environment variables.
- googleapis#2264 Which adds a missing line break in AWS Credential canonical request.

Features
- googleapis#2269 Support per-request max retry configuration.
- googleapis#2228 Supports Quota Project environment variable for ADC.
- googleapis#2219 Removes obsolete OOB code. BREAKING CHANGE: We have removed OOB support from the library because the feature is not supported by Google OAuth as of October 3rd 2022. See the [official announcement](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob) for more information.
- googleapis#2216 Log errors when trying to reach Compute's metadata server.
- googleapis#2177, googleapis#2197, googleapis#2200, googleapis#2206, googleapis#2215, googleapis#2235 Support for Workload Identity Federation and Worforce Identity Federation.
- googleapis#2103 Compute credentials support explicit scopes.
- googleapis#2096 Improves deserialization error handling.
amanda-tarafa added a commit to amanda-tarafa/google-api-dotnet-client that referenced this pull request Nov 30, 2022
And support version: 1.58.0-beta02 => 1.58.0

Dependencies:

- Client libraries no longer target netstandard1.0 or net40.

Bug fixes:

- googleapis#2273 Don't attempt to use an empty/null media type in batch responses
- googleapis#2251 Which fixes a typo on then name of one of the AWS Credential environment variables.
- googleapis#2264 Which adds a missing line break in AWS Credential canonical request.

Features
- googleapis#2269 Support per-request max retry configuration.
- googleapis#2228 Supports Quota Project environment variable for ADC.
- googleapis#2219 Removes obsolete OOB code. BREAKING CHANGE: We have removed OOB support from the library because the feature is not supported by Google OAuth as of October 3rd 2022. See the [official announcement](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob) for more information.
- googleapis#2216 Log errors when trying to reach Compute's metadata server.
- googleapis#2177, googleapis#2197, googleapis#2200, googleapis#2206, googleapis#2215, googleapis#2235 Support for Workload Identity Federation and Worforce Identity Federation.
- googleapis#2103 Compute credentials support explicit scopes.
- googleapis#2096 Improves deserialization error handling.
amanda-tarafa added a commit that referenced this pull request Nov 30, 2022
And support version: 1.58.0-beta02 => 1.58.0

Dependencies:

- Client libraries no longer target netstandard1.0 or net40.

Bug fixes:

- #2273 Don't attempt to use an empty/null media type in batch responses
- #2251 Which fixes a typo on then name of one of the AWS Credential environment variables.
- #2264 Which adds a missing line break in AWS Credential canonical request.

Features
- #2269 Support per-request max retry configuration.
- #2228 Supports Quota Project environment variable for ADC.
- #2219 Removes obsolete OOB code. BREAKING CHANGE: We have removed OOB support from the library because the feature is not supported by Google OAuth as of October 3rd 2022. See the [official announcement](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob) for more information.
- #2216 Log errors when trying to reach Compute's metadata server.
- #2177, #2197, #2200, #2206, #2215, #2235 Support for Workload Identity Federation and Worforce Identity Federation.
- #2103 Compute credentials support explicit scopes.
- #2096 Improves deserialization error handling.
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.

None yet

2 participants