auth

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnonymousTenantID TenantID = "tenant_000000000000000000000000001"
	AnonymousUserID   UserID   = "user_000000000000000000000000001"
)
View Source
const (
	// These are the namespaced custom claims we expect on any JWT
	// access token.
	TenantIDClaim = "https://lake.brimdata.io/tenant_id"
	UserIDClaim   = "https://lake.brimdata.io/user_id"
)

Variables

This section is empty.

Functions

func AuthTokenFromContext

func AuthTokenFromContext(ctx context.Context) (string, bool)

func ContextWithAuthToken

func ContextWithAuthToken(ctx context.Context, token string) context.Context

func ContextWithIdentity

func ContextWithIdentity(ctx context.Context, ident Identity) context.Context

func GenerateAccessToken

func GenerateAccessToken(keyID string, privateKeyFile string, expiration time.Duration, audience, domain string, tenantID TenantID, userID UserID) (string, error)

GenerateAccessToken creates a JWT in string format with the expected audience, issuer, and claims to pass zqd authentication checks.

Types

type Identity

type Identity struct {
	TenantID TenantID
	UserID   UserID
}

func IdentityFromContext

func IdentityFromContext(ctx context.Context) Identity

type TenantID

type TenantID string

type TokenValidator

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

func NewTokenValidator

func NewTokenValidator(audience, domain, jwksPath string) (*TokenValidator, error)

func (*TokenValidator) Validate

func (v *TokenValidator) Validate(token string) (Identity, error)

func (*TokenValidator) ValidateRequest

func (v *TokenValidator) ValidateRequest(r *http.Request) (string, Identity, error)

type UserID

type UserID string

Jump to

Keyboard shortcuts

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