auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEngine

type AuthEngine struct {
	core.Controller

	SiteDao *site.Dao      `inject:""`
	Db      *gorm.DB       `inject:""`
	Dao     *Dao           `inject:""`
	Cfg     *config.Model  `inject:""`
	Token   token.Provider `inject:""`
	Render  *render.Render `inject:""`
	Session *Session       `inject:""`
}

func (*AuthEngine) Asserts

func (p *AuthEngine) Asserts() []*core.Template

func (*AuthEngine) Migrate

func (p *AuthEngine) Migrate()

func (*AuthEngine) Mount

func (p *AuthEngine) Mount(rt core.Router)

func (*AuthEngine) Rss

func (p *AuthEngine) Rss() rss.Handler

func (*AuthEngine) Seed

func (p *AuthEngine) Seed() error

func (*AuthEngine) Shell

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

func (*AuthEngine) Sitemap

func (p *AuthEngine) Sitemap() sitemap.Handler

type Dao

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

func (*Dao) Allow

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

func (*Dao) Can

func (p *Dao) Can(user uint, name string, resource_type string, resource_id uint) bool

func (*Dao) Deny

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

func (*Dao) GetUser

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

func (*Dao) Is

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

func (*Dao) ListUser

func (p *Dao) ListUser() []User

func (*Dao) Log

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

func (*Dao) Role

func (p *Dao) Role(name string, resource_type string, resource_id uint) (*Role, error)

func (*Dao) SaveUser

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

type EmailForm

type EmailForm struct {
	Email string `form:"email" binding:"email"`
}

type Google

type Google struct {
	// contains filtered or unexported fields
}

func NewGoogle

func NewGoogle(cfg *GoogleConf) *Google

===============================================

func (*Google) ParseToken

func (p *Google) ParseToken(req *http.Request) ([]byte, error)

func (*Google) Token

func (p *Google) Token(code string) ([]byte, error)

func (*Google) Url

func (p *Google) Url() string

type GoogleConf

type GoogleConf struct {
	Web GoogleWeb `json:"web"`
}

type GoogleUserInfo

type GoogleUserInfo struct {
	Id      string `json:"id"`
	Email   string `json:"email"`
	Name    string `json:"name"`
	Link    string `json:"link"`
	Picture string `json:"picture"`
}

type GoogleWeb

type GoogleWeb struct {
	ClientId     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	RedirectURLS []string `json:"redirect_uris"`
}

type Log

type Log struct {
	ID        uint      `gorm:"primary_key" json:"id"`
	UserID    uint      `sql:"not null" json:"-"`
	User      User      `json:"-"`
	Message   string    `sql:"not null" json:"message"`
	CreatedAt time.Time `sql:"not null;default:current_timestamp" json:"created_at"`
}

type Oauth

type Oauth interface {
	Token(req *http.Request) ([]byte, error)
	Url() string
}

type PasswordForm

type PasswordForm struct {
	Token                string `form:"token" binding:"required"`
	Password             string `form:"password" binding:"min=8"`
	PasswordConfirmation string `form:"password_confirmation" binding:"eqfield=Password"`
}

type Permission

type Permission struct {
	ID     uint `gorm:"primary_key"`
	User   User
	UserID uint `sql:"not null"`
	Role   Role
	RoleID uint      `sql:"not null"`
	Begin  time.Time `sql:"not null;default:current_date;type:date"`
	End    time.Time `sql:"not null;default:'1000-1-1';type:date"`
}

func (*Permission) BeginS

func (p *Permission) BeginS() string

func (*Permission) Enable

func (p *Permission) Enable() bool

func (*Permission) EndS

func (p *Permission) EndS() string

type Role

type Role struct {
	ID           uint   `gorm:"primary_key"`
	Name         string `sql:"not null;index:idx_roles_name"`
	ResourceType string `sql:"not null;default:'-';index:idx_roles_resource_type"`
	ResourceId   uint   `sql:"not null;default:0"`
}

func (Role) String

func (p Role) String() string

type Session

type Session struct {
	Db    *gorm.DB       `inject:""`
	Dao   *Dao           `inject:""`
	Token token.Provider `inject:""`
}

func (*Session) Admin

func (p *Session) Admin(req *http.Request) (*User, error)

func (*Session) User

func (p *Session) User(req *http.Request) (*User, error)

type SignInForm

type SignInForm struct {
	RememberMe bool   `form:"remember_me"`
	Email      string `form:"email" binding:"email"`
	Password   string `form:"password" binding:"min=8"`
}

type SignUpForm

type SignUpForm struct {
	Username             string `form:"username" binding:"min=2,max=20"`
	Email                string `form:"email" binding:"email"`
	Password             string `form:"password" binding:"min=8"`
	PasswordConfirmation string `form:"password_confirmation" binding:"eqfield=Password"`
}

type User

type User struct {
	core.Model

	Email        string `sql:"not null;index:idx_users_email"`
	Uid          string `sql:"not null;unique_index;type:char(36)"`
	Home         string `sql:"not null"`
	Name         string `sql:"not null"`
	ProviderType string `sql:"not null;default:'unknown';index:idx_users_provider_type"`
	ProviderId   string `sql:"not null;index:idx_users_provider_id"`

	LastSignIn  time.Time `sql:"not null"`
	SignInCount uint      `sql:"not null;default:0"`

	Permissions []Permission
}

func (*User) SetGravatar

func (p *User) SetGravatar()

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