auth

package
v0.0.0-...-beacdf2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TOKEN token session 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
)
View Source
const (

	// SendEmailJob send email
	SendEmailJob = "send-email"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	web.Model

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

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

Attachment attachment

func (*Attachment) IsPicture

func (p *Attachment) IsPicture() bool

IsPicture is picture?

func (Attachment) TableName

func (Attachment) TableName() string

TableName table name

type Dao

type Dao struct {
	Db   *gorm.DB       `inject:""`
	Hmac *security.Hmac `inject:""`
	I18n *i18n.I18n     `inject:""`
}

Dao auth dao

func (*Dao) AddEmailUser

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

AddEmailUser add email user

func (*Dao) Allow

func (p *Dao) Allow(role, 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 roles

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) GetByEmail

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

GetByEmail 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, names ...string) bool

Is is role ?

func (*Dao) Log

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

Log add log

func (*Dao) Resources

func (p *Dao) Resources(user uint, role, rty string) ([]uint, error)

Resources list resource ids by user and role

func (*Dao) Role

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

Role check role exist

func (*Dao) SignIn

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

SignIn set sign-in info

func (*Dao) Users

func (p *Dao) Users(role, rty string, rid uint) ([]uint, error)

Users list users by resource

type Jwt

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

Jwt jwt helper

func (*Jwt) CurrentUserMiddleware

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

CurrentUserMiddleware current-user middleware

func (*Jwt) MustAdminMiddleware

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

MustAdminMiddleware must has admin role

func (*Jwt) MustSignInMiddleware

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

MustSignInMiddleware must sign-in

func (*Jwt) Sum

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

Sum create jwt token

func (*Jwt) Validate

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

Validate check jwt

type Log

type Log struct {
	web.Timestamp

	Message string `json:"message"`
	Type    string `json:"type"`
	IP      string `json:"ip"`

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

Log log

func (Log) String

func (p Log) String() string

func (Log) TableName

func (Log) TableName() string

TableName table name

type Plugin

type Plugin struct {
	Dao      *Dao               `inject:""`
	Jwt      *Jwt               `inject:""`
	Db       *gorm.DB           `inject:""`
	I18n     *i18n.I18n         `inject:""`
	Cache    *cache.Cache       `inject:""`
	Uploader uploader.Store     `inject:""`
	Hmac     *security.Hmac     `inject:""`
	Server   *job.Server        `inject:""`
	Settings *settings.Settings `inject:""`
}

Plugin plugin

func (*Plugin) Atom

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

Atom rss.atom

func (*Plugin) Console

func (p *Plugin) Console() []cli.Command

Console console commands

func (*Plugin) Mount

func (p *Plugin) Mount(rt *axe.Router)

Mount mount web points

func (*Plugin) Open

func (p *Plugin) Open(*inject.Graph) error

Open open beans

func (*Plugin) Sitemap

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

Sitemap sitemap.xml.gz

func (*Plugin) Workers

func (p *Plugin) Workers() map[string]job.Handler

Workers job handler

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" gorm:"column: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