Documentation
¶
Overview ¶
Package jwttest provides an in-process jwt.Signer for tests. It generates RSA keys on the fly and never touches disk or external services. Production code MUST NOT import this package.
Index ¶
- type Signer
- func (s *Signer) ActiveKID() string
- func (s *Signer) AddKey(tb testing.TB, kid string)
- func (s *Signer) DropKey(kid string)
- func (s *Signer) Get(kid string) (*rsa.PublicKey, bool)
- func (s *Signer) Keys() []jwt.PublicKey
- func (s *Signer) SetActive(kid string)
- func (s *Signer) SignAccessToken(ctx context.Context, claims jwt.Claims, expiry time.Duration) (string, error)
- func (s *Signer) SignClaims(_ context.Context, claims map[string]any) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer is an in-memory jwt.Signer for tests. All operations are goroutine-safe; AddKey / SetActive / DropKey may be called concurrently with Sign / Verify.
func NewSigner ¶
NewSigner constructs a Signer with a single key (the active one). Subsequent keys are added with AddKey.
func (*Signer) DropKey ¶
DropKey removes a key entirely. Tokens signed with that kid will no longer verify.
Click to show internal directories.
Click to hide internal directories.