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

enhancement(http-client): Add automatic bearer token acquisition in http-client #21023

Conversation

KowalczykBartek
Copy link
Contributor

@KowalczykBartek KowalczykBartek commented Aug 8, 2024

This is the same problem solved but with different approach #21008 . (another idea for #20635.)

@KowalczykBartek KowalczykBartek requested a review from a team as a code owner August 8, 2024 07:24
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Aug 8, 2024
HttpClient::new_with_custom_client(tls_settings, proxy_config, &mut Client::builder(), None)
}

pub fn new_asdasd(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

please don't look at names right now :) I just wanted to make it working end to end :)

@tareksha
Copy link

tareksha commented Sep 8, 2024

hi @jszwedko can you please help with reviewing this contribution?

@jszwedko
Copy link
Member

hi @jszwedko can you please help with reviewing this contribution?

Hey! Yes, apologies for the delay. I'll try to get this reviewed next week.

@tareksha
Copy link

tareksha commented Oct 8, 2024

Hey! Yes, apologies for the delay. I'll try to get this reviewed next week.

hi @jszwedko, a gentle reminder

@pront
Copy link
Member

pront commented Oct 8, 2024

Hi all, thanks for this contribution! FYI I see a conflict and a failing CI check.

token: Arc<Mutex<Option<ExpirableToken>>>
}

impl<B> Clone for OAuth2Extension<B> {
Copy link
Member

Choose a reason for hiding this comment

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

I think you can add #[derive(Clone)] to OAuth2Extension and delete this manual implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pront what I wanted to ask for is more an opinion on the idea/shape for this feature, so I have two
#21008
#21023
If at least one will be ok, I will open new PR will clean code (without a function names like new_asdasd)

Copy link
Member

Choose a reason for hiding this comment

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

👋 Hi @KowalczykBartek, I took a look at both PRs. Can you share a config example for this method? Then we can compare it with this config.

I also think enhancing the http client is preferable since other sinks will benefit from these options. One note here, we want to ensure we are not affecting the existing behavior and that should be easy to do with sensible defaults for the new options.

Copy link
Contributor Author

@KowalczykBartek KowalczykBartek Oct 15, 2024

Choose a reason for hiding this comment

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

@pront both are in this PR, for the first approach its #21008 (comment)

sources:
  my_source_id:
    scrape_interval_secs: 1
    type: http_client
    endpoint: http://127.0.0.1:9898/logs

sinks:
  my_sink_id:
    auth:
      strategy: "o_auth2"
      client_id: "some_client_id"
      client_secret: "client_secret"
      token_endpoint: "https://some.url/oauth/token"
    type: http
    encoding:
      codec: raw_message
    inputs:
      - my_source_id
    uri: http://127.0.0.1:9091/output

so, its sink aware configuration, and second one is one you linked,

sources:
  my_source_id:
    scrape_interval_secs: 1
    type: http_client
    endpoint: http://127.0.0.1:9898/logs

sinks:
  my_sink_id:
    http_client_authorization_strategy:
      auth:
        strategy: "o_auth2"
        client_id: "some_client_id"
        client_secret: "client_secret"
        token_endpoint: "https://some.url/oauth/token"
    type: http
    encoding:
      codec: raw_message
    inputs:
      - my_source_id
    uri: http://127.0.0.1:9091/output
I also think enhancing the http client is preferable since other sinks will benefit from these options

if we can agree on this - I can prepare new PR (without all the mess I introduced - and without the conflict :) ) for this approach

Copy link
Member

Choose a reason for hiding this comment

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

if we can agree on this - I can prepare new PR (without all the mess I introduced - and without the conflict :) ) for this approach

Thank you @KowalczykBartek, sounds good to me 🚀 Please close the PR you don't intend to work on anymore.

Choose a reason for hiding this comment

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

hi. note that in the original issue #20635 i also described the need for a client certificate for the token request that targets the issuer. this is separate from the client certificate that might be configured for the sink's http target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pront I opened not-a-poc PR here #21583 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants