golang-jwt 5

Last reviewed Oct 20, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. golang-jwt 561 lines · 3.1K tokens
Total191 lines · 8.6K tokens

CWE Coverage

  • 15
  • 20
  • 22
  • 59
  • 78
  • 79
  • 89
  • 94
  • 117
  • 190
  • 201
  • 208
  • 209
  • 250
  • 252
  • 257
  • 287
  • 294
  • 295
  • 307
  • 323
  • 327
  • 338
  • 347
  • 352
  • 362
  • 367
  • 378
  • 426
  • 444
  • 488
  • 494
  • 532
  • 598
  • 732
  • 759
  • 770
  • 772
  • 807
  • 841
  • 862
  • 863
  • 915
  • 916
  • 918
  • 942
  • 1004
  • 1275
  • 1284
  • 1287
  • 1395

Prompt Preview

Apply these rules to github.com/golang-jwt/jwt/v5. This pack includes Go 1.27, whose token-verification rules also apply. This library signs and verifies compact JWTs; it does not supply a complete OAuth/OIDC flow, JWKS service, JWE implementation, or application authorization policy.

Parser configuration and header policy

  • Construct a jwt.NewParser for each trusted issuer and token purpose, configure it before sharing, and keep the option slices and key lookup policy immutable during requests. WithValidMethods retains the supplied slice rather than copying it.
  • Validate parser configuration at startup. A nil WithValidMethods slice leaves algorithm selection unrestricted, while a non-nil empty slice rejects every method; do not turn a missing algorithm configuration into a permissive default.
  • Require the token profile's typ and any intended cty in a reviewed header check. The parser reads alg but does not impose token-purpose typing or implement critical extensions; reject unsupported crit, b64: false, compression, and nested/encrypted formats rather than treating them as ordinary signed JWTs.
  • Keep custom signing-method registration fixed at startup. RegisterSigningMethod replaces the process-wide factory for an algorithm name, so an algorithm-name allowlist cannot protect against a substituted implementation. Never register a permissive verifier under a standard name.
  • Keep shared SigningMethod instances, TimePrecision, and MarshalSingleStringAsArray unchanged during request handling. Use deliberate startup configuration instead of