MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ParseJWTToken

Function ParseJWTToken

internal/auth/codex/jwt_parser.go:58–76  ·  view source on GitHub ↗

ParseJWTToken parses a JWT token string and extracts its claims without performing cryptographic signature verification. This is useful for introspecting the token's contents to retrieve user information from an ID token after it has been validated by the authentication server.

(token string)

Source from the content-addressed store, hash-verified

56// contents to retrieve user information from an ID token after it has been validated
57// by the authentication server.
58func ParseJWTToken(token string) (*JWTClaims, error) {
59 parts := strings.Split(token, ".")
60 if len(parts) != 3 {
61 return nil, fmt.Errorf("invalid JWT token format: expected 3 parts, got %d", len(parts))
62 }
63
64 // Decode the claims (payload) part
65 claimsData, err := base64URLDecode(parts[1])
66 if err != nil {
67 return nil, fmt.Errorf("failed to decode JWT claims: %w", err)
68 }
69
70 var claims JWTClaims
71 if err = json.Unmarshal(claimsData, &claims); err != nil {
72 return nil, fmt.Errorf("failed to unmarshal JWT claims: %w", err)
73 }
74
75 return &claims, nil
76}
77
78// base64URLDecode decodes a Base64 URL-encoded string, adding padding if necessary.
79// JWTs use a URL-safe Base64 alphabet and omit padding, so this function ensures

Callers 6

synthesizeFileAuthsFunction · 0.92
RequestCodexTokenMethod · 0.92
buildAuthRecordMethod · 0.92

Calls 1

base64URLDecodeFunction · 0.85

Tested by

no test coverage detected