Documentation ¶
Index ¶
- func Secret(i, l int) []byte
- func SendMail(to, subject, body string, html bool, files ...string)
- func Shell(cmd string, args ...string) error
- type AesHmacEncryptor
- type Dao
- func (p *Dao) AddUser(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(k string, v interface{}) error
- func (p *Dao) GetUser(uid string) (*User, error)
- func (p *Dao) Is(user uint, name string) bool
- func (p *Dao) Log(user uint, msg string)
- func (p *Dao) Role(name string, rty string, rid uint) (*Role, error)
- func (p *Dao) Set(k string, v interface{}, f bool) error
- func (p *Dao) UserClaims(u *User) jws.Claims
- type Encryptor
- type Engine
- type GoogleCredential
- type GoogleUser
- type Jwt
- type Log
- type Notice
- type NoticeFm
- type OauthFm
- type Permission
- type Role
- type Setting
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AesHmacEncryptor ¶
AesHmacEncryptor using hmac and aes
func (*AesHmacEncryptor) Decode ¶
func (p *AesHmacEncryptor) Decode(buf []byte) ([]byte, error)
Decode decode by aes
func (*AesHmacEncryptor) Encode ¶
func (p *AesHmacEncryptor) Encode(buf []byte) ([]byte, error)
Encode encode by aes
func (*AesHmacEncryptor) Equal ¶
func (p *AesHmacEncryptor) Equal(plain, code []byte) bool
Equal check hmac
type Dao ¶
type Dao struct { Db *gorm.DB `inject:""` Encryptor Encryptor `inject:""` Logger *logging.Logger `inject:""` }
Dao db helper
type Encryptor ¶
type Encryptor interface { Encode(buf []byte) ([]byte, error) Decode(buf []byte) ([]byte, error) Sum(buf []byte) []byte Equal(plain, code []byte) bool }
Encryptor for encrypt and decrypt
func NewAesHmacEncryptor ¶
NewAesHmacEncryptor new AesHmacEncryptor
type Engine ¶
type Engine struct { I18n *i18n.I18n `inject:""` Dao *Dao `inject:""` Jwt *Jwt `inject:""` Logger *logging.Logger `inject:""` Cache *web.Cache `inject:""` Oauth2GoogleState string `inject:"oauth2.google.state"` }
Engine platform engine
type GoogleCredential ¶
type GoogleCredential struct { Web struct { ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` RedirectURLS []string `json:"redirect_uris"` } `json:"web"` }
GoogleCredential google creadential
func (*GoogleCredential) To ¶
func (p *GoogleCredential) To() oauth2.Config
To to oauth2 config model
type GoogleUser ¶
type GoogleUser struct { ID string `json:"id"` Email string `json:"email"` Name string `json:"name"` Link string `json:"link"` Picture string `json:"picture"` }
GoogleUser google oauth user info
type Jwt ¶
type Jwt struct { Key []byte `inject:"jwt.key"` Method crypto.SigningMethod `inject:"jwt.method"` Logger *logging.Logger `inject:""` Redis *redis.Pool `inject:""` Dao *Dao `inject:""` }
Jwt jwt helper
func (*Jwt) CurrentUserHandler ¶
func (p *Jwt) CurrentUserHandler(must bool) gin.HandlerFunc
CurrentUserHandler inject current user
func (*Jwt) MustAdminHandler ¶
func (p *Jwt) MustAdminHandler() gin.HandlerFunc
MustAdminHandler check must have admin role
func (*Jwt) MustRolesHandler ¶
func (p *Jwt) MustRolesHandler(roles ...string) gin.HandlerFunc
MustRolesHandler check must have one roles at least
type Log ¶
type Log struct { ID uint `gorm:"primary_key" json:"id"` UserID uint `gorm:"not null" json:"-"` User User `json:"-"` Message string `gorm:"not null;type:VARCHAR(255)" json:"message"` CreatedAt time.Time `gorm:"not null;default:current_timestamp" json:"created_at"` }
Log model
type Notice ¶
type Notice struct { ID uint `gorm:"primary_key" json:"id"` Lang string `gorm:"not null;type:varchar(8);index" json:"lang"` Content string `gorm:"not null;type:text" json:"content"` CreatedAt time.Time `gorm:"not null;default:current_timestamp" json:"created_at"` }
Notice notice model
type NoticeFm ¶
type NoticeFm struct {
Content string `form:"content" binding:"required"`
}
NoticeFm form for notice
type Permission ¶
type Permission struct { web.Model User User UserID uint `gorm:"not null"` Role Role RoleID uint `gorm:"not null"` Begin time.Time `gorm:"not null;default:current_date;type:date"` End time.Time `gorm:"not null;default:'1000-1-1';type:date"` }
Permission permission model
type Role ¶
type Role struct { web.Model Name string `gorm:"not null;index;type:VARCHAR(255)"` ResourceType string `gorm:"not null;default:'-';index;type:VARCHAR(255)"` ResourceID uint `gorm:"not null;default:0"` }
Role role model
type Setting ¶
type Setting struct { web.Model Key string `gorm:"not null;unique;type:VARCHAR(255)"` Val []byte `gorm:"not null"` Flag bool `gorm:"not null"` }
Setting setting model
type User ¶
type User struct { web.Model Email string `gorm:"not null;index;type:VARCHAR(255)" json:"email"` UID string `gorm:"not null;unique_index;type:char(36)" json:"uid"` Home string `gorm:"not null;type:VARCHAR(255)" json:"home"` Logo string `gorm:"not null;type:VARCHAR(255)" json:"logo"` Name string `gorm:"not null;type:VARCHAR(255)" json:"name"` Password string `gorm:"not null;default:'-';type:VARCHAR(500)" json:"-"` ProviderType string `gorm:"not null;default:'unknown';index;type:VARCHAR(255)" json:"provider_type"` ProviderID string `gorm:"not null;index;type:VARCHAR(255)" json:"provider_id"` LastSignIn *time.Time `json:"last_sign_in"` SignInCount uint `gorm:"not null;default:0" json:"sign_in_count"` ConfirmedAt *time.Time `json:"confirmed_at"` LockedAt *time.Time `json:"locked_at"` Permissions []Permission `json:"permissions"` Logs []Log `json:"logs"` }
User user model
Click to show internal directories.
Click to hide internal directories.