Skip to content

Feature: Add Basic Authentication Support #28

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

Merged
merged 2 commits into from
Apr 17, 2025

Conversation

AH-dark
Copy link
Contributor

@AH-dark AH-dark commented Apr 13, 2025

Summary

This PR adds support for HTTP Basic Authentication in the ClientBuilder and Client structures of the dxr_client crate.

It allows users to connect to XML-RPC endpoints that require a username and password, without manually customizing the underlying reqwest::Client.


What's Changed

  • Added username and password fields to ClientBuilder and Client.
  • Introduced a builder method:
    pub fn basic_auth(mut self, username: String, password: String) -> Self
  • Updated Client::with_client to accept optional authentication credentials.
  • In Client::call, added logic to apply .basic_auth(...) to reqwest::RequestBuilder when credentials are provided.

Motivation

Some enterprise or internal XML-RPC APIs are protected with Basic HTTP Authentication. This patch provides first-class support to enable seamless integration with such systems.

@decathorpe
Copy link
Member

Thanks for your PR!

I'm not sure if I actually want the builtin reqwest client to grow more featureful. Both the reqwest client and the axum server are intended to be minimal "getting started" implementations. Though I suppose this is a very simple feature to add since it just adds a few lines of code ...

There are some potential issues with the code that I see, I'll leave those as inline reviews.

…asic_auth` constructor, use `self.password.as_ref()`
@AH-dark AH-dark requested a review from decathorpe April 14, 2025 18:17
@decathorpe
Copy link
Member

Thank you, looks good to me now!

Do you need a new release with these changes?

@decathorpe decathorpe merged commit 8f1da24 into ironthree:main Apr 17, 2025
5 checks passed
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.

2 participants