Documentation
¶
Overview ¶
Package appauth is the hub's login-time authorization endpoint for published applications.
The design deliberately keeps the hub OFF the per-request data path:
- Public apps never contact the hub at all.
- Private apps redirect an unauthenticated browser here exactly once. The hub reuses the shared portal browser session (or bounces through the normal /login flow), evaluates ONE SubjectAccessReview against the tenant workspace, and hands the app's access proxy a one-use code. The proxy exchanges the code server-to-server and then maintains its own bounded local session; the hub is not consulted again until that session expires.
Access policy is plain kcp RBAC in the tenant workspace: visiting a private app requires `get` on the instance resource with subresource `access` (e.g. `applications/my-shop` + subresource `access`). Granting a member access is creating a ClusterRole/ClusterRoleBinding pair; revoking is deleting it. The hub carries no knowledge of any provider CRD schema — only resource coordinates supplied by the (controller-authored) proxy config, validated syntactically here.
Index ¶
Constants ¶
const ( // AuthorizePath is the browser-facing entry point the access proxy // redirects to when a private app has no session. AuthorizePath = "/auth/apps/authorize" // ExchangePath is the server-to-server endpoint the access proxy calls to // turn a one-use code into a session grant. ExchangePath = "/auth/apps/exchange" // CallbackPath is the reserved path on the app host that authorize // redirects back to. It must stay in lockstep with the access proxy's // callback route (providers/infrastructure/accessproxy). CallbackPath = "/__faros/auth/callback" // AccessSubresource is the RBAC convention gating private apps: a visitor // needs `get` on `<resource>/<name>` with this subresource in the tenant // workspace. The subresource is never served; it exists only as an // authorization tuple. AccessSubresource = "access" // AccessVerb is the verb checked against the access subresource. AccessVerb = "get" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Sessions is the shared hub browser-session store (portal SSO).
Sessions *browsersession.Store
// SARClient resolves per-workspace SubjectAccessReview clients.
SARClient SARFactory
// AppsDomain is the DNS zone published apps live under
// (e.g. "apps.faros.example"). Redirects are only issued to hosts
// directly under this zone. Empty disables the endpoints.
AppsDomain string
// LoginPath is the hub-relative path of the interactive login page an
// unauthenticated browser is sent to. Defaults to "/ui/login" (the
// portal SPA is mounted under /ui/).
LoginPath string
// Now and Random are test seams.
Now func() time.Time
Random io.Reader
}
Config assembles a Handler.
type ExchangeResponse ¶
type ExchangeResponse struct {
Allowed bool `json:"allowed"`
UserID string `json:"userId"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
SessionTTLSeconds int64 `json:"sessionTtlSeconds"`
}
ExchangeResponse is returned to the proxy on a successful exchange. It contains identity metadata only — never a credential of any kind.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the authorize and exchange endpoints.
func (*Handler) HandleAuthorize ¶
func (h *Handler) HandleAuthorize(w http.ResponseWriter, r *http.Request)
HandleAuthorize is the browser entry point.
GET /auth/apps/authorize?cluster=&group=&resource=&name=&redirect_uri=&state=
func (*Handler) HandleExchange ¶
func (h *Handler) HandleExchange(w http.ResponseWriter, r *http.Request)
HandleExchange consumes a one-use code.
POST /auth/apps/exchange {"code":..., "host":..., "cluster":..., ...}
func (*Handler) RegisterRoutes ¶
func (h *Handler) RegisterRoutes(router *mux.Router, limit func(http.HandlerFunc) http.HandlerFunc)
RegisterRoutes mounts the endpoints. limit wraps each handler with the hub's auth rate limiter; pass nil to mount unwrapped (tests).
type InstanceRef ¶
type InstanceRef struct {
Cluster string // logical cluster ID of the tenant workspace
Group string // API group of the instance CRD
Resource string // REST plural of the instance CRD
Name string // instance name
}
InstanceRef are the resource coordinates of a published template instance. They are authorization inputs only; the hub never reads the object.
type SARFactory ¶
type SARFactory func(clusterID string) (authorizationv1client.SubjectAccessReviewInterface, error)
SARFactory returns a SubjectAccessReview client scoped to one logical cluster. The hub wires this from its kcp admin config; tests use fakes.