usecase

package
v0.0.0-...-34c33d5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

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

func NewAuthentication

func NewAuthentication(accessTokenTimeout, refreshTokenTimeout time.Duration) Authentication

func (Authentication) ExtractClaimsForValidToken

func (a Authentication) ExtractClaimsForValidToken(token *jwt.Token) (jwt.MapClaims, error)

func (Authentication) GenerateJWTTokenPair

func (a Authentication) GenerateJWTTokenPair(user *models.User, signingKeyJWT string) (*models.TokenPair, error)

func (Authentication) ParseTokenString

func (a Authentication) ParseTokenString(jwtToken, signingKeyJWT string) (*jwt.Token, error)

type AuthenticationPort

type AuthenticationPort interface {
	ExtractClaimsForValidToken(token *jwt.Token) (jwt.MapClaims, error)
	GenerateJWTTokenPair(user *models.User, signingKeyJWT string) (*models.TokenPair, error)
	ParseTokenString(jwtToken, signingKeyJWT string) (*jwt.Token, error)
}

type AuthenticationUsecase

type AuthenticationUsecase struct {
	Auth AuthenticationPort
}

func NewAuthenticationUsecase

func NewAuthenticationUsecase(auth AuthenticationPort) AuthenticationUsecase

func (AuthenticationUsecase) ExtractClaimsForValidToken

func (u AuthenticationUsecase) ExtractClaimsForValidToken(token *jwt.Token) (jwt.MapClaims, error)

func (AuthenticationUsecase) GenerateJWTTokenPair

func (u AuthenticationUsecase) GenerateJWTTokenPair(user *models.User, signingKeyJWT string) (*models.TokenPair, error)

func (AuthenticationUsecase) ParseTokenString

func (u AuthenticationUsecase) ParseTokenString(jwtToken, signingKeyJWT string) (*jwt.Token, error)

type FakeAuthUsecase

type FakeAuthUsecase struct {
	HasGenerateJWTTokenPairError       bool
	HasParseTokenStringError           bool
	HasExtractClaimsForValidTokenError bool
}

func (FakeAuthUsecase) ExtractClaimsForValidToken

func (f FakeAuthUsecase) ExtractClaimsForValidToken(token *jwt.Token) (jwt.MapClaims, error)

func (FakeAuthUsecase) GenerateJWTTokenPair

func (f FakeAuthUsecase) GenerateJWTTokenPair(user *models.User, signingKeyJWT string) (*models.TokenPair, error)

func (FakeAuthUsecase) ParseTokenString

func (f FakeAuthUsecase) ParseTokenString(token, signingKeyJWT string) (*jwt.Token, error)

type FakeUserUsecase

type FakeUserUsecase struct {
	HasGetUserError                bool
	HasGetUserByIdError            bool
	HasUpdatePasswordByUserIdError bool
	HasDeleteUserTokenError        bool
	HasStoreUserTokenError         bool
	HasValidPasswordError          bool
	IsValidUserError               bool
}

func (FakeUserUsecase) DeleteUserToken

func (f FakeUserUsecase) DeleteUserToken(userId string) error

func (FakeUserUsecase) GetUser

func (f FakeUserUsecase) GetUser(name string) (*models.User, error)

func (FakeUserUsecase) GetUserById

func (f FakeUserUsecase) GetUserById(userId string) (*models.User, error)

func (FakeUserUsecase) HasValidPassword

func (f FakeUserUsecase) HasValidPassword(user *models.User, clientPassword string) (bool, error)

func (FakeUserUsecase) IsValidUser

func (f FakeUserUsecase) IsValidUser(userId string) bool

func (FakeUserUsecase) StoreUserToken

func (f FakeUserUsecase) StoreUserToken(userId string, tokenPair *models.TokenPair) error

func (FakeUserUsecase) UpdataPasswordByUserId

func (f FakeUserUsecase) UpdataPasswordByUserId(userId, newPasswordHash string) error

type UserPort

type UserPort interface {
	DeleteUserToken(userId string) error
	GetUser(name string) (*models.User, error)
	GetUserById(userId string) (*models.User, error)
	UpdataPasswordByUserId(userId, newPasswordHash string) error
	HasValidPassword(user *models.User, clientPassword string) (bool, error)
	IsValidUser(userId string) bool
	StoreUserToken(userId string, tokenPair *models.TokenPair) error
}

type UserUsecase

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

func NewUserUsecase

func NewUserUsecase(repository UserPort) UserUsecase

func (UserUsecase) DeleteUserToken

func (u UserUsecase) DeleteUserToken(userId string) error

func (UserUsecase) GetUser

func (u UserUsecase) GetUser(client *models.User) (*models.User, error)

func (UserUsecase) GetUserById

func (u UserUsecase) GetUserById(userId string) (*models.User, error)

func (UserUsecase) HasValidPassword

func (u UserUsecase) HasValidPassword(user *models.User, password string) (bool, error)

func (UserUsecase) IsValidUser

func (u UserUsecase) IsValidUser(userId string) bool

func (UserUsecase) StoreUserToken

func (u UserUsecase) StoreUserToken(userId string, tokenPair *models.TokenPair) error

func (UserUsecase) UpdataPasswordByUserId

func (u UserUsecase) UpdataPasswordByUserId(userId, newPasswordHash string) error

Jump to

Keyboard shortcuts

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