server

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

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

Go to latest
Published: Aug 21, 2022 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthValidator

type AuthValidator interface {
	Login(username, password string) (auth bool)
}

type BasicAuth

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

func NewBasicAuth

func NewBasicAuth(auth AuthValidator) (*BasicAuth, error)

func (*BasicAuth) Auth

func (a *BasicAuth) Auth(username, password string) (auth bool)

type Context

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter
	Srv      *Server
	T        *template.Template
	Status   int
	Err      error
	Time     time.Time

	Token jwt.Token

	Data webData
	// contains filtered or unexported fields
}

func (*Context) Admin

func (c *Context) Admin() bool

func (*Context) ApproveConsent

func (c *Context) ApproveConsent(u *core.User, challenge string) (rdr string, err error)

func (*Context) ApproveLogin

func (c *Context) ApproveLogin(u *core.User, challenge string) (rdr string, err error)

func (*Context) CheckXsrf

func (c *Context) CheckXsrf() (ok bool)

CheckXsrf validates the xsrf token

func (*Context) Consent

func (c *Context) Consent(challenge string) (cr *client.ConsentRequest, err error)

func (*Context) Error

func (c *Context) Error(i interface{})

func (*Context) Exec

func (c *Context) Exec()

func (*Context) Forbidden

func (c *Context) Forbidden()

func (*Context) Form

func (c *Context) Form(name string) string

func (*Context) FormSlice

func (c *Context) FormSlice(name string) []string

func (*Context) Forwarded

func (c *Context) Forwarded() (ret string)

func (*Context) LogSetCookie

func (c *Context) LogSetCookie(err error, msg string)

func (*Context) LoggedOn

func (c *Context) LoggedOn() (ok bool)

func (*Context) Login

func (c *Context) Login(u *core.User, remember string)

func (*Context) Method

func (c *Context) Method() string

func (*Context) NotFound

func (c *Context) NotFound()

func (*Context) Path

func (c *Context) Path() string

func (*Context) PlainForbidden

func (c *Context) PlainForbidden()

func (*Context) PlainOK

func (c *Context) PlainOK()

func (*Context) PlainUnauthorized

func (c *Context) PlainUnauthorized()

func (*Context) Query

func (c *Context) Query(name string) string

func (*Context) Redirect

func (c *Context) Redirect(uri string, code int)

func (*Context) RejectConsent

func (c *Context) RejectConsent(challenge string) (rdr string, err error)

func (*Context) Remember

func (c *Context) Remember() string

func (*Context) RevokeSession

func (c *Context) RevokeSession(user, client string, all bool) (err error)

func (*Context) Sessions

func (c *Context) Sessions(user string) (m map[string]sess, err error)

func (*Context) SetCookie

func (c *Context) SetCookie(claims jwt.Claims, d time.Duration)

func (*Context) SetHeader

func (c *Context) SetHeader(name, value string)

func (*Context) Template

func (c *Context) Template(name string)

func (*Context) Totp

func (c *Context) Totp() string

func (*Context) User

func (c *Context) User() string

func (*Context) Var

func (c *Context) Var(name string) (ret string)

type DBLoginValidator

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

func NewDBLoginValidator

func NewDBLoginValidator(db *db.DB) *DBLoginValidator

func (*DBLoginValidator) Login

func (val *DBLoginValidator) Login(username, password string) bool

type Server

type Server struct {
	Config *core.Config

	API       *client.APIClient
	DB        *db.DB
	JWT       *jwt.JWT
	BasicAuth *BasicAuth
	// contains filtered or unexported fields
}

func NewServer

func NewServer(log logr.Logger, cfg *core.Config) (srv *Server, err error)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

func (*Server) Start

func (s *Server) Start(dblog logr.Logger) (err error)

type TemplateStore

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

func NewTemplateStore

func NewTemplateStore() *TemplateStore

func (*TemplateStore) Get

func (ts *TemplateStore) Get(name string) *template.Template

func (*TemplateStore) Parse

func (ts *TemplateStore) Parse(fs fs.FS, name string, files ...string)

Jump to

Keyboard shortcuts

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