auth

package
v0.0.0-...-8bb18f9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DaysTokenValid = 30

Variables

View Source
var (
	ErrTokenInvalid = errors.New("jwt token is invalid")
	ErrTokenExpired = errors.New("jwt token is expired")
	ErrParsingToken = errors.New("error parsing jwt token")
)

Functions

func GenerateJwtWithClaims

func GenerateJwtWithClaims(user string) (string, error)

func IsJwtExpired

func IsJwtExpired(token string) bool

Types

type Claims

type Claims struct {
	MachineID string `json:"machine_id"`
	jwt.RegisteredClaims
}

func ParseJwtWithClaims

func ParseJwtWithClaims(token string) (*Claims, error)

type OpenIDConfig

type OpenIDConfig struct {
	Issuer           string   `json:"issuer"`
	AuthEndpoint     string   `json:"authorization_endpoint"`
	TokenEndpoint    string   `json:"token_endpoint"`
	JWKSEndpoint     string   `json:"jwks_uri"`
	Scopes           []string `json:"scopes_supported"`
	Claims           []string `json:"claims_supported"`
	UserInfoEndpoint string   `json:"userinfo_endpoint"`
}

type TokenValidator

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

func NewTokenValidator

func NewTokenValidator(ctx context.Context) (*TokenValidator, error)

func (*TokenValidator) GetPKCEAuthInfo

func (t *TokenValidator) GetPKCEAuthInfo() *ctrlv1.GetPKCEAuthInfoResponse

func (*TokenValidator) GetUser

func (t *TokenValidator) GetUser(token *jwt.Token) (string, error)

func (*TokenValidator) GetUserInfo

func (t *TokenValidator) GetUserInfo(token *jwt.Token) (*UserInfo, error)

func (*TokenValidator) ValidateAccessToken

func (t *TokenValidator) ValidateAccessToken(token string) (string, error)

type UserInfo

type UserInfo struct {
	Name       string    `json:"name"`
	GivenName  string    `json:"given_name"`
	FamilyName string    `json:"family_name"`
	Email      string    `json:"email"`
	Nickname   string    `json:"nickname"`
	UpdatedAt  time.Time `json:"-"`
}

func (*UserInfo) NeedsRefresh

func (u *UserInfo) NeedsRefresh() bool

Jump to

Keyboard shortcuts

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