domain

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrACINotFound      = errors.New("aci not found")
	ErrPermissionDenied = errors.New("permission denied")
)
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")
)
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)
}

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)
}

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
}

type AuthUseCase

type AuthUseCase interface {
	SignUp(ctx context.Context, auth *Auth) error
	SignIn(ctx context.Context, username, password string) (token *Token, err error)
	SignInWithProvider(ctx context.Context, provider Provider, token string) (genToken *Token, 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