Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rharpavat committed Aug 16, 2023
1 parent 247f286 commit 6afca46
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkg/pop/poptoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (as *PopAuthenticationScheme) KeyID() string {
func (as *PopAuthenticationScheme) FormatAccessToken(accessToken string) (string, error) {
ts := time.Now().Unix()
nonce := uuid.New().String()
nonce = strings.Replace(nonce, "-", "", -1)
nonce = strings.ReplaceAll(nonce, "-", "")
header := fmt.Sprintf(`{"typ":"pop","alg":"%s","kid":"%s"}`, as.PoPKey.Alg(), as.PoPKey.KeyID())
headerB64 := base64.RawURLEncoding.EncodeToString([]byte(header))
payload := fmt.Sprintf(`{"at":"%s","ts":%d,"u":"%s","cnf":{"jwk":%s},"nonce":"%s"}`, accessToken, ts, as.Host, as.PoPKey.JWK(), nonce)
Expand Down Expand Up @@ -161,7 +161,7 @@ func GetSwPoPKey() *swKey {

key, err := generateSwKey()
if err != nil {
log.Fatal("unable to generate popkey")
log.Panicf("unable to generate popkey. err: %v", err)
}
pswKey = key

Expand All @@ -172,7 +172,7 @@ func GetSwPoPKey() *swKey {
<-ticker.C
key, err := generateSwKey()
if err != nil {
log.Fatal("unable to generate popkey")
log.Panicf("unable to generate popkey. err: %v", err)
}
pwsKeyMutex.Lock()
pswKey = key
Expand Down
4 changes: 2 additions & 2 deletions pkg/token/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func (p *InteractiveToken) Token() (adal.Token, error) {
// azurecore.AccessTokens have ExpiresOn as Time.Time. We need to convert it to JSON.Number
// by fetching the time in seconds since the Unix epoch via Unix() and then converting to a
// JSON.Number via formatting as a string using a base-10 int64 conversion
expiresOnJson := json.Number(strconv.FormatInt(expiresOn, 10))
expiresOnJSON := json.Number(strconv.FormatInt(expiresOn, 10))

// re-wrap the azurecore.AccessToken into an adal.Token
return adal.Token{
AccessToken: token,
ExpiresOn: expiresOnJson,
ExpiresOn: expiresOnJSON,
Resource: p.resourceID,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/token/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (o *Options) Validate() error {
}

if o.PoPClaims != nil && !o.IsPopTokenEnabled {
return fmt.Errorf("pop-enabled flag is required to use the PoP token feature. Please provide both pop-enabled and pop-claims flags.")
return fmt.Errorf("pop-enabled flag is required to use the PoP token feature. Please provide both pop-enabled and pop-claims flags")
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/token/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ func parsePopClaims(popClaims []string) (map[string]string, error) {
key := strings.TrimSpace(claimPair[0])
val := strings.TrimSpace(claimPair[1])
if key == "" || val == "" {
return nil, fmt.Errorf("error parsing PoP token claims. Ensure the claims are formatted as `key=value` with no extra whitespace.")
return nil, fmt.Errorf("error parsing PoP token claims. Ensure the claims are formatted as `key=value` with no extra whitespace")
}
claimsMap[key] = val
}
if claimsMap["u"] == "" {
return nil, fmt.Errorf("required u-claim not provided for PoP token flow. Please provide the ARM ID of the connected cluster in the format `u=<ARM_ID`.")
return nil, fmt.Errorf("required u-claim not provided for PoP token flow. Please provide the ARM ID of the connected cluster in the format `u=<ARM_ID`")
}
return claimsMap, nil
}

0 comments on commit 6afca46

Please sign in to comment.