token

package
v1.2.2-0...-70982f0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = errors.New("invalid JWT token")
View Source
var ErrInvalidTokenType = errors.New("invalid token type")

Functions

func SignCallbackToken

func SignCallbackToken(secret, prv, cat, redirect string) (string, error)

func SignCategorySelectToken

func SignCategorySelectToken(secret string, categories []*model.Category, u *types.ProviderUserData) (string, error)

func SignDisclaimerAcknowledgementRequiredToken

func SignDisclaimerAcknowledgementRequiredToken(secret string, userID string) (string, error)

func SignEmailVerificationRequiredToken

func SignEmailVerificationRequiredToken(secret string, u *model.User) (string, error)

func SignEmailVerificationToken

func SignEmailVerificationToken(secret string, userID string, email string) (string, error)

func SignLoginToken

func SignLoginToken(secret string, expiration time.Time, sessID string, u *model.User) (string, error)

func SignPasswordResetRequiredToken

func SignPasswordResetRequiredToken(secret string, userID string) (string, error)

func SignPasswordResetToken

func SignPasswordResetToken(secret string, userID string) (string, error)

func SignRegisterToken

func SignRegisterToken(secret string, u *model.User) (string, error)

Types

type CallbackClaims

type CallbackClaims struct {
	TypeClaims
	Provider   string `json:"provider"`
	CategoryID string `json:"category_id"`
	Redirect   string `json:"redirect"`
}

func ParseCallbackToken

func ParseCallbackToken(secret, ss string) (*CallbackClaims, error)

func (CallbackClaims) Validate

func (c CallbackClaims) Validate() error

type CategorySelectClaims

type CategorySelectClaims struct {
	TypeClaims
	Categories []CategorySelectClaimsCategory `json:"categories"`
	User       types.ProviderUserData         `json:"user"`
}

func ParseCategorySelectToken

func ParseCategorySelectToken(secret, ss string) (*CategorySelectClaims, error)

func (CategorySelectClaims) Validate

func (c CategorySelectClaims) Validate() error

type CategorySelectClaimsCategory

type CategorySelectClaimsCategory struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Photo string `json:"photo"`
}

type DisclaimerAcknowledgementRequiredClaims

type DisclaimerAcknowledgementRequiredClaims struct {
	TypeClaims
	UserID string `json:"user_id"`
}

func ParseDisclaimerAcknowledgementRequiredToken

func ParseDisclaimerAcknowledgementRequiredToken(secret, ss string) (*DisclaimerAcknowledgementRequiredClaims, error)

func (DisclaimerAcknowledgementRequiredClaims) Validate

type EmailVerificationClaims

type EmailVerificationClaims struct {
	TypeClaims
	UserID string `json:"user_id"`
	Email  string `json:"email"`
}

func ParseEmailVerificationToken

func ParseEmailVerificationToken(secret, ss string) (*EmailVerificationClaims, error)

func (EmailVerificationClaims) Validate

func (c EmailVerificationClaims) Validate() error

type EmailVerificationRequiredClaims

type EmailVerificationRequiredClaims struct {
	TypeClaims
	UserID       string `json:"user_id"`
	CategoryID   string `json:"category_id"`
	CurrentEmail string `json:"current_email"`
}

func ParseEmailVerificationRequiredToken

func ParseEmailVerificationRequiredToken(secret, ss string) (*EmailVerificationRequiredClaims, error)

func (EmailVerificationRequiredClaims) Validate

type ExternalClaims

type ExternalClaims struct {
	TypeClaims
	UserID   string `json:"user_id"`
	GroupID  string `json:"group_id"`
	Role     string `json:"role"`
	Username string `json:"username"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Photo    string `json:"photo"`

	CategoryID string `json:"-"`
}

func ParseExternalToken

func ParseExternalToken(db rethinkdb.QueryExecutor, ss string) (*ExternalClaims, error)

func (ExternalClaims) Validate

func (c ExternalClaims) Validate() error

type LoginClaims

type LoginClaims struct {
	*jwt.RegisteredClaims
	KeyID     string          `json:"kid"`
	Type      Type            `json:"type,omitempty"`
	SessionID string          `json:"session_id"`
	Data      LoginClaimsData `json:"data"`
}

func ParseLoginToken

func ParseLoginToken(secret, ss string) (*LoginClaims, error)

func (LoginClaims) Validate

func (c LoginClaims) Validate() error

type LoginClaimsData

type LoginClaimsData struct {
	Provider   string `json:"provider"`
	ID         string `json:"user_id"`
	RoleID     string `json:"role_id"`
	CategoryID string `json:"category_id"`
	GroupID    string `json:"group_id"`
	Name       string `json:"name"`
}

type PasswordResetClaims

type PasswordResetClaims struct {
	TypeClaims
	UserID string `json:"user_id"`
}

func ParsePasswordResetToken

func ParsePasswordResetToken(secret, ss string) (*PasswordResetClaims, error)

func (PasswordResetClaims) Validate

func (c PasswordResetClaims) Validate() error

type PasswordResetRequiredClaims

type PasswordResetRequiredClaims struct {
	TypeClaims
	UserID string `json:"user_id"`
}

func ParsePasswordResetRequiredToken

func ParsePasswordResetRequiredToken(secret, ss string) (*PasswordResetRequiredClaims, error)

func (PasswordResetRequiredClaims) Validate

func (c PasswordResetRequiredClaims) Validate() error

type RegisterClaims

type RegisterClaims struct {
	TypeClaims
	Provider   string `json:"provider"`
	UserID     string `json:"user_id"`
	Username   string `json:"username"`
	CategoryID string `json:"category_id"`
	Name       string `json:"name"`
	Email      string `json:"email"`
	Photo      string `json:"photo"`
}

func ParseRegisterToken

func ParseRegisterToken(secret, ss string) (*RegisterClaims, error)

func (RegisterClaims) Validate

func (c RegisterClaims) Validate() error

type Type

type Type string
const (
	TypeUnknown                           Type = "unknown"
	TypeLogin                             Type = "login"
	TypeCallback                          Type = "callback"
	TypeRegister                          Type = "register"
	TypeExternal                          Type = "external"
	TypeDisclaimerAcknowledgementRequired Type = "disclaimer-acknowledgement-required"
	TypeEmailVerificationRequired         Type = "email-verification-required"
	TypeEmailVerification                 Type = "email-verification"
	TypePasswordResetRequired             Type = "password-reset-required"
	TypePasswordReset                     Type = "password-reset"
	TypeCategorySelect                    Type = "category-select"
)

func GetTokenType

func GetTokenType(ss string) (Type, error)

type TypeClaims

type TypeClaims struct {
	*jwt.RegisteredClaims
	KeyID string `json:"kid"`
	Type  Type   `json:"type"`
}

Jump to

Keyboard shortcuts

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