authentication

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PermAuthAdmin = "auth.admin" // Constant for assigning a permission to auth admins
	PermAuthView  = "auth.view"  // Constant for assigning a permission to auth viewers

)

Define constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

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

Author is the base type for this plugin, all functionality is built on this

func CtxAuth

func CtxAuth(ctx context.Context) *Author

CtxAuth is used to return the Author object from a Context

func (*Author) CheckPerm

func (a *Author) CheckPerm(r *seabird.Request, perms []string) bool

CheckPerm takes a request and list of permissions and returns true/false depending on if the request is authorized

func (*Author) PermGuard

func (a *Author) PermGuard(r *seabird.Request, perms []string) bool

PermGuard is a convenience method for providing an error message when the perms don't check out

func (*Author) RegisterPermString

func (a *Author) RegisterPermString(perm string)

RegisterPermString registers a permission string

type Ident

type Ident struct {
	gorm.Model
	UserID  uint
	Type    string
	Pattern string
}

Ident stores the masks used to identify a user

type Permission

type Permission struct {
	gorm.Model
	OwnerID   uint
	OwnerType string
	Perm      string
}

Permission stores strings that represent the permissions assigned to a particular user

type Role

type Role struct {
	gorm.Model
	Name        string       `gorm:"unique_index"`
	Users       []User       `gorm:"many2many:user_roles;"`
	Permissions []Permission `gorm:"polymorphic:Owner;"`
}

Role associates users with permissions sets

type User

type User struct {
	gorm.Model
	Name        string `gorm:"unique_index"`
	Idents      []Ident
	Permissions []Permission `gorm:"polymorphic:Owner;"`
	Roles       []Role       `gorm:"many2many:user_roles;"`
}

User provides the linchpin for other references

Jump to

Keyboard shortcuts

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