Skip to content

Commit

Permalink
Merge pull request #416 from potto007/fix-http-header-init
Browse files Browse the repository at this point in the history
Fix AddJWT to init c.Headers if still nil.
  • Loading branch information
plorenz authored Jul 6, 2023
2 parents 8460598 + d7945ca commit b16c83e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions edge-apis/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ type BaseCredentials struct {
CaPool *x509.CertPool
}

// AddJWT adds additional JWTs to the credentials. Used to satisfy secondary authentication/MFA requirements. The
// provided token should be the base64 encoded version of the token.
func (c *BaseCredentials) AddJWT(token string) {
c.Headers.Add("authorization", "Bearer "+token)
}

// Payload will produce the object used to construct the body of an authentication requests. The base version
// sets shared information available in BaseCredentials.
func (c *BaseCredentials) Payload() *rest_model.Authenticate {
Expand Down Expand Up @@ -137,6 +131,12 @@ func (c *BaseCredentials) AddHeader(key, value string) {
c.Headers.Add(key, value)
}

// AddJWT adds additional JWTs to the credentials. Used to satisfy secondary authentication/MFA requirements. The
// provided token should be the base64 encoded version of the token. Convenience function for AddHeader.
func (c *BaseCredentials) AddJWT(token string) {
c.AddHeader("Authorization", "Bearer "+token)
}

// AuthenticateRequest provides a base implementation to authenticate an outgoing request. This is provided here
// for authentication methods such as `cert` which do not have to provide any more request level information.
func (c *BaseCredentials) AuthenticateRequest(request runtime.ClientRequest, _ strfmt.Registry) error {
Expand Down

0 comments on commit b16c83e

Please sign in to comment.