Human and application identity · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
Explore an OIDC provider
curl -s https://issuer.example.com/.well-known/openid-configuration | jq | Discovery: endpoints, supported flows, JWKS URL |
curl -s <jwks_uri> | jq '.keys[] | {kid, alg, kty}' | The public keys used to verify tokens |
cut -d. -f2 <<< "$TOKEN" | tr '_-' '/+' | base64 -d 2>/dev/null | jq | Read a JWT's claims (reading is not validating) |
Get tokens (test IdP)
curl -s -d grant_type=client_credentials -d client_id=svc -d client_secret=… <token_endpoint> | Client Credentials: a service gets a token for itself |
kubectl oidc-login get-token --oidc-issuer-url=<issuer> --oidc-client-id=kubectl | kubelogin: browser login, token for kubectl |
Gateway / mesh token checks (Istio)
kubectl apply -f requestauthentication.yaml | Validate JWTs from an issuer (signature, iss, aud) at the proxy |
kubectl get requestauthentication,authorizationpolicy -n shop | Which token rules apply in a namespace |
Debugging tokens
cut -d. -f1 <<< "$TOKEN" | base64 -d 2>/dev/null | Header: alg and kid |
cut -d. -f2 <<< "$TOKEN" | tr '_-' '/+' | base64 -d 2>/dev/null | jq '{iss,aud,sub,exp,scope}' | Claims that every check uses |
date -d @<exp> | Human-readable expiry |
Who can do what
kubectl auth can-i --list --as=alice@example.com --as-group=team-shop | Effective permissions of a user and group |
kubectl get clusterrolebindings,rolebindings -A -o wide | grep -i <group> | Where a group is bound |
kubectl get clusterrolebindings -o json | jq -r '.items[] | select(.roleRef.name=="cluster-admin") | .metadata.name, .subjects' | Everyone with cluster-admin |
Audit
jq 'select(.verb=="create" and .objectRef.subresource=="exec")' audit.log | Who exec'd into pods |
jq 'select(.objectRef.resource=="secrets" and .user.username | test("@"))' audit.log | Humans reading Secrets |