kubernetestoken

package
v0.0.0-...-5c79d48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceAccountNamePrefix = "system:serviceaccount"
)

Variables

This section is empty.

Functions

func GetIDToken

func GetIDToken(getEnv getEnvFunc, readFile readFileFunc) (string, error)

Types

type TokenReviewValidator

type TokenReviewValidator struct {
	// contains filtered or unexported fields
}

TokenReviewValidator validates a Kubernetes Service Account JWT using the Kubernetes TokenRequest API endpoint.

func (*TokenReviewValidator) Validate

func (v *TokenReviewValidator) Validate(ctx context.Context, token string) (*ValidationResult, error)

Validate uses the Kubernetes TokenReview API to validate a token and return its UserInfo

type ValidationResult

type ValidationResult struct {
	// Raw contains the underlying information retrieved during the validation
	// process. This lets us ensure all pertinent information is presented in
	// audit logs.
	Raw any `json:"raw"`
	// Type indicates which form of validation was performed on the token.
	Type types.KubernetesJoinType `json:"type"`
	// Username is the Kubernetes username extracted from the identity.
	// This will be prepended with `system:serviceaccount:` for service
	// accounts.
	Username string `json:"username"`
}

func ValidateTokenWithJWKS

func ValidateTokenWithJWKS(
	now time.Time,
	jwksData []byte,
	clusterName string,
	token string,
) (*ValidationResult, error)

ValidateTokenWithJWKS validates a Kubernetes Service Account JWT using a configured JWKS.

func (*ValidationResult) JoinAuditAttributes

func (c *ValidationResult) JoinAuditAttributes() (map[string]interface{}, error)

JoinAuditAttributes returns a series of attributes that can be inserted into audit events related to a specific join.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL