Skip to content

Instantly share code, notes, and snippets.

@chrigl
Last active December 20, 2024 12:07
Show Gist options
  • Select an option

  • Save chrigl/48430fef50c6efd1e2e8db2318ecb9aa to your computer and use it in GitHub Desktop.

Select an option

Save chrigl/48430fef50c6efd1e2e8db2318ecb9aa to your computer and use it in GitHub Desktop.
arrow-of-death.go
serviceAccountName := ""
if claims, ok := jwtToken.Claims.(jwt.MapClaims); ok {
for key, value := range claims {
if key == "kubernetes.io" {
if k8sClaims, ok := value.(map[string]interface{}); ok {
for k, v := range k8sClaims {
if k == "serviceaccount" {
if saClaims, ok := v.(map[string]interface{}); ok {
for k, v := range saClaims {
if k == "name" {
if name, ok := v.(string); ok {
serviceAccountName = name
}
}
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment