Skip to content

Commit

Permalink
feat(azure): log unhandled error codes (#3865)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz authored Feb 13, 2025
1 parent d010607 commit 8cd2fdd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/detectors/azure_entra/refreshtoken/refreshtoken.go
Original file line number Diff line number Diff line change
@@ -134,16 +134,18 @@ TokenLoop:
continue
} else if errors.Is(verificationErr, ErrTokenExpired) {
continue TokenLoop
} else {
// Received an unexpected/unhandled error type.
r = createResult(token, clientId, tenantId, isVerified, extraData, verificationErr)
break ClientLoop
}
}

// The result is verified or there's only one associated client and tenant.
if isVerified {
r = createResult(tenantId, clientId, token, isVerified, extraData, verificationErr)
r = createResult(token, clientId, tenantId, isVerified, extraData, verificationErr)
break ClientLoop
}

// The result may be valid for another client/tenant.
}
}
}
@@ -244,17 +246,20 @@ func verifyMatch(ctx context.Context, client *http.Client, refreshToken string,
// https://login.microsoftonline.com/error?code=9002313
d := errResp.Description
switch {
case strings.HasPrefix(d, "AADSTS70008:"), strings.HasPrefix(d, "AADSTS700082:"):
case strings.HasPrefix(d, "AADSTS70008:"),
strings.HasPrefix(d, "AADSTS700082:"),
strings.HasPrefix(d, "AADSTS70043:"):
// https://login.microsoftonline.com/error?code=70008
// https://login.microsoftonline.com/error?code=700082
// https://login.microsoftonline.com/error?code=70043
return false, nil, ErrTokenExpired
case strings.HasPrefix(d, "AADSTS700016:"):
// https://login.microsoftonline.com/error?code=700016
return false, nil, ErrClientNotFoundInTenant
case strings.HasPrefix(d, "AADSTS90002:"):
// https://login.microsoftonline.com/error?code=90002
return false, nil, ErrTenantNotFound
case strings.HasPrefix(d, "AADSTS9002313"):
case strings.HasPrefix(d, "AADSTS9002313:"):
// This seems to be a generic "invalid token" error code.
// 'invalid_grant': AADSTS9002313: Invalid request. Request is malformed or invalid.
return false, nil, nil

0 comments on commit 8cd2fdd

Please sign in to comment.