vault

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceManagerUser = "manage-users"
	ResourceBasicUser   = "basic-user"
)

Variables

This section is empty.

Functions

func AddUser

func AddUser(rail miso.Rail, tx *gorm.DB, req AddUserParam, operator string) error

func AddUserEp

func AddUserEp(c *gin.Context, rail miso.Rail, req AddUserParam) (any, error)

func AdminUpdateUser

func AdminUpdateUser(rail miso.Rail, tx *gorm.DB, req AdminUpdateUserReq, operator common.User) error

func BootstrapServer

func BootstrapServer(args []string)

func DecodeTokenUsername

func DecodeTokenUsername(rail miso.Rail, token string) (string, error)

func DeleteUserKey

func DeleteUserKey(rail miso.Rail, tx *gorm.DB, req DeleteUserKeyReq, userId int) error

func DeleteUserKeyEp

func DeleteUserKeyEp(c *gin.Context, rail miso.Rail, req DeleteUserKeyReq) (any, error)

func ExchangeToken

func ExchangeToken(rail miso.Rail, tx *gorm.DB, req ExchangeTokenReq) (string, error)

func ExchangeTokenEp

func ExchangeTokenEp(c *gin.Context, rail miso.Rail, req ExchangeTokenReq) (any, error)

func FindUsername

func FindUsername(rail miso.Rail, tx *gorm.DB, username string) (string, error)

func GenUserKey

func GenUserKey(rail miso.Rail, tx *gorm.DB, req GenUserKeyReq, username string) error

func GenUserKeyEp

func GenUserKeyEp(c *gin.Context, rail miso.Rail, req GenUserKeyReq) (any, error)

func GetUserDetailEp

func GetUserDetailEp(c *gin.Context, rail miso.Rail) (any, error)

func GetUserInfEp

func GetUserInfEp(c *gin.Context, rail miso.Rail) (any, error)

func GetUserTokenEp

func GetUserTokenEp(c *gin.Context, rail miso.Rail) (any, error)

func InvalidateUserInfoCache

func InvalidateUserInfoCache(rail miso.Rail, username string) error

func ItnFetchNameByIdEp added in v0.0.15

func ItnFetchNameByIdEp(c *gin.Context, rail miso.Rail) (any, error)

func ItnFetchNameByUserNoEp added in v0.0.15

func ItnFetchNameByUserNoEp(c *gin.Context, rail miso.Rail, req api.FetchNameByUserNoReq) (any, error)

func ItnFetchUserIdEp added in v0.0.15

func ItnFetchUserIdEp(c *gin.Context, rail miso.Rail) (any, error)

func ItnFetchUserInfoEp added in v0.0.15

func ItnFetchUserInfoEp(c *gin.Context, rail miso.Rail, req api.FindUserReq) (any, error)

func ItnFetchUsersWithRoleEp added in v0.0.15

func ItnFetchUsersWithRoleEp(c *gin.Context, rail miso.Rail, req api.FetchUsersWithRoleReq) (any, error)

func ItnFindNameOfUserNo

func ItnFindNameOfUserNo(rail miso.Rail, tx *gorm.DB, req api.FetchNameByUserNoReq) (api.FetchUsernamesRes, error)

func ItnFindUserInfo

func ItnFindUserInfo(rail miso.Rail, tx *gorm.DB, req api.FindUserReq) (api.UserInfo, error)

func ItnFindUsersWithRole added in v0.0.15

func ItnFindUsersWithRole(rail miso.Rail, db *gorm.DB, req api.FetchUsersWithRoleReq) ([]api.UserInfo, error)

func ListAccessLogEp

func ListAccessLogEp(c *gin.Context, rail miso.Rail, req ListAccessLogReq) (any, error)

func ListAccessLogs

func ListAccessLogs(rail miso.Rail, tx *gorm.DB, user common.User, req ListAccessLogReq) (miso.PageRes[ListedAccessLog], error)

func ListUserEp

func ListUserEp(c *gin.Context, rail miso.Rail, req ListUserReq) (any, error)

func ListUserKeyEp

func ListUserKeyEp(c *gin.Context, rail miso.Rail, req ListUserKeysReq) (any, error)

func ListUserKeys

func ListUserKeys(rail miso.Rail, tx *gorm.DB, req ListUserKeysReq, user common.User) (miso.PageRes[ListedUserKey], error)

func ListUsers

func ListUsers(rail miso.Rail, tx *gorm.DB, req ListUserReq) (miso.PageRes[api.UserInfo], error)

func RemoteAddr

func RemoteAddr(forwardedFor string) string

func ReviewUserRegistration

func ReviewUserRegistration(rail miso.Rail, tx *gorm.DB, req AdminReviewUserReq) error

func ReviewUserRegistrationEp

func ReviewUserRegistrationEp(c *gin.Context, rail miso.Rail, req AdminReviewUserReq) (any, error)

func SaveAccessLogEvent

func SaveAccessLogEvent(rail miso.Rail, tx *gorm.DB, evt AccessLogEvent) error

func UpdatePassword

func UpdatePassword(rail miso.Rail, tx *gorm.DB, username string, req UpdatePasswordReq) error

func UpdatePasswordEp

func UpdatePasswordEp(c *gin.Context, rail miso.Rail, req UpdatePasswordReq) (any, error)

func UpdateUserEp

func UpdateUserEp(c *gin.Context, rail miso.Rail, req AdminUpdateUserReq) (any, error)

func UserLoginEp

func UserLoginEp(gin *gin.Context, rail miso.Rail, req LoginReq) (any, error)

func UserRegister

func UserRegister(rail miso.Rail, tx *gorm.DB, req RegisterReq) error

func UserReqRegisterEp

func UserReqRegisterEp(c *gin.Context, rail miso.Rail, req RegisterReq) (any, error)

Types

type AccessLog

type AccessLog struct {
	Id         int
	UserAgent  string
	IpAddress  string
	UserId     int
	Username   string
	Url        string
	AccessTime miso.ETime
	CreateTime miso.ETime
	CreateBy   string
	UpdateTime miso.ETime
	UpdateBy   string
	IsDel      common.IS_DEL
}

type AccessLogEvent

type AccessLogEvent struct {
	UserAgent  string     `json:"userAgent"`
	IpAddress  string     `json:"ipAddress"`
	UserId     int        `json:"userId"`
	Username   string     `json:"username"`
	Url        string     `json:"url"`
	AccessTime miso.ETime `json:"accessTime"`
}

type AddUserParam

type AddUserParam struct {
	Username string `json:"username" valid:"notEmpty"`
	Password string `json:"password" valid:"notEmpty"`
	RoleNo   string `json:"roleNo"`
}

type AdminAddUserReq

type AdminAddUserReq struct {
	Username string `json:"username" valid:"notEmpty"`
	Password string `json:"password" valid:"notEmpty"`
	RoleNo   string `json:"roleNo" valid:"notEmpty"`
}

type AdminReviewUserReq

type AdminReviewUserReq struct {
	UserId       int    `json:"userId" valid:"positive"`
	ReviewStatus string `json:"reviewStatus"`
}

type AdminUpdateUserReq

type AdminUpdateUserReq struct {
	Id         int    `json:"id" valid:"positive"`
	RoleNo     string `json:"roleNo" valid:"notEmpty"`
	IsDisabled int    `json:"isDisabled"`
}

type DeleteUserKeyReq

type DeleteUserKeyReq struct {
	UserKeyId int `json:"userKeyId"`
}

type ExchangeTokenReq

type ExchangeTokenReq struct {
	Token string `json:"token" valid:"notEmpty"`
}

type GenUserKeyReq

type GenUserKeyReq struct {
	Password string `json:"password" valid:"notEmpty"`
	KeyName  string `json:"keyName" valid:"notEmpty"`
}

type ListAccessLogReq

type ListAccessLogReq struct {
	Paging miso.Paging `json:"pagingVo"`
}

type ListUserKeysReq

type ListUserKeysReq struct {
	Paging miso.Paging `json:"pagingVo"`
	Name   string      `json:"name"`
}

type ListUserReq

type ListUserReq struct {
	Username   *string     `json:"username"`
	RoleNo     *string     `json:"roleNo"`
	IsDisabled *int        `json:"isDisabled"`
	Paging     miso.Paging `json:"pagingVo"`
}

type ListedAccessLog

type ListedAccessLog struct {
	Id         int        `json:"id"`
	UserAgent  string     `json:"userAgent"`
	IpAddress  string     `json:"ipAddress"`
	Username   string     `json:"username"`
	Url        string     `json:"url"`
	AccessTime miso.ETime `json:"accessTime"`
}

type ListedUserKey

type ListedUserKey struct {
	Id             int        `json:"id"`
	SecretKey      string     `json:"secretKey"`
	Name           string     `json:"name"`
	ExpirationTime miso.ETime `json:"expirationTime"`
	CreateTime     miso.ETime `json:"createTime"`
}

type LoginReq

type LoginReq struct {
	Username string `json:"username" valid:"notEmpty"`
	Password string `json:"password" valid:"notEmpty"`
}

type NewUserKey

type NewUserKey struct {
	Name           string
	SecretKey      string
	ExpirationTime miso.ETime
	UserId         int
}

type PasswordLoginParam

type PasswordLoginParam struct {
	Username string
	Password string
}

type RegisterReq

type RegisterReq struct {
	Username string `json:"username" valid:"notEmpty"`
	Password string `json:"password" valid:"notEmpty"`
}

type RoleInfoReq added in v0.0.14

type RoleInfoReq struct {
	RoleNo string `json:"roleNo" `
}

type RoleInfoResp added in v0.0.14

type RoleInfoResp struct {
	RoleNo string `json:"roleNo"`
	Name   string `json:"name"`
}

func GetRoleInfo added in v0.0.14

func GetRoleInfo(rail miso.Rail, req RoleInfoReq) (*RoleInfoResp, error)

Retrieve role information

type TokenUser

type TokenUser struct {
	Id       int
	UserNo   string
	Username string
	RoleNo   string
}

func DecodeTokenUser

func DecodeTokenUser(rail miso.Rail, token string) (TokenUser, error)

type UpdatePasswordReq

type UpdatePasswordReq struct {
	PrevPassword string `json:"prevPassword" valid:"notEmpty"`
	NewPassword  string `json:"newPassword" valid:"notEmpty"`
}

type User

type User struct {
	Id           int
	UserNo       string
	Username     string
	Password     string
	Salt         string
	ReviewStatus string
	RoleNo       string
	IsDisabled   int
	CreateTime   miso.ETime
	CreateBy     string
	UpdateTime   miso.ETime
	UpdateBy     string
	IsDel        common.IS_DEL
}

func UserLogin

func UserLogin(rail miso.Rail, tx *gorm.DB, req PasswordLoginParam) (string, User, error)

func (*User) CanReview

func (u *User) CanReview() bool

func (*User) Deleted

func (u *User) Deleted() bool

type UserDetail

type UserDetail struct {
	Id           int    `json:"id"`
	Username     string `json:"username"`
	RoleName     string `json:"roleName"`
	RoleNo       string `json:"roleNo"`
	UserNo       string `json:"userNo"`
	RegisterDate string `json:"registerDate"`
	Password     string `json:"password"`
	Salt         string `json:"salt"`
}

func LoadUserBriefThrCache

func LoadUserBriefThrCache(rail miso.Rail, tx *gorm.DB, username string) (UserDetail, error)

func LoadUserInfoBrief

func LoadUserInfoBrief(rail miso.Rail, tx *gorm.DB, username string) (UserDetail, error)

type UserInfoBrief

type UserInfoBrief struct {
	Id           int    `json:"id"`
	Username     string `json:"username"`
	RoleName     string `json:"roleName"`
	RoleNo       string `json:"roleNo"`
	UserNo       string `json:"userNo"`
	RegisterDate string `json:"registerDate"`
}

func FetchUserBrief

func FetchUserBrief(rail miso.Rail, tx *gorm.DB, username string) (UserInfoBrief, error)

func GetTokenUser

func GetTokenUser(rail miso.Rail, tx *gorm.DB, token string) (UserInfoBrief, error)

Jump to

Keyboard shortcuts

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