Documentation
¶
Overview ¶
Package lodge is an app's adapter to lodge, the hub of frostyard's first-party apps.
An app has 2 sockets: the lodge socket, on which lodge forwards a user's calls, and the app's private socket, on which the app's own user works. The adapter trusts the Lodge-Principal and Lodge-Grant headers on the lodge socket only, and only after it has checked the peer's user id: every other connection gets the local user, and its Lodge-* headers are deleted.
The permissions themselves are the app's: docs/specs/permissions.md is the contract, and github.com/frostyard/hearth/authz is the runtime.
Index ¶
- Constants
- func ConnContext(ctx context.Context, conn net.Conn) context.Context
- func Handler(next http.Handler) http.Handler
- func Listener(l net.Listener, lodgeUID int) net.Listener
- func PrivateHandler(next http.Handler) http.Handler
- func Serve(l net.Listener, lodgeUID int, h http.Handler) *http.Server
Constants ¶
const ( // PrincipalHeader carries the caller's principal. PrincipalHeader = "Lodge-Principal" // GrantHeader carries the caller's grant, as base64url without padding // (RFC 4648 §5) of the grant's JSON. GrantHeader = "Lodge-Grant" )
The 2 headers that lodge sends, after it has authenticated the user and looked up the user's grant for this app.
Variables ¶
This section is empty.
Functions ¶
func ConnContext ¶
ConnContext marks the context of 1 connection that lodge's listener accepted. It is the http.Server's ConnContext.
func Handler ¶
Handler serves an app's lodge socket: it reads the principal and the grant from lodge's 2 headers, and refuses the request with 403 unless it came from lodge's socket, the principal is valid and the grant parses.
On success the caller is in the request's context (authz.CallerFrom), so every generated permission check reads it.
func Listener ¶
Listener returns a listener that accepts only the connections of lodgeUID. It closes every other connection, and every connection whose peer cannot be read, before it reads a byte of it, and it keeps accepting.
func PrivateHandler ¶
PrivateHandler serves an app's private socket: it deletes every Lodge-* header of the request, and sets the local user as the caller. A forged header therefore reaches no handler.
func Serve ¶
Serve serves h on lodge's socket, over the listener of Listener(l, lodgeUID), and returns the http.Server that runs it.
Serve starts the server and returns; stop it with the server's Shutdown or Close. A caller that needs the server's own errors serves the listener itself, with Handler and ConnContext.
Types ¶
This section is empty.