auth

package
v0.0.0-...-f2087ef Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(f cli.ActionFunc) cli.ActionFunc

Action load config action

func IocAction

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

IocAction ioc action

func IsProduction

func IsProduction() bool

IsProduction is production mode?

func OpenDatabase

func OpenDatabase() (*gorm.DB, error)

OpenDatabase open database

func OpenLogger

func OpenLogger() *logging.Logger

OpenLogger open logger

func OpenRedis

func OpenRedis() *redis.Pool

OpenRedis get redis connection pool

Types

type Attachment

type Attachment struct {
	web.Model

	Title     string
	Name      string
	MediaType string
	Summary   string

	UserID uint
	User   User
}

Attachment attachment

type Dao

type Dao struct {
	Db        *gorm.DB        `inject:""`
	Encryptor *web.Encryptor  `inject:""`
	Logger    *logging.Logger `inject:""`
}

Dao db helper

func (*Dao) AddOpenIDUser

func (p *Dao) AddOpenIDUser(pid, pty, email, name, home, logo string) (*User, error)

AddOpenIDUser add openid user

func (*Dao) Allow

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

Allow allow permission

func (*Dao) Authority

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

Authority get user's role names

func (*Dao) Can

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

Can can?

func (*Dao) Deny

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

Deny deny permission

func (*Dao) Get

func (p *Dao) Get(k string, v interface{}) error

Get get setting value by key

func (*Dao) GetUserByEmail

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

GetUserByEmail get user by email

func (*Dao) GetUserByUID

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

GetUserByUID get user by uid

func (*Dao) Is

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

Is is role ?

func (*Dao) Log

func (p *Dao) Log(user uint, msg string)

Log add log

func (*Dao) Role

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

Role check role exist

func (*Dao) Set

func (p *Dao) Set(k string, v interface{}, f bool) error

Set save setting

func (*Dao) SignIn

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

SignIn sign in

func (*Dao) SignUp

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

SignUp sign up

func (*Dao) UserClaims

func (p *Dao) UserClaims(u *User) jws.Claims

UserClaims generate user claims

type Engine

type Engine struct {
	Cache     cache.Store     `inject:""`
	Db        *gorm.DB        `inject:""`
	Jobber    jobber.Jobber   `inject:""`
	Logger    *logging.Logger `inject:""`
	Encryptor *web.Encryptor  `inject:""`
	I18n      *i18n.I18n      `inject:""`
}

Engine engine model

func (*Engine) Map

func (p *Engine) Map(inj *inject.Graph) error

Map map objects

func (*Engine) Mount

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

Mount mount web point

func (*Engine) Shell

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

Shell command line

func (*Engine) Worker

func (p *Engine) Worker()

Worker do background job

type Jwt

type Jwt struct {
	Key    []byte               `inject:"jwt.key"`
	Method crypto.SigningMethod `inject:"jwt.method"`
	Logger *logging.Logger      `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

func (*Jwt) Sum

func (p *Jwt) Sum(cm jws.Claims, days int) ([]byte, error)

Sum create jwt token

func (*Jwt) Validate

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

Validate check jwt

type LeaveWord

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"`
	UserID    uint      `json:"-"`
	User      User      `json:"-"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

Log model

type Notice

type Notice struct {
	web.Model
	Lang    string `json:"lang"`
	Content string `json:"content"`
}

Notice notice

type Permission

type Permission struct {
	web.Model
	User   User
	UserID uint
	Role   Role
	RoleID uint
	Begin  time.Time
	End    time.Time
}

Permission permission model

func (*Permission) BeginS

func (p *Permission) BeginS() string

BeginS begin to string

func (*Permission) Enable

func (p *Permission) Enable() bool

Enable is enable?

func (*Permission) EndS

func (p *Permission) EndS() string

EndS end to string

type Role

type Role struct {
	web.Model

	Name         string
	ResourceType string
	ResourceID   uint
}

Role role model

func (Role) String

func (p Role) String() string

type Setting

type Setting struct {
	web.Model

	Key    string
	Val    []byte
	Encode bool
}

Setting setting

type User

type User struct {
	web.Model
	Email    string `json:"email"`
	UID      string `json:"uid"`
	Home     string `json:"home"`
	Name     string `json:"name"`
	Password []byte `json:"-"`

	ProviderType string `json:"provider_type"`
	ProviderID   string `json:"provider_id"`

	LastSignIn  *time.Time `json:"last_sign_in"`
	SignInCount uint       `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

func (*User) IsAvailable

func (p *User) IsAvailable() bool

IsAvailable is valid?

func (*User) IsConfirmed

func (p *User) IsConfirmed() bool

IsConfirmed confirmed?

func (*User) IsLocked

func (p *User) IsLocked() bool

IsLocked locked?

func (p *User) SetGravatarLogo()

SetGravatarLogo set logo by gravatar

func (User) String

func (p User) String() string

Jump to

Keyboard shortcuts

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