users

package
v0.0.0-...-df3db6e Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserRoles    = []Role{RoleUser}
	ManagerRoles = []Role{RoleUser, RoleManager}
)

Functions

func Fingerprint

func Fingerprint(k ssh.PublicKey) string

func HasRoles

func HasRoles(wrap UserFunction, ath auth.Auther, usrs Users, rlz Roles, cfg config.Configer) restful.RouteFunction

Check if the user which is identified by the "Authorization" header has as least one of the given roles.

Types

type Allowance

type Allowance struct {
	GrantedBy string    `json:"grantedBy"`
	Uid       string    `json:"uid"`
	Until     time.Time `json:"until"`
}

type CheckedUser

type CheckedUser func(f UserFunction) restful.RouteFunction

func CheckUser

func CheckUser(a auth.Auther, u Users, rlz Roles, cfg config.Configer) CheckedUser

type Key

type Key struct {
	Id          string `json:"id"`
	Value       string `json:"value"`
	Fingerprint string `json:"fingerprint"`
}

func AsKey

func AsKey(usrs Users, uid, kid, pubkey string) (*Key, error)

func ParseKey

func ParseKey(pubkey string) (*Key, error)

type Role

type Role string
const (
	RoleUser    Role = "USER"
	RoleManager      = "MANAGER"
)

type Roles

type Roles []Role

func (Roles) Has

func (rlz Roles) Has(r Role) bool

func (Roles) String

func (rlz Roles) String() string

type User

type User struct {
	Id                string     `json:"id"`
	Name              string     `json:"name"`
	Keys              []Key      `json:"keys"`
	Roles             Roles      `json:"roles"`
	Aliases           []string   `json:"aliases"`
	Use2FA            bool       `json:"use2fa"`
	AutologinAfter2FA int        `json:"autologinafter2FA"`
	Allowance         *Allowance `json:"allowance,omitempty"`
	IdToken           string     `json:"idtoken"`
}

type UserFunction

type UserFunction func(usr *User, request *restful.Request, response *restful.Response)

Signature for a restful function which needs an authorized user

type Users

type Users interface {
	Create(network, id, name string, rolzs Roles) (*User, error)
	AddAlias(id, network, alias string) (*User, error)
	NewIdToken(uid string) (*User, error)
	ByIdToken(idtok string) (*User, error)
	RemoveAlias(id, network, alias string) (*User, error)
	GetAll() ([]User, error)
	Get(id string) (*User, error)
	AddKey(uid, kid string, pubkey string, fp string) (*Key, error)
	RemoveKey(uid, kid string) (*Key, error)
	Update(uid, username string, rolz Roles) (*User, error)
	Permit(a Allowance, ttlSecs uint64) error
	Delete(uid string) (*User, error)
	GetByKey(pubkey string) (*User, *Key, error)
	Create2FAToken(domain, uid string) (string, error)
	SetAutologinAfter2FA(uid string, duration int) (*User, error)
	Use2FAToken(uid string, use bool) error
	CheckToken(uid, token string) error
	CheckAndAllowToken(uid, token string, maxAllowance int) error
	Close() error
}

type UsersService

type UsersService struct {
	Auth     auth.Auther
	Provider Users
	Config   config.Configer
}

func (*UsersService) Register

func (t *UsersService) Register(root string, c *restful.Container)

func (*UsersService) Shutdown

func (t *UsersService) Shutdown() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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