pfzetto / axum-oidc

A OpenID Connect Client Libary for axum
https://crates.io/crates/axum-oidc
22 stars 7 forks source link

Support for self-signed certificates #12

Closed heimmat closed 5 months ago

heimmat commented 6 months ago

My OIDC server uses a certificate signed by a custom CA which needs to be trusted by my application. That currently seems to be impossible with your crate. My understanding is that client discovery is the only time my application will directly contact the OIDC server. So if there was a way to pass a custom http client function instead of the hardcoded openidconnect::reqwest::async_http_client

impl<AC: AdditionalClaims> OidcClient<AC> {
    pub async fn discover_new(
    // ...
    ) {
        let provider_metadata =
            ProviderMetadata::discover_async(IssuerUrl::new(issuer)?, async_http_client).await?;
            // ...
   }
}

my problem could be solved by copying the openidconnect code and adding builder options importing the certificate.

Another option might be providing a OidcClient::new constructor which accepts already discovered ProviderMetadata.

Got any pointers for me how you would implement that?

pfzetto commented 6 months ago

Hello, I've added new constructors to OidcClienton master in c9f63180b3aa49a0be336c012bfa14477f4fb6aa. These functions will be included on the next minor release.

They alllow you to provide a reqwest::Client or ProviderMetadata to build a OidcClient.

Let me know if they help in your situation.

Paul

heimmat commented 5 months ago

Wow, thanks Paul! This looks promising. When do you plan to publish to crates.io?

pfzetto commented 5 months ago

I'm not sure. I think that I will wait a bit longer until I have some more changes. You can always use the Cargo Git Dependency.

heimmat commented 5 months ago

That's what I ended up doing and it worked like a charm. Thanks again, Paul!