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

[extension/oauth2clientauth] Add EndpointParams #7307

Merged
merged 201 commits into from
Mar 9, 2022

Conversation

tomsanbear
Copy link
Contributor

Description:
Adds support to pass additional token endpoint parameters, in particular support for some oauth providers (in my case Ory Hydra) require the client to request the audience.

Link to tracking Issue: N/A

Testing: Tested on a custom build of the otel collector, in addition to adding unit test coverage.

Documentation: Added description of the endpoint param config in addition to an example in the readme.

@tomsanbear tomsanbear requested a review from a team January 24, 2022 02:23
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 24, 2022

CLA Signed

The committers are authorized under a signed CLA.

@pavankrish123
Copy link
Contributor

@jpkrohling I can take a review for this? Please assign this to me.

@@ -76,6 +76,7 @@ func newClientCredentialsExtension(cfg *Config, logger *zap.Logger) (*ClientCred
ClientSecret: cfg.ClientSecret,
TokenURL: cfg.TokenURL,
Scopes: cfg.Scopes,
EndpointParams: cfg.EndpointParams,
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @tomsanbear. Can you please modify this test case as well https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/oauth2clientauthextension/extension_test.go#L48 in addition to the configuration test you modified. This test is a proper e2e use case.

Everything else LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @pavankrish123 , thanks for the quick review, i've pushed the test up to the branch. Let me know if there is anything else you suggest to add 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you. I have added a minor suggestion on the test. Please add the test and everything else LGTM

@jpkrohling
Copy link
Member

@jpkrohling I can take a review for this? Please assign this to me.

It's yours!

Timeout: 2,
ClientID: "testclientid",
ClientSecret: "testsecret",
EndpointParams: url.Values{"audience": []string{"someaudience"}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add the equivalent assert to test the EndpointParams to complete the test -

assert.Equal(t, test.settings.Timeout, rc.client.Timeout)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have update the test case with the assertion, thanks!

@pavankrish123
Copy link
Contributor

Thank you! @jpkrohling need help in kicking off the rest of the builds and on merge.

@@ -58,6 +60,7 @@ Following are the configuration fields
- [**token_url**](https://datatracker.ietf.org/doc/html/rfc6749#section-3.2) - The resource server's token endpoint URLs.
- [**client_id**](https://datatracker.ietf.org/doc/html/rfc6749#section-2.2) - The client identifier issued to the client.
- [**client_secret**](https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1) - The secret string associated with above identifier.
- [**enndoint_params**](https://github.com/golang/oauth2/blob/master/clientcredentials/clientcredentials.go#L44) - Additional parameters that are sent to the token endpoint.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- [**enndoint_params**](https://github.com/golang/oauth2/blob/master/clientcredentials/clientcredentials.go#L44) - Additional parameters that are sent to the token endpoint.
- [**endpoint_params**](https://github.com/golang/oauth2/blob/master/clientcredentials/clientcredentials.go#L44) - Additional parameters that are sent to the token endpoint.

@jpkrohling jpkrohling changed the title Add EndpointParams to oauth2clientauthentication [extension/oauth2clientauth] Add EndpointParams Jan 28, 2022
@jpkrohling jpkrohling enabled auto-merge (squash) January 28, 2022 18:55
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 12, 2022
@tomsanbear
Copy link
Contributor Author

Anything we can do to get this merged in? CI fails don't seem related

@bogdandrutu
Copy link
Member

would be good to rebase, and ensure test pass.

@github-actions github-actions bot removed the Stale label Feb 15, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2022

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 1, 2022
@tomsanbear
Copy link
Contributor Author

Apologies from the spam as a result of the rebase, PR should be up to date with latest main now.

@github-actions github-actions bot removed the Stale label Mar 2, 2022
@jpkrohling
Copy link
Member

Once you add a changelog entry, the CI should pass and I'll get this merged. Thanks for your patience!

@jpkrohling
Copy link
Member

Sorry, just noticed that the linting is also failing:

golangci-lint run --allow-parallel-runners
extension.go:75: File is not `gofmt`-ed with `-s` (gofmt)
			ClientID:     cfg.ClientID,
			ClientSecret: cfg.ClientSecret,
			TokenURL:     cfg.TokenURL,
			Scopes:       cfg.Scopes,
make[2]: *** [../../Makefile.Common:96: lint] Error 1

@jpkrohling
Copy link
Member

@tomsanbear, sorry to ask this, but the PR seems to have been opened from your main branch: could you please fix the conflict? I'll then merge this on green.

@tomsanbear
Copy link
Contributor Author

@tomsanbear, sorry to ask this, but the PR seems to have been opened from your main branch: could you please fix the conflict? I'll then merge this on green.

@jpkrohling updated!

@jpkrohling jpkrohling merged commit 748a7f4 into open-telemetry:main Mar 9, 2022
ZahidMirza95 pushed a commit to ZahidMirza95/opentelemetry-collector-contrib that referenced this pull request Jun 21, 2023
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.