auth

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package auth is Google Workspace sign-in and the instance claim that hangs off it.

It is not a transport. The local and tailnet listeners still name the caller the way they always have; this package adds a session cookie (Identify) and, when Google OAuth is configured, restricts humans on an unclaimed instance to WhoAmI and Claim. The local token and node identity stay fully privileged for the CLI and workers.

Index

Constants

View Source
const (
	StatusPath   = "/auth/status"
	StartPath    = "/auth/google/start"
	CallbackPath = "/auth/google/callback"
	LogoutPath   = "/auth/logout"
	// PicturePath is the signed-in user's Google avatar, proxied same-origin so
	// tracking protection cannot hide it.
	PicturePath = "/auth/picture"
)

Paths the browser hits without a session. Mounted outside the identity middleware.

View Source
const CookieName = "podium_session"

CookieName is the session cookie set after a Google callback. HttpOnly, SameSite=Lax.

Variables

This section is empty.

Functions

func RestrictUnclaimed

func RestrictUnclaimed(st instanceView, googleEnabled bool, next http.Handler) http.Handler

RestrictUnclaimed forbids KindUser from everything except WhoAmI and Claim until the instance has an owner, and afterwards requires the caller's domain to match. Nodes and the local token are not humans and are not gated — workers and the CLI still use them. A no-op when googleEnabled is false, so existing deployments do not change.

func Wrap

Wrap returns inner unchanged when st is nil. Otherwise Identify tries a session first.

Types

type Flow

type Flow struct {
	Google Google
	Store  *store.Store
	// contains filtered or unexported fields
}

Flow holds in-flight OAuth states. Podium is a single process, so this lives in memory and a restart drops anything mid-login, which is the right answer.

type Google

type Google struct {
	ClientID     string
	ClientSecret string
	// PublicURL, if set, is the origin used for the OAuth redirect URI. Empty means the
	// start request's own origin, so a single client can have both localhost and a
	// production URI registered.
	PublicURL   string
	HTTPClient  *http.Client
	AuthURL     string
	TokenURL    string
	UserInfoURL string
}

Google is the OAuth client. Zero ClientID means Google sign-in is off and none of the /auth/google routes do anything useful.

func (Google) Enabled

func (g Google) Enabled() bool

Enabled reports whether both halves of the OAuth client are set.

type Handler

type Handler struct {
	Flow   *Flow
	Store  *store.Store
	Logger *slog.Logger
}

Handler serves /auth/*. Status is always public. The Google routes 404 when OAuth is off.

func NewHandler

func NewHandler(flow *Flow, logger *slog.Logger) *Handler

NewHandler returns the /auth/* mux. flow may have Google disabled.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts the public /auth/* routes on mux. They sit outside the identity middleware: status is how the UI learns Google is on, and start/callback are the OAuth dance.

type Layer

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

Layer wraps a transport.Listener so a Google session cookie (or bearer) becomes KindUser before the inner transport is asked. Listen is delegated. Ready/BaseURL are NOT promoted: server.unwrapTransport looks through Inner() so the tailnet probes still hit the real listener.

func (*Layer) Identify

func (l *Layer) Identify(r *http.Request) (transport.Identity, error)

Identify prefers a live Google session cookie, then the inner transport.

func (*Layer) Inner

func (l *Layer) Inner() transport.Listener

Inner returns the wrapped listener. server.unwrapTransport uses this.

func (*Layer) Listen

func (l *Layer) Listen(ctx context.Context) (net.Listener, error)

Listen binds the inner transport's socket.

Jump to

Keyboard shortcuts

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