service

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyService

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

func NewAPIKeyService

func NewAPIKeyService(db *gorm.DB) APIKeyService

func (APIKeyService) CreateAPIKey

func (svc APIKeyService) CreateAPIKey(ctx context.Context, params model.CreateAPIKeyParams) (model.APIKey, string, error)

func (APIKeyService) DeleteAPIKeyByID

func (svc APIKeyService) DeleteAPIKeyByID(ctx context.Context, id uint) error

func (APIKeyService) FindAPIKeyByID

func (svc APIKeyService) FindAPIKeyByID(ctx context.Context, id uint) (model.APIKey, error)

func (APIKeyService) FindAPIKeyByName

func (svc APIKeyService) FindAPIKeyByName(ctx context.Context, name string) (model.APIKey, error)

func (APIKeyService) GetAllAPIKeys

func (svc APIKeyService) GetAllAPIKeys(ctx context.Context) ([]model.APIKey, error)

type AuthService

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

func NewAuthService

func NewAuthService(db *gorm.DB, jwtTokenService JWTTokenService) AuthService

func (AuthService) APIKeyFromToken

func (svc AuthService) APIKeyFromToken(ctx context.Context, t string) (model.APIKey, error)

func (AuthService) AuthenticateUser

func (svc AuthService) AuthenticateUser(ctx context.Context, name string, password string) (model.User, error)

AuthenticateUser returns User with the given login if its password hash matches the given one. If user cannot be found or the password does not match the function returns ErrCredentialsInvalid.

External users are not allowed to use password authentication. TODO(kolesnikovae): It's true for "some" authentication providers.

Others may need us to pass through the credentials (e.g. LDAP).

func (AuthService) UserFromJWTToken

func (svc AuthService) UserFromJWTToken(ctx context.Context, t string) (model.User, error)

type CachingAuthService

type CachingAuthService struct {
	AuthService
	// contains filtered or unexported fields
}

func NewCachingAuthService

func NewCachingAuthService(authService AuthService, c CachingAuthServiceConfig) CachingAuthService

func (CachingAuthService) APIKeyFromToken

func (svc CachingAuthService) APIKeyFromToken(ctx context.Context, t string) (model.APIKey, error)

func (CachingAuthService) DeleteAPIKey

func (svc CachingAuthService) DeleteAPIKey(t string)

func (CachingAuthService) PutAPIKey

func (svc CachingAuthService) PutAPIKey(t string, k model.APIKey)

type CachingAuthServiceConfig

type CachingAuthServiceConfig struct {
	Size int
	TTL  time.Duration
}

type JWTTokenService

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

func NewJWTTokenService

func NewJWTTokenService(signingKey []byte, tokenTTL time.Duration) JWTTokenService

func (JWTTokenService) GenerateUserJWTToken

func (svc JWTTokenService) GenerateUserJWTToken(name string, role model.Role) *jwt.Token

func (JWTTokenService) Parse

func (svc JWTTokenService) Parse(t string) (*jwt.Token, error)

Parse parses the token and validates it using the signing key.

func (JWTTokenService) Sign

func (svc JWTTokenService) Sign(t *jwt.Token) (string, error)

func (JWTTokenService) UserFromJWTToken

func (JWTTokenService) UserFromJWTToken(t *jwt.Token) (model.TokenUser, bool)

UserFromJWTToken retrieves user info from the given JWT token. 'name' claim must be present and valid, otherwise the function returns false. The function does not validate the token.

type UserService

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

func NewUserService

func NewUserService(db *gorm.DB) UserService

func (UserService) CreateUser

func (svc UserService) CreateUser(ctx context.Context, params model.CreateUserParams) (model.User, error)

func (UserService) DeleteUserByID

func (svc UserService) DeleteUserByID(ctx context.Context, id uint) error

func (UserService) FindUserByEmail

func (svc UserService) FindUserByEmail(ctx context.Context, email string) (model.User, error)

func (UserService) FindUserByID

func (svc UserService) FindUserByID(ctx context.Context, id uint) (model.User, error)

func (UserService) FindUserByName

func (svc UserService) FindUserByName(ctx context.Context, name string) (model.User, error)

func (UserService) GetAllUsers

func (svc UserService) GetAllUsers(ctx context.Context) ([]model.User, error)

func (UserService) UpdateUserByID

func (svc UserService) UpdateUserByID(ctx context.Context, id uint, params model.UpdateUserParams) (model.User, error)

func (UserService) UpdateUserByName

func (svc UserService) UpdateUserByName(ctx context.Context, name string, params model.UpdateUserParams) (model.User, error)

func (UserService) UpdateUserPasswordByID

func (svc UserService) UpdateUserPasswordByID(ctx context.Context, id uint, params model.UpdateUserPasswordParams) error

Jump to

Keyboard shortcuts

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