Skip to content

Commit

Permalink
Merge pull request #123 from azaurus1/122-hotfix---handle-lowercase-a…
Browse files Browse the repository at this point in the history
…uth-type

added lowercase check, and notification of using basic auth
  • Loading branch information
azaurus1 authored Mar 27, 2024
2 parents b4bc29f + 6ebebc5 commit 7ae436e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"os"
"strings"
)

const controllerUrl = "controllerUrl"
Expand Down Expand Up @@ -137,15 +138,16 @@ func validateOpts(opts ...Opt) (*cfg, *url.URL, error) {
}
// if auth token passed, handle authenticated requests
if optCfg.authToken != "" {
switch optCfg.authType {
case "Bearer":
switch strings.ToLower(optCfg.authType) {
case "bearer":
optCfg.httpAuthWriter = func(req *http.Request) {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", optCfg.authToken))
}
default:
optCfg.httpAuthWriter = func(req *http.Request) {
req.Header.Set("Authorization", fmt.Sprintf("Basic %s", optCfg.authToken))
}
fmt.Println("auth type not supported, defaulting to basic auth")
}
}

Expand Down

0 comments on commit 7ae436e

Please sign in to comment.