Documentation
¶
Index ¶
- func CORS(next http.Handler) http.Handler
- func DevIdentity(next http.Handler) http.Handler
- func RequestLogging(log *slog.Logger) func(http.Handler) http.Handler
- func TailscaleIdentity(lc WhoisClient, db UserStore, log *slog.Logger) func(http.Handler) http.Handler
- func UserIDFromContext(r *http.Request) (int, bool)
- type UserInfo
- type UserStore
- type WhoisClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DevIdentity ¶
DevIdentity is middleware that sets a development user identity (user_id=1).
func RequestLogging ¶
RequestLogging returns middleware that logs HTTP requests.
func TailscaleIdentity ¶
func TailscaleIdentity(lc WhoisClient, db UserStore, log *slog.Logger) func(http.Handler) http.Handler
TailscaleIdentity returns middleware that authenticates requests via Tailscale WhoIs.
Types ¶
type UserInfo ¶
type UserInfo struct {
Login string `json:"login"`
DisplayName string `json:"display_name"`
TailscaleID string `json:"tailscale_id,omitempty"`
Tailnet string `json:"tailnet,omitempty"`
}
UserInfo holds identity information for an authenticated user.
func UserInfoFromContext ¶
UserInfoFromContext returns the authenticated user info from the request context.
type UserStore ¶
type UserStore interface {
GetOrCreateUser(ctx context.Context, login, displayName string) (int, error)
GetPrimaryUser(ctx context.Context) (int, string, error)
}
UserStore resolves Tailscale identities to application user IDs.
type WhoisClient ¶
type WhoisClient interface {
WhoIs(ctx context.Context, remoteAddr string) (*apitype.WhoIsResponse, error)
}
WhoisClient looks up the identity of a Tailscale peer.
Click to show internal directories.
Click to hide internal directories.