Documentation
¶
Overview ¶
Package authtest signs tokens the way Dex does, and reviews ServiceAccount tokens the way the Kubernetes API does, for tests.
Index ¶
- Constants
- func PersonClaims(email string, groups []string, exp time.Time) map[string]any
- func PersonSubject(email string) string
- func PrincipalClaims(clientID string, exp time.Time) map[string]any
- func ServiceAccountToken(namespace, name string, exp time.Time) string
- type Issuer
- func (i *Issuer) Discovery(jwksURL string) []byte
- func (i *Issuer) JWKS() []byte
- func (i *Issuer) Person(email string, groups []string, exp time.Time) string
- func (i *Issuer) Principal(clientID string, exp time.Time) string
- func (i *Issuer) Sign(claims map[string]any) string
- func (i *Issuer) Verifier(audience string, now func() time.Time) *auth.OIDCVerifier
- type TokenReviews
Constants ¶
const ( IssuerURL = "https://dex.example.io" Audience = "beekeeper" )
The issuer and audience tests use.
const ClusterIssuer = "https://kubernetes.default.svc.cluster.local"
ClusterIssuer is the iss of ServiceAccountToken's tokens: a cluster's, not IssuerURL.
Variables ¶
This section is empty.
Functions ¶
func PersonClaims ¶
PersonClaims are the claims of a person's token for Beekeeper.
func PersonSubject ¶
PersonSubject is a sub Dex could give a person signed in through a connector.
func PrincipalClaims ¶
PrincipalClaims are the claims of a principal client's own client_credentials token for Beekeeper, as Dex issues it.
Types ¶
type Issuer ¶
type Issuer struct {
URL string
// contains filtered or unexported fields
}
Issuer signs tokens with its own key.
type TokenReviews ¶
type TokenReviews struct {
// contains filtered or unexported fields
}
TokenReviews is a Kubernetes API that authenticates the tokens it accepted, for the audiences a review asks for, and no other token.
func NewTokenReviews ¶
func NewTokenReviews() *TokenReviews
NewTokenReviews returns an API that authenticates no token yet.
func (*TokenReviews) Accept ¶
func (r *TokenReviews) Accept(token, username string)
Accept makes the API authenticate token as username.
func (*TokenReviews) Calls ¶
func (r *TokenReviews) Calls() int
Calls is how many reviews the API answered or failed.
func (*TokenReviews) Client ¶
func (r *TokenReviews) Client() client.Client
Client is a client of the API.
func (*TokenReviews) Fail ¶
func (r *TokenReviews) Fail(err error)
Fail makes every review fail with err, or no review once err is nil.