authorization

package
v0.0.0-...-0ccb4e7 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	OnNewUser gongo.Callback
	// contains filtered or unexported fields
}

func New

func New() *Authorization

func (*Authorization) AddPermission

func (auth *Authorization) AddPermission(code, name string) error

func (*Authorization) Configure

func (auth *Authorization) Configure(app gongo.App) error

func (Authorization) LoggerFields

func (auth Authorization) LoggerFields(ctx context.Context) map[string]interface{}

func (*Authorization) Login

func (auth *Authorization) Login(w http.ResponseWriter, r *http.Request, id, name, email, avatarURL string) error

func (*Authorization) Logout

func (auth *Authorization) Logout(w http.ResponseWriter, r *http.Request) error

func (*Authorization) Middleware

func (auth *Authorization) Middleware(next http.Handler) http.Handler

func (Authorization) Resources

func (auth Authorization) Resources() []interface{}

type Group

type Group struct {
	gorm.Model
	Name        string       `valid:"required"`
	Permissions []Permission `gorm:"many2many:group_permission"`
}

type Permission

type Permission struct {
	gorm.Model
	Name string
	Code string
}

type User

type User struct {
	gorm.Model
	Name        string `valid:"required"`
	Email       string
	AvatarURL   string
	LastLogin   time.Time
	Active      bool
	Permissions []Permission `gorm:"many2many:user_permission"`
	Groups      []Group      `gorm:"many2many:user_group"`
}

func (User) DisplayName

func (u User) DisplayName() string

func (User) HasPermissions

func (u User) HasPermissions(permissions ...string) bool

type UserID

type UserID struct {
	ID     string
	User   User
	UserID uint
}

Jump to

Keyboard shortcuts

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