Skip to content

Commit

Permalink
chore: Use a constant for auth header name
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Apr 20, 2024
1 parent 111551a commit a0a9488
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/plugin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
)

// Authorization header name
const (
authHeaderName = "Authorization"
)

// Client is a Grafana API client
type GrafanaClient interface {
GetDashboard(dashUID string) (Dashboard, error)
Expand Down Expand Up @@ -73,8 +78,8 @@ func (g grafanaClient) forwardAuthHeader(r *http.Request) *http.Request {
// If cookie is not foun, try Authorization header that is used in API requests
if g.headers.Get(backend.CookiesHeaderName) != "" {
r.Header.Set(backend.CookiesHeaderName, g.headers.Get(backend.CookiesHeaderName))
} else if g.headers.Get("Authorization") != "" {
r.Header.Set("Authorization", g.headers.Get("Authorization"))
} else if g.headers.Get(authHeaderName) != "" {
r.Header.Set(authHeaderName, g.headers.Get(authHeaderName))
}
return r
}
Expand Down

0 comments on commit a0a9488

Please sign in to comment.