token

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: LGPL-3.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ADMIN       int = 42
	CREATOR     int = 1
	COORDINATOR int = 2
)

Variables

This section is empty.

Functions

func GetAPIToken added in v0.4.0

func GetAPIToken(r *http.Request) string

func GetServiceToken added in v0.4.0

func GetServiceToken(r *http.Request) string

Types

type APIKey added in v0.4.0

type APIKey struct {
	ID      int    `json:"api_key_id" sql:"api_key_id"`
	Key     string `json:"api_key" sql:"api_key"`
	Comment string `json:"api_key_comment" sql:"api_key_comment"`
}

type AuthService added in v0.0.5

type AuthService struct {
	SigningKey        *rsa.PrivateKey
	ValidationKey     *rsa.PublicKey
	ValidationKeyFile string
	TokenLifetime     time.Duration
	Issuer            string
}

func NewAuthService added in v0.4.0

func NewAuthService(privatekey string, publickey string, tokenLifetime int, issuer string) *AuthService

type Authentication added in v0.0.5

type Authentication interface {
	GenerateAccessToken(user *User) (string, error)
}

Authentication interface lists the methods that our authentication service should implement

type ServiceKey added in v0.4.0

type ServiceKey struct {
	ID      int    `json:"service_key_id" sql:"service_key_id"`
	Key     string `json:"service_key" sql:"service_key"`
	Comment string `json:"service_key_comment" sql:"service_key_comment"`
}

type User added in v0.4.0

type User struct {
	ID           int       `json:"user_id" sql:"user_id"`
	Email        string    `json:"user_email" sql:"user_email"`
	PasswordHash string    `json:"user_password" sql:"user_password"`
	CreateDate   time.Time `json:"user_createdat" sql:"user_createdat"`
	UpdateDate   time.Time `json:"user_updatedat" sql:"user_updatedat"`
	Role         int       `json:"user_role" sql:"user_role"`
}

type UserClaims added in v0.4.0

type UserClaims struct {
	UserID        string
	UserRole      int
	UserFestivals []int
	UserArtists   []int
	UserLocations []int
	UserEvents    []int
	UserLinks     []int
	UserPlaces    []int
	UserImages    []int
	UserTags      []int
	jwt.RegisteredClaims
}

func GetValidClaims added in v0.4.0

func GetValidClaims(r *http.Request, validator *ValidationService) *UserClaims

type Validation added in v0.6.0

type Validation interface {
	ValidateAccessToken(token string) (string, error)
}

type ValidationService added in v0.6.0

type ValidationService struct {
	Key         *rsa.PublicKey
	APIKeys     *[]string
	ServiceKeys *[]string
	Client      *http.Client
	Endpoint    string
}

func NewValidationService added in v0.6.0

func NewValidationService(endpoint string, clientCert string, clientKey string, serviceKey string, loadingServiceKeys bool) *ValidationService

func (*ValidationService) ValidateAccessToken added in v0.6.0

func (validator *ValidationService) ValidateAccessToken(tokenString string) (*UserClaims, error)

ValidateAccessToken parses and validates the given access token returns the custom claim present in the token payload

Jump to

Keyboard shortcuts

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