auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TOKEN token key
	TOKEN = "token"
	// UID uid key
	UID = "uid"
	// CurrentUser current-user key
	CurrentUser = "currentUser"
	// IsAdmin is-admin key
	IsAdmin = "isAdmin"
)
View Source
const (
	// RoleAdmin admin role
	RoleAdmin = "admin"
	// RoleRoot root role
	RoleRoot = "root"
	// UserTypeEmail email user
	UserTypeEmail = "email"

	// DefaultResourceType default resource type
	DefaultResourceType = "-"
	// DefaultResourceID default resourc id
	DefaultResourceID = 0
)

Variables

This section is empty.

Functions

func Action added in v0.2.0

func Action(fn func(*cli.Context, *inject.Graph) error) cli.ActionFunc

Action ioc action

Types

type Attachment

type Attachment struct {
	web.Model

	Title        string `json:"title"`
	URL          string `json:"url"`
	Length       int64  `json:"length"`
	MediaType    string `json:"mediaType"`
	ResourceType string `json:"resourceType"`
	ResourceID   uint   `json:"resourceId"`

	UserID uint `json:"userId"`
	User   User `json:"-"`
}

Attachment attachment

func (*Attachment) IsPicture added in v0.4.1

func (p *Attachment) IsPicture() bool

IsPicture is picture?

func (Attachment) TableName

func (Attachment) TableName() string

TableName table name

type Dao added in v0.2.0

type Dao struct {
	Db       *gorm.DB      `inject:""`
	Security *web.Security `inject:""`
	I18n     *web.I18n     `inject:""`
}

Dao auth dao

func (*Dao) AddEmailUser added in v0.2.0

func (p *Dao) AddEmailUser(name, email, password string) (*User, error)

AddEmailUser add email user

func (*Dao) Allow added in v0.2.0

func (p *Dao) Allow(role, user uint, years, months, days int) error

Allow allow permission

func (*Dao) Authority added in v0.2.0

func (p *Dao) Authority(user uint, rty string, rid uint) []string

Authority get roles

func (*Dao) Can added in v0.2.0

func (p *Dao) Can(user uint, name string, rty string, rid uint) bool

Can can?

func (*Dao) Deny added in v0.2.0

func (p *Dao) Deny(role uint, user uint) error

Deny deny permission

func (*Dao) GetByEmail added in v0.2.0

func (p *Dao) GetByEmail(email string) (*User, error)

GetByEmail get user by email

func (*Dao) GetUserByUID added in v0.2.0

func (p *Dao) GetUserByUID(uid string) (*User, error)

GetUserByUID get user by uid

func (*Dao) Is added in v0.2.0

func (p *Dao) Is(user uint, names ...string) bool

Is is role ?

func (*Dao) Log added in v0.2.0

func (p *Dao) Log(user uint, ip, message string)

Log add log

func (*Dao) Role added in v0.2.0

func (p *Dao) Role(name string, rty string, rid uint) (*Role, error)

Role check role exist

func (*Dao) SignIn added in v0.4.1

func (p *Dao) SignIn(email, password, lang, ip string) (*User, error)

SignIn set sign-in info

type Engine added in v0.2.0

type Engine struct {
	Dao      *Dao          `inject:""`
	Db       *gorm.DB      `inject:""`
	Security *web.Security `inject:""`
	I18n     *web.I18n     `inject:""`
	Jwt      *Jwt          `inject:""`
	Uploader web.Uploader  `inject:""`
	Settings *web.Settings `inject:""`
	Queue    *web.Queue    `inject:""`
}

Engine engine

func (*Engine) Atom added in v0.2.0

func (p *Engine) Atom(lang string) ([]*atom.Entry, error)

Atom rss.atom

func (*Engine) Mount added in v0.2.0

func (p *Engine) Mount(rt *gin.Engine)

Mount web mount-points

func (*Engine) RegisterWorker added in v0.3.0

func (p *Engine) RegisterWorker()

RegisterWorker register worker

func (*Engine) Shell added in v0.2.0

func (p *Engine) Shell() []cli.Command

Shell shell commands

func (*Engine) Sitemap added in v0.2.0

func (p *Engine) Sitemap() ([]stm.URL, error)

Sitemap sitemap.xml.gz

type Jwt added in v0.2.0

type Jwt struct {
	Key    []byte               `inject:"jwt.key"`
	Method crypto.SigningMethod `inject:"jwt.method"`
	Dao    *Dao                 `inject:""`
	I18n   *web.I18n            `inject:""`
}

Jwt jwt helper

func (*Jwt) CurrentUserMiddleware added in v0.3.0

func (p *Jwt) CurrentUserMiddleware(c *gin.Context)

CurrentUserMiddleware current-user middleware

func (*Jwt) MustAdminMiddleware added in v0.3.0

func (p *Jwt) MustAdminMiddleware(c *gin.Context)

MustAdminMiddleware must-admin middleware

func (*Jwt) MustSignInMiddleware added in v0.3.0

func (p *Jwt) MustSignInMiddleware(c *gin.Context)

MustSignInMiddleware must-sign-in middleware

func (*Jwt) Sum added in v0.2.0

func (p *Jwt) Sum(cm jws.Claims, exp time.Duration) ([]byte, error)

Sum create jwt token

func (*Jwt) Validate added in v0.2.0

func (p *Jwt) Validate(buf []byte) (jwt.Claims, error)

Validate check jwt

type Log

type Log struct {
	ID        uint      `json:"id"`
	Message   string    `json:"message"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
	IP        string    `json:"ip"`

	UserID uint `json:"userId"`
	User   User `json:"-"`
}

Log log

func (Log) TableName

func (Log) TableName() string

TableName table name

type Policy

type Policy struct {
	web.Model

	StartUp  time.Time
	ShutDown time.Time

	UserID uint
	User   User
	RoleID uint
	Role   Role
}

Policy policy

func (*Policy) Enable

func (p *Policy) Enable() bool

Enable is enable?

func (Policy) TableName

func (Policy) TableName() string

TableName table name

type Role

type Role struct {
	web.Model

	Name         string
	ResourceID   uint
	ResourceType string
}

Role role

func (Role) String

func (p Role) String() string

func (Role) TableName

func (Role) TableName() string

TableName table name

type User

type User struct {
	web.Model

	Name            string     `json:"name"`
	Email           string     `json:"email"`
	UID             string     `json:"uid"`
	Password        []byte     `json:"-"`
	ProviderID      string     `json:"-"`
	ProviderType    string     `json:"providerType"`
	Home            string     `json:"home"`
	SignInCount     uint       `json:"signInCount"`
	LastSignInAt    *time.Time `json:"lastSignInAt"`
	LastSignInIP    string     `json:"lastSignInIp"`
	CurrentSignInAt *time.Time `json:"currentSignInAt"`
	CurrentSignInIP string     `json:"currentSignInIp"`
	ConfirmedAt     *time.Time `json:"confirmedAt"`
	LockedAt        *time.Time `json:"lockedAt"`

	Logs []Log `json:"-"`
}

User user

func (*User) IsConfirm

func (p *User) IsConfirm() bool

IsConfirm is confirm?

func (*User) IsLock

func (p *User) IsLock() bool

IsLock is lock?

func (p *User) SetGravatarLogo()

SetGravatarLogo set logo by gravatar

func (*User) SetUID

func (p *User) SetUID()

SetUID generate uid

func (User) String

func (p User) String() string

func (User) TableName

func (User) TableName() string

TableName table name

type Vote

type Vote struct {
	web.Model

	Point        int
	ResourceID   uint
	ResourceType string
}

Vote vote

func (Vote) TableName

func (Vote) TableName() string

TableName table name

Jump to

Keyboard shortcuts

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