userapi

package
v0.0.0-...-9714d35 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	*UserCache
}

receiver type

func (*Api) Attached

func (uc *Api) Attached(method string) bool

implement the Cruder interface

func (*Api) Create

func (uc *Api) Create(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*Api) Delete

func (uc *Api) Delete(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Api) List

func (uc *Api) List(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*Api) Read

func (uc *Api) Read(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Api) Replace

func (uc *Api) Replace(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*Api) Update

func (uc *Api) Update(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

type User

type User struct {
	Username     string
	Password     string   `json:",omitempty" bson:"-"`
	PasswordHash [16]byte `json:"-"`
	CreationTime int64
	UpdateTime   int64
}

type UserCache

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

receiver type

func NewUserCache

func NewUserCache(db *sql.DB, adminarr []string, authorizedProviders map[string][]string) *UserCache

generator

func (*UserCache) AdminAuth

func (uc *UserCache) AdminAuth(r *http.Request) (ok bool)

user is admin

func (*UserCache) AuthenticateRequest

func (uc *UserCache) AuthenticateRequest(w http.ResponseWriter, r *http.Request) *User

extract the username+password from request

func (*UserCache) AuthenticateUser

func (uc *UserCache) AuthenticateUser(username, password string) (*User, error)

func (*UserCache) AuthorizeProvider

func (uc *UserCache) AuthorizeProvider(r *http.Request, facility string) (string, string, error)

authorize the request for this facility

func (*UserCache) AuthorizeUser

func (uc *UserCache) AuthorizeUser(r *http.Request, facility string) (string, error)

func (*UserCache) Drop

func (uc *UserCache) Drop(username string) error

drop user from cache and db

func (*UserCache) Insert

func (uc *UserCache) Insert(user *User) error

insert a new user

func (*UserCache) Load

func (uc *UserCache) Load(username string) *User

func (*UserCache) MinimalAuth

func (uc *UserCache) MinimalAuth(r *http.Request) (ok bool)

user exists

func (*UserCache) Reinsert

func (uc *UserCache) Reinsert(user *User) error

Jump to

Keyboard shortcuts

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