lodge

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ConnContext(ctx context.Context, conn net.Conn) context.Context

ConnContext marks the context of 1 connection that lodge's listener accepted. It is the http.Server's ConnContext.

func Handler

func Handler(next http.Handler) http.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

func Listener(l net.Listener, lodgeUID int) net.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

func PrivateHandler(next http.Handler) http.Handler

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

func Serve(l net.Listener, lodgeUID int, h http.Handler) *http.Server

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.

Jump to

Keyboard shortcuts

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