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

SetCustomHeaders/WithCustomHeaders seems broken #236

Closed
nyxi opened this issue Sep 25, 2023 · 2 comments · Fixed by #237
Closed

SetCustomHeaders/WithCustomHeaders seems broken #236

nyxi opened this issue Sep 25, 2023 · 2 comments · Fixed by #237

Comments

@nyxi
Copy link

nyxi commented Sep 25, 2023

Expected Behavior

Custom headers added with SetCustomHeaders should be added to all requests made with the client.

Current Behavior

The custom headers added with SetCustomHeaders are not added to requests made with the client.

Failure Information

vault-client-go 0.4.0

Steps to Reproduce

package main

import (
        "context"
        "fmt"
        "log"
        "net/http"

        "github.com/hashicorp/vault-client-go"
        "github.com/hashicorp/vault-client-go/schema"
)

func handler(w http.ResponseWriter, r *http.Request) {
        fmt.Printf("Accept-Encoding: %s\n", r.Header.Get("accept-encoding"))
        fmt.Printf("Amazing: %s\n", r.Header.Get("amazing"))
}

func listen() {
        http.HandleFunc("/", http.HandlerFunc(handler))
        http.ListenAndServe(":9393", nil)
}

func main() {
        go listen()
        // Get a Vault client
        client, _ := vault.New(
                vault.WithAddress("http://localhost:9393"),
        )

        headers := make(http.Header)
        headers.Set("amazing", "very")
        err := client.SetCustomHeaders(headers)
        if err != nil {
                log.Fatalln(err)
        }

        _, _ = client.Auth.JwtOidcRequestAuthorizationUrl(
                context.Background(),
                schema.JwtOidcRequestAuthorizationUrlRequest{
                        RedirectUri: "http://localhost:9393/oidc/callback",
                        Role:        "default_role",
                },
                vault.WithCustomHeaders(headers),
        )
}
@averche
Copy link
Collaborator

averche commented Sep 27, 2023

Hi @nyxi, thanks for reporting this bug!

Somehow the wiring was never done for custom headers. I believe I have a fix for this in #237

@averche
Copy link
Collaborator

averche commented Sep 27, 2023

Fixed and released in 0.4.1. Thanks again!

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