Documentation
¶
Overview ¶
Package httpapi is the drive server's HTTP adapter.
Index ¶
- func Authenticate(tokens *core.Tokens, sessions *core.Sessions, cookieName string) errchain.Middleware
- func New(log zerolog.Logger, info buildinfo.Info, svc Services) http.Handler
- func Require(scope core.Scope) errchain.Middleware
- func RequireSession() errchain.Middleware
- func Serve(ctx context.Context, ln net.Listener, h http.Handler, log zerolog.Logger, ...) error
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate(tokens *core.Tokens, sessions *core.Sessions, cookieName string) errchain.Middleware
Authenticate turns an "Authorization: Bearer hds_..." header, or else the session cookie, into a Principal in the request context. A request that sends a bearer header is judged on it alone, so a stale cookie cannot override a token.
func New ¶
New returns the server's handler. /healthz is quiet in the request log unless it fails, so a probe loop does not flood it.
func Require ¶
func Require(scope core.Scope) errchain.Middleware
Require rejects a request whose principal lacks scope. It runs after Authenticate.
func RequireSession ¶
func RequireSession() errchain.Middleware
RequireSession rejects a request that did not authenticate by session cookie, so a token cannot mint more tokens. It runs after Authenticate.
Types ¶
type Services ¶
type Services struct {
Tokens *core.Tokens
Sessions *core.Sessions
SignIn *core.SignIn
Documents *core.Documents
// Web is the built web UI. When nil, no UI route is registered.
Web fs.FS
// BaseURL decides the session cookie's name and Secure flag.
BaseURL string
// TrustedProxies are the proxies whose X-Forwarded-For names the client.
TrustedProxies []netip.Prefix
}
Click to show internal directories.
Click to hide internal directories.