Documentation ¶
Index ¶
- Constants
- func CreateCertificate(ca bool, subject pkix.Name, years int) ([]byte, []byte, error)
- func WritePemFile(file, _type string, buf []byte) error
- type Dao
- func (p *Dao) AddEmailUser(lang, email, name, password string) (*User, error)
- func (p *Dao) AddOpenIDUser(pid, pty, email, name, home, logo string) (*User, error)
- func (p *Dao) Allow(role uint, user uint, years, months, days int) error
- func (p *Dao) Authority(user uint, rty string, rid uint) []string
- func (p *Dao) Can(user uint, name string, rty string, rid uint) bool
- func (p *Dao) Deny(role uint, user uint) error
- func (p *Dao) Get(key string, val interface{}) error
- func (p *Dao) GetUserByEmail(email string) (*User, error)
- func (p *Dao) GetUserByUID(uid string) (*User, error)
- func (p *Dao) Is(user uint, name string) bool
- func (p *Dao) Log(user uint, msg string)
- func (p *Dao) Logf(user uint, lang, format string, args ...interface{})
- func (p *Dao) Role(name string, rty string, rid uint) (*Role, error)
- func (p *Dao) Set(key string, val interface{}, flag bool) error
- func (p *Dao) UserClaims(u *User) jws.Claims
- type Engine
- type Jwt
- type Leaveword
- type Log
- type Notice
- type Permission
- type Role
- type SMTP
- type Setting
- type User
Constants ¶
View Source
const ( //DefaultResourceType default resource-type DefaultResourceType = "-" //DefaultResourceID default resource-id DefaultResourceID = 0 //RoleAdmin admin RoleAdmin = "admin" //RoleRoot root RoleRoot = "root" )
View Source
const CurrentUser = "current-user"
CurrentUser current user key
View Source
const (
//ProvideTypeEmail email provuder-type
ProvideTypeEmail = "email"
)
Variables ¶
This section is empty.
Functions ¶
func CreateCertificate ¶ added in v0.2.0
CreateCertificate create certs
func WritePemFile ¶ added in v0.2.0
WritePemFile wirte to a pem format file
Types ¶
type Dao ¶ added in v0.2.0
type Dao struct { Db *gorm.DB `inject:""` Cache *web.Cache `inject:""` Aes *web.Aes `inject:""` Hmac *web.Hmac `inject:""` I18n *web.I18n `inject:""` }
Dao dao
func (*Dao) AddEmailUser ¶ added in v0.2.0
AddEmailUser add email user
func (*Dao) AddOpenIDUser ¶ added in v0.2.0
AddOpenIDUser add openid user
func (*Dao) GetUserByEmail ¶ added in v0.2.0
GetUserByEmail get user by email
func (*Dao) GetUserByUID ¶ added in v0.2.0
GetUserByUID get user by uid
type Engine ¶ added in v0.2.0
type Engine struct { I18n *web.I18n `inject:""` Cache *web.Cache `inject:""` Hmac *web.Hmac `inject:""` Server *machinery.Server `inject:""` Dao *Dao `inject:""` Db *gorm.DB `inject:""` Jwt *Jwt `inject:""` }
Engine auth engine
type Jwt ¶ added in v0.2.0
type Jwt struct { Key []byte `inject:"jwt.key"` Method crypto.SigningMethod `inject:"jwt.method"` Dao *Dao `inject:""` }
Jwt jwt helper
func (*Jwt) CurrentUserHandler ¶ added in v0.2.0
func (p *Jwt) CurrentUserHandler(must bool) gin.HandlerFunc
CurrentUserHandler inject current user
func (*Jwt) MustAdminHandler ¶ added in v0.2.0
func (p *Jwt) MustAdminHandler() gin.HandlerFunc
MustAdminHandler check must have admin role
func (*Jwt) MustRolesHandler ¶ added in v0.2.0
func (p *Jwt) MustRolesHandler(roles ...string) gin.HandlerFunc
MustRolesHandler check must have one roles at least
type Leaveword ¶ added in v0.2.0
type Leaveword struct { ID uint `json:"id"` Content string `json:"content"` CreatedAt time.Time `json:"created_at"` }
Leaveword leave word
type Log ¶
type Log struct { ID uint `json:"id"` Message string `json:"message"` CreatedAt time.Time `json:"created_at"` UserID uint `json:"user_id"` User User `json:"user"` }
Log model
type Permission ¶
type Permission struct { web.Model StartUp time.Time `json:"start_up"` ShutDown time.Time `json:"shut_down"` UserID uint `json:"user_id"` User User `json:"user"` RoleID uint `json:"role_id"` Role Role `json:"role"` }
Permission permission model
type Role ¶
type Role struct { web.Model Name string `json:"name"` ResourceType string `json:"resource_type"` ResourceID uint `json:"resource_id"` Permissions []Permission `json:"permissions"` }
Role role model
type SMTP ¶ added in v0.2.0
type SMTP struct { From string `json:"form"` Username string `json:"username"` Password string `json:"-"` Host string `json:"host"` Port int `json:"port"` }
SMTP smtp config
type User ¶
type User struct { web.Model Email string `json:"email"` UID string `json:"uid"` Home string `json:"home"` Logo string `json:"logo"` Name string `json:"name"` Password []byte `json:"-"` ProviderType string `json:"provider_type"` ProviderID string `json:"provider_id"` LastSignInAt *time.Time `json:"last_sign_in_at"` LastSignInIP string `json:"last_sign_in_ip"` CurrentSignInAt *time.Time `json:"current_sign_in_at"` CurrentSignInIP string `json:"current_sign_in_ip"` SignInCount uint `json:"sign_in_count"` ConfirmedAt *time.Time `json:"confirmed_at"` LockedAt *time.Time `json:"locked_at"` Logs []Log `json:"logs"` Permissions []Permission `json:"permissions"` }
User user model
func (*User) SetGravatarLogo ¶
func (p *User) SetGravatarLogo()
SetGravatarLogo set logo by gravatar
Click to show internal directories.
Click to hide internal directories.