Skip to content

Commit

Permalink
add client header in requests (#229)
Browse files Browse the repository at this point in the history
Signed-off-by: Nandor Kracser <[email protected]>
  • Loading branch information
bonifaido committed Apr 21, 2020
1 parent cb66a1f commit db5ed5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func (c curlRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {

log.Debug(command.String())

r.Header.Add("Client", "banzai-cli")

return c.base.RoundTrip(r)
}

Expand Down
9 changes: 4 additions & 5 deletions internal/cli/command/login/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,12 @@ func (a *app) requestTokenFromPipeline(rawIDToken string, refreshToken string) (
return "", fmt.Errorf("request returned: %s", string(body))
}

for _, cookie := range resp.Cookies() {
if cookie.Name == "user_sess" {
return cookie.Value, nil
}
sessionToken := resp.Header.Get("Authorization")
if sessionToken != "" {
return sessionToken, nil
}

return "", fmt.Errorf("failed to find user_sess cookie in Pipeline response")
return "", fmt.Errorf("failed to find Authorization header in Pipeline response")
}

func (a *app) waitShutdown(server *http.Server) {
Expand Down

0 comments on commit db5ed5a

Please sign in to comment.