Documentation
¶
Index ¶
- Constants
- Variables
- func Captcha(c *gin.Context, length ...int)
- func CaptchaVerify(c *gin.Context, code string) bool
- func CheckPassword(plainText, cipherText string) bool
- func CreateAccess(c *Access)
- func CreateDb(fileName string)
- func CreateUser(db *gorm.DB, user *User)
- func DeleteAccess(hash string)
- func EncryptAlg(origData string) string
- func ListAllAccesses(userName string) map[string]bool
- func ListRolesExpectSuperAdmin() []string
- func MD5(s string) string
- func OpenDb(fileName string)
- func RegisterOne(username, password, tel string) bool
- func ResetPassword(userName, password, tel string) bool
- func RoleAddAccess(grade string, accesses ...string) bool
- func Serve(w http.ResponseWriter, r *http.Request, id, ext, lang string, download bool, ...) error
- func Session(keyPairs string) gin.HandlerFunc
- func SessionConfig() sessions.Store
- func UserAddRole(userName string, grade ...string) bool
- func VerifyUser(userName, password string) bool
- type Access
- type Role
- type User
Constants ¶
View Source
const CommonRole = "common"
View Source
const SuperRole = "super"
Variables ¶
View Source
var Db *gorm.DB
Functions ¶
func CaptchaVerify ¶
CaptchaVerify 验证 code是从前端拿到的用户输入的验证码
func CheckPassword ¶
func CreateUser ¶
func EncryptAlg ¶
func ListAllAccesses ¶
func ListRolesExpectSuperAdmin ¶
func ListRolesExpectSuperAdmin() []string
TODO: 当得到一个新的反弹shell要把他记录在数据库中 所有server创建时都会归到超级管理员手里
func RegisterOne ¶
func ResetPassword ¶
ResetPassword 输入的参数都是经过检查的, 包含内容的
func RoleAddAccess ¶
func Serve ¶
func Serve(w http.ResponseWriter, r *http.Request, id, ext, lang string, download bool, width, height int) error
Serve 生成图片
func UserAddRole ¶
UserAddRole 创建一个超级管理员页面, oauth验证只有超级管理员才可以打开, 可以实现以下操作
func VerifyUser ¶
Types ¶
type Access ¶
type Access struct {
gorm.Model
Host string `json:"host"`
Port uint16 `json:"port"`
Hash string `json:"hash"`
User string `json:"user"`
OS oss.OperatingSystem `json:"os"`
TimeStamp time.Time `json:"timestamp"`
}
func (Access) AfterCreate ¶
AfterCreate 创建一个新的server之后会将该server归入超级管理员
type Role ¶
type Role struct {
gorm.Model
Grade string `json:"grade"`
//Users []User `gorm:"many2many:role_users;"`
Accesses []Access `gorm:"many2many:role_accesses;" json:"accesses"`
}
func (*Role) ListAccesses ¶
type User ¶
type User struct {
gorm.Model
UserName string `json:"username"` // 和sql表有关, UserName -> user_name; UserMM -> user_m_m
Password string `json:"password"`
Tel string `json:"tel"`
Roles []Role `gorm:"many2many:user_roles;" json:"roles"`
}
func (*User) BeforeCreate ¶
BeforeCreate 创建用户之前的hook, 将密码aes加密一下
Click to show internal directories.
Click to hide internal directories.