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

The DefaultHyperClient does not support http - Issue with metadata server authentication #179

Open
pseguin2011 opened this issue May 26, 2022 · 1 comment

Comments

@pseguin2011
Copy link

pseguin2011 commented May 26, 2022

When using the InstanceMetadata authentication, the default hyper client only enforces https, and the call to the metadata server fails (returning the following error: Token retrieval failed with error: error trying to connect: Unsupported scheme http)

My current solution is to simply create a custom client as seen below:

    match yup_oauth2::ApplicationDefaultCredentialsAuthenticator::with_client(
        opts,
        hyper::Client::builder().build(
            hyper_rustls::HttpsConnectorBuilder::new()
                .with_native_roots()
                .https_or_http()
                .enable_http1()
                .enable_http2()
                .build(),
        ),
    )
    .await
    {
        yup_oauth2::authenticator::ApplicationDefaultCredentialsTypes::InstanceMetadata(
            auth_builder,
        ) => {
            Ok(auth_builder.build().unwrap())
        }
        yup_oauth2::authenticator::ApplicationDefaultCredentialsTypes::ServiceAccount(auth_builder) => {
            Ok(auth_builder.build().await.unwrap())
            }
    }
@dermesser
Copy link
Owner

We had a discussion about this some time ago, the argument in favor of the current state was that HTTPS should (obviously) be preferred and thus enforced. However, I definitely see the problem of this case.

I am commenting more on the PR

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 a pull request may close this issue.

2 participants