auth

package
v0.0.0-...-c17893f Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

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

func (*Dao) Allow

func (p *Dao) Allow(role uint, user uint, dur time.Duration) error

Allow set allow permission

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 set deny permission

func (*Dao) GetUser

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

GetUser get user by uid

func (*Dao) Is

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

Is is?

func (*Dao) Role

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

Role insure role name exists

type Engine

type Engine struct {
	Db     *gorm.DB        `inject:""`
	Logger *logging.Logger `inject:""`
}

func (*Engine) Assets

func (p *Engine) Assets() error

func (*Engine) Map

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

func (*Engine) Migrate

func (p *Engine) Migrate()

func (*Engine) Mount

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

func (*Engine) Seed

func (p *Engine) Seed()

func (*Engine) Shell

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

type Google

type Google struct {
	Web struct {
		ClientID     string   `json:"client_id"`
		ClientSecret string   `json:"client_secret"`
		RedirectURLS []string `json:"redirect_uris"`
	} `json:"web"`
}

Google google credentials model

func ReadGoogle

func ReadGoogle(f string) (*Google, error)

ReadGoogle read google credentials.

func (*Google) Parse

func (p *Google) Parse(code string) (*GoogleUser, error)

Parse parse user from request

func (*Google) To

func (p *Google) To() *oauth2.Config

To to oauth2 credentials

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 user model

func (*GoogleUser) Save

func (p *GoogleUser) Save(db *gorm.DB) (*User, error)

Save save user to database

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 log model

type Permission

type Permission struct {
	gails.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

func (*Permission) BeginS

func (p *Permission) BeginS() string

BeginS begintime

func (*Permission) Enable

func (p *Permission) Enable() bool

Enable is enable?

func (*Permission) EndS

func (p *Permission) EndS() string

EndS endtime

type Role

type Role struct {
	gails.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

func (Role) String

func (p Role) String() string

type User

type User struct {
	gorm.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"`
	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)"`
	ProviderID   string `gorm:"not null;index;type:VARCHAR(255)"`

	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"`
}

func (*User) IsAvailable

func (p *User) IsAvailable() bool

IsAvailable is available?

func (*User) IsConfirmed

func (p *User) IsConfirmed() bool

IsConfirmed is confirmed?

func (*User) IsLocked

func (p *User) IsLocked() bool

IsLocked is locked?

func (*User) SetGravatar

func (p *User) SetGravatar()

SetGravatar set gravatar logo

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