domain

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrACINotFound      = errors.New("aci not found")
	ErrPermissionDenied = errors.New("permission denied")
	ErrInvalidACI       = errors.New("invalid aci")
)
View Source
var (
	ErrAuthNotFound          = errors.New("auth not found")
	ErrUsernameExist         = errors.New("username already exist")
	ErrInvalidPassword       = errors.New("invalid password")
	ErrPasswordNotMatch      = errors.New("password not match")
	ErrInternal              = errors.New("internal error")
	ErrInvalidPasswordPolicy = errors.New("invalid password policy")
)
View Source
var (
	ErrInvalidToken  = errors.New("invalid token")
	ErrInvalidIssuer = errors.New("invalid issuer")
	ErrExpiredToken  = errors.New("expired token")
)

Functions

This section is empty.

Types

type ACI

type ACI struct {
	gorm.Model
	Id       string `json:"id" gorm:"uniqueIndex" yaml:"id"`
	Resource string `json:"resource" yaml:"resource"`
	Payload  string `json:"payload" yaml:"payload"`
	RoleId   string `json:"role_id" yaml:"roleId"`
	UserId   string `json:"user_id" yaml:"userId"`
}

type ACIRepository

type ACIRepository interface {
	Create(ctx context.Context, aci *ACI) error
	GetById(ctx context.Context, id string) (*ACI, error)
	GetByResource(ctx context.Context, resource string) ([]*ACI, error)
	GetByRoleId(ctx context.Context, roleId string) ([]*ACI, error)
	GetByPayload(ctx context.Context, payload string) ([]*ACI, error)
	GetByUserId(ctx context.Context, userId string) ([]*ACI, error)
	CheckByRoleId(ctx context.Context, roleId string, resource string, payload string) (bool, error)
	CheckByUserId(ctx context.Context, userId string, resource string, payload string) (bool, error)
	List(ctx context.Context, query *common.QueryOpts) (*common.ListResult[*ACI], error)
	Update(ctx context.Context, aci *ACI) error
	Delete(ctx context.Context, id string) error
	GetResourcesByUserIdAndPayload(ctx context.Context, userId string, payload string) ([]*ACI, error)
	GetResourcesByUserIdAndResource(ctx context.Context, userId string, resource string) ([]*ACI, error)
}

type ACIUseCase

type ACIUseCase interface {
	Create(ctx context.Context, aci *ACI) error
	GetById(ctx context.Context, id string) (*ACI, error)
	GetByResource(ctx context.Context, resource string) ([]*ACI, error)
	GetByRoleId(ctx context.Context, roleId string) ([]*ACI, error)
	GetByPayload(ctx context.Context, payload string) ([]*ACI, error)
	GetByUserId(ctx context.Context, userId string) ([]*ACI, error)
	GetResourcesByUserIdAndPayload(ctx context.Context, userId string, payload string) ([]*ACI, error)
	GetResourcesByUserIdAndResource(ctx context.Context, userId string, resource string) ([]*ACI, error)
	List(ctx context.Context, query *common.QueryOpts) (*common.ListResult[*ACI], error)
	Update(ctx context.Context, aci *ACI) error
	Delete(ctx context.Context, id string) error
}

type Auth

type Auth struct {
	gorm.Model
	Id        string `json:"id" gorm:"uniqueIndex" mapstructure:"id"`
	Username  string `json:"username" gorm:"uniqueIndex"`
	Password  string `json:"password" gorm:"-"`
	Hpassword string `json:"hpassword"`
	RoleId    string `json:"role_id" mapstructure:"role_id"`
}

type AuthRepository

type AuthRepository interface {
	Create(ctx context.Context, auth *Auth) error
	GetById(ctx context.Context, id string) (*Auth, error)
	GetStaticUserMap(ctx context.Context) map[string]*Auth
	GetByUsername(ctx context.Context, username string) (*Auth, error)
	GetByUsernameAndHpassword(ctx context.Context, username, hpassword string) (*Auth, error)
	Update(ctx context.Context, auth *Auth) error
	Delete(ctx context.Context, id string) error
	List(ctx context.Context, opt *common.QueryOpts) (*common.ListResult[*Auth], error)
}

type AuthUseCase

type AuthUseCase interface {
	SignUp(ctx context.Context, auth *Auth) error
	SignUpWithProvider(ctx context.Context, provider Provider, token string) error
	SignIn(ctx context.Context, username, password string) (token *Token, err error)
	SignInWithProvider(ctx context.Context, provider Provider, token string) (genToken *Token, err error)
	CheckAuth(ctx context.Context, uid string) (existed bool, err error)
	CheckAuthWithProvider(ctx context.Context, provider Provider, token string) (existed bool, err error)
	ChangePassword(ctx context.Context, uid, oldPassword, newPassword string) error
	ChangeRole(ctx context.Context, uid, roleId string) error
	Delete(ctx context.Context, id string) error
	Verify(ctx context.Context, token string) (auth *Auth, err error)
	List(ctx context.Context, opt *common.QueryOpts) (*common.ListResult[*Auth], error)
	GetByUsername(ctx context.Context, username string) (*Auth, error)
	GetById(ctx context.Context, id string) (*Auth, error)
	GetStaticUserList(ctx context.Context) (list *StaticUserList, err error)
}

type JwtGenerator

type JwtGenerator interface {
	GenerateToken(auth *Auth, payload map[string]interface{}) (string, error)
	VerifyToken(token string) (*Auth, map[string]interface{}, error)
}

type Provider

type Provider interface {
	VerifyToken(ctx context.Context, token string) (uid string, claims map[string]interface{}, err error)
}

type StaticUserList added in v0.1.2

type StaticUserList struct {
	List []*Auth `json:"static_users" yaml:"static_users" mapstructure:"static_users"`
}

type Token

type Token struct {
	Jwt    string `json:"jwt"`
	Id     string `json:"id"`
	UserId string `json:"user_id"`
	RoleId string `json:"role_id"`
}

Jump to

Keyboard shortcuts

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