kc jwt
Overview
The kc jwt command decodes and displays JWT (JSON Web Token) contents in a human-readable format. It extracts and pretty-prints the header and payload, and adds human-readable timestamps.
Syntax
or
Arguments
[token]
string - optional
The JWT token to decode. If not provided as an argument, reads from stdin.
Examples
Decode Token from Argument
kc jwt eyJhbGciOiJSUzI1NiIsImtpZCI6ImY0Y2NkNDU0LWYzYTgtNDQ3Zi1hN2MzLTY3ZmY5MzUxMzZiMSIsInR5cCI6IkpXVCJ9.eyJhdF9oYXNoIjoiaGNBY2dtdmdBekJlSGgyODlkWHF3USIsImF1ZCI6WyJwdWJsaWMiXSwi...
Decode Token from Stdin
Pipe from kc token
Output
JWT Header:
{
"alg": "RS256",
"kid": "f4ccd454-f3a8-447f-a7c3-67ff935136b1",
"typ": "JWT"
}
JWT Payload:
{
"at_hash": "_GWrC20juEb4Zh39S0ly5w",
"aud": ["public"],
"auth_time": 1761564624,
"auth_time_human": "2025-10-27 11:30:24 UTC",
"azp": "public",
"email": "john@example.com",
"emails": ["john@example.com"],
"exp": 1761568224,
"exp_human": "2025-10-27 12:30:24 UTC",
"groups": ["developers", "ops"],
"iat": 1761564624,
"iat_human": "2025-10-27 11:30:24 UTC",
"iss": "https://kubauth.example.com",
"jti": "be30eeb2-153f-4dec-97b8-c75d23035f81",
"name": "John DOE",
"office": "208G",
"rat": 1761564624,
"rat_human": "2025-10-27 11:30:24 UTC",
"sub": "john"
}
Human-Readable Timestamps
The decoder adds _human suffixed fields for timestamp claims:
auth_time_human- When user authenticatedexp_human- When token expiresiat_human- When token was issuedrat_human- Token refresh time
Note
The *_human fields are added by the decoder for convenience and are not part of the actual JWT token.
JWT Structure
Header
Contains token metadata:
alg- Signing algorithm (e.g., RS256)kid- Key ID used for signingtyp- Token type (JWT)
Payload
Contains claims (user information):
Standard OIDC Claims:
sub- Subject (username)iss- Issuer URLaud- Audience (client ID)exp- Expiration timeiat- Issued at timeauth_time- Authentication time
Kubauth-Added Claims:
name- User's full nameemail- Primary emailemails- All emailsgroups- Group memberships
Custom Claims:
- Any claims from User or Group
spec.claims
Limitations
No Signature Verification
The kc jwt command only decodes the token; it does not verify the signature.
Base64 Decoding Only
This command simply base64-decodes the JWT parts. It doesn't validate:
- Token expiration
- Issuer authenticity
- Signature validity
Troubleshooting
Invalid Token Format
Error:
Solution: Ensure the token is a complete JWT with three dot-separated parts:
Malformed JSON
If the output shows malformed JSON, the token may be corrupted or incomplete.
Related Commands
kc token- Get tokens with-dflag for automatic decodingkc token-nui- Get tokens in terminalkc whoami- With -d option, display decoded token from kubectl context