auth

package
v0.0.0-...-8a4eff6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator struct {
	Decoder Decoder
	Service UserGetter
}

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(next papernet.HandlerFunc) papernet.HandlerFunc

type Decoder

type Decoder interface {
	Decode(string) (int, bool, error)
}

type Team

type Team struct {
	ID   int    `json:"id"`
	Name string `json:"name"`

	Members []TeamMember `json:"members"`

	CanSee  []int `json:"canSee"`
	CanEdit []int `json:"canEdit"`
}

type TeamMember

type TeamMember struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`

	IsTeamAdmin bool `json:"admin"`
}

type TeamRepository

type TeamRepository interface {
	Get(int) (Team, error)
	GetForUser(int) ([]Team, error)

	Upsert(*Team) error
	Delete(int) error
}

type User

type User struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`

	Salt         string `json:"-"`
	PasswordHash string `json:"-"`

	IsAdmin bool `json:"isAdmin"`

	Owns      []int `json:"owns"`
	CanSee    []int `json:"canSee"`
	CanEdit   []int `json:"canEdit"`
	Bookmarks []int `json:"bookmarks"`
}

func UserFromContext

func UserFromContext(ctx context.Context) (User, error)

type UserGetter

type UserGetter interface {
	Get(userID int) (User, error)
}

type UserRepository

type UserRepository interface {
	// User information
	Get(int) (User, error)
	GetByEmail(string) (User, error)
	List() ([]User, error)
	Upsert(*User) error
	Delete(int) error

	// User -> Paper
	PaperOwner(paperID int) (int, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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