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

Support for EndpointParams for HTTP Output OAuth2's ClientCredentials auth config #7847

Closed
jcortega opened this issue Jul 16, 2020 · 3 comments · Fixed by #12821
Closed

Support for EndpointParams for HTTP Output OAuth2's ClientCredentials auth config #7847

jcortega opened this issue Jul 16, 2020 · 3 comments · Fixed by #12821
Assignees
Labels
help wanted Request for community participation, code, contribution size/s 1 day effort, great beginniner issue

Comments

@jcortega
Copy link

Feature Request

Some OAuth2 identity service such as Auth0 requires audience parameter when requesting token from their token endpoint. An example of token request call be found here (also posted below in case the link breaks). Currently, the http output plugin does not support additional parameters such as the above.

curl --request POST \
  --url 'https://YOUR_DOMAIN/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data client_id=YOUR_CLIENT_ID \
  --data client_secret=YOUR_CLIENT_SECRET \
  --data audience=YOUR_API_IDENTIFIER

Proposal:

Add token_endpoint_parameters to http output plugin config that will accept key-value pair for additional ClientCredentials token request parameter.

For example:

[[outputs.http]]
  url="https://myendpoint/metrics"
  client_id="myclientid"
  client_secret="myclientsecret"
  token_url="https://mytenant.auth0.com/oauth/token"
  data_format="json"
  scopes=["write:telemetry"]
  [outputs.http.headers]
    Content-Type="application/json"
  [output.http.token_endpoint_parameters]
      audience="https://myaudience.cascadeo.io"

The parameters would then be passed to clientcredentials.Config as EndpointParameter.

Current behavior:

HTTP output plugin does not accept additional token endpoint parameter.

Desired behavior:

HTTP output plugin should accept additional token endpoint parameter such as audience, which is used by Auth0.

Use case:

This adds support to users using Auth0 to protect their HTTP endpoint, and other auth provider that requires additional parameters on token request.

@jcortega jcortega changed the title Support for EndpointParams for HTTP Output OAuth2 ClientCredentials Authentication Support for EndpointParams for HTTP Output OAuth2's ClientCredentials auth config Jul 16, 2020
@powersj
Copy link
Contributor

powersj commented Mar 22, 2022

next steps: look into adding map config option for data parameters in a generic way

@powersj powersj added the help wanted Request for community participation, code, contribution label Mar 22, 2022
@reimda
Copy link
Contributor

reimda commented Aug 4, 2022

Hi @jcortega are you able to put together a PR to implement this or are you still available to test it?

I think telegraf's existing OAuth2Config struct (in plugins/common/http/config.go) could be extended with another field for audience. Then we would need to change the CreateOauth2Client function to pass the audience to the x/oauth2 code.

It seems like x/oauth2 expects the audience in its EndpointParams config. I couldn't quickly find docs on how to do it, but here's the commit that adds this functionality to the x/oauth2 module. It has unit tests that show how to use it:
golang/oauth2@01b79d9

@reimda reimda added the size/s 1 day effort, great beginniner issue label Aug 4, 2022
@srebhan srebhan self-assigned this Mar 9, 2023
@srebhan
Copy link
Member

srebhan commented Mar 9, 2023

@jcortega can you please test the binary built in PR #12821 after CI finished the tests? Let me know if this fixes the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Request for community participation, code, contribution size/s 1 day effort, great beginniner issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants