Documentation
¶
Overview ¶
Package edgeauthtest mints identity JWTs for an app's tests, the way guard signs them, with a throwaway key served from an in-process JWKS:
iss := edgeauthtest.NewIssuer(t)
v, err := edgeauth.New(iss.Config("live.metsa.app"))
...
req := httptest.NewRequest(http.MethodGet, "https://live.metsa.app/admin", nil)
iss.Sign(req, edgeauth.Identity{Subject: "u1", Roles: []string{"admin"}})
MintWith edits the claims before signing, for the tokens an app must refuse (expired, for another host).
Index ¶
Constants ¶
const KeyID = "edgeauthtest"
KeyID is the kid of every Issuer's key.
const Lifetime = 60 * time.Second
Lifetime is how long a minted token is valid, as guard's are.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct {
Issuer string `json:"iss"`
Audience string `json:"aud"`
Subject string `json:"sub"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
Name string `json:"name"`
Roles []string `json:"roles"`
SessionID string `json:"sid"`
AuthTime int64 `json:"auth_time,omitempty"`
ClientID string `json:"azp"`
Source string `json:"src"`
IssuedAt int64 `json:"iat"`
Expiry int64 `json:"exp"`
}
Claims is a token's payload before signing, for MintWith to edit.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer signs identity JWTs with an in-memory P-256 key and serves its JWKS on a test server that is closed when the test ends.
func (*Issuer) Mint ¶
Mint signs an identity JWT for id with audience aud, issued now and valid for Lifetime. An empty Source becomes edgeauth.SourceSession.