Skip to content

Commit

Permalink
feat(common.cookie): allow usage of secrets for header
Browse files Browse the repository at this point in the history
  • Loading branch information
h0nIg authored Jul 19, 2024
1 parent 41553ff commit 7ac1bab
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plugins/common/cookie/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type CookieAuthConfig struct {
URL string `toml:"cookie_auth_url"`
Method string `toml:"cookie_auth_method"`

Headers map[string]string `toml:"cookie_auth_headers"`
Headers map[string]*config.Secret `toml:"cookie_auth_headers"`

// HTTP Basic Auth Credentials
Username string `toml:"cookie_auth_username"`
Expand Down Expand Up @@ -98,11 +98,19 @@ func (c *CookieAuthConfig) auth() error {
}

for k, v := range c.Headers {
secret, err := v.Get()
if err != nil {
return err
}

headerVal := secret.String()
if strings.EqualFold(k, "host") {
req.Host = v
req.Host = headerVal
} else {
req.Header.Add(k, v)
req.Header.Add(k, headerVal)
}

secret.Destroy()
}

resp, err := c.client.Do(req)
Expand Down

0 comments on commit 7ac1bab

Please sign in to comment.