accessgate

package
v1.117.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package accessgate refuses portal requests from callers whose roles map to no persona.

Authenticating proves who a caller is; it does not decide what they may reach. The portal's authenticator admits any identity the configured providers accept, so on its own it would hand a session — and with it every org-shared knowledge page and the whole federated search surface — to any account an identity provider will issue a token for. This package is the authorization half: it resolves the caller's persona and refuses the request when there is none.

It lives outside pkg/portal so the refusal, its branded page, and its tests stay one cohesive unit that the portal handler composes rather than embeds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Brand

type Brand struct {
	Name               string
	LogoSVG            string
	URL                string
	ImplementorName    string
	ImplementorLogoSVG string
	ImplementorURL     string
}

Brand is the chrome the denial page renders with, mirroring the share-guest landing page so a refusal reads as the same product as an admission.

type Gate

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

Gate authorizes authenticated portal callers by persona.

func New

func New(resolve PersonaResolver, brand Brand) *Gate

New creates a Gate. A nil resolver denies every caller: the gate is the portal's authorization boundary, and a boundary that cannot evaluate its input refuses rather than admits.

func (*Gate) Allows

func (g *Gate) Allows(roles []string) bool

Allows reports whether roles map to a persona. Exported so a caller that has already authenticated — the SPA shell gate — can ask the same question the middleware asks without producing a response.

func (*Gate) Deny

func (g *Gate) Deny(w http.ResponseWriter, r *http.Request, email string)

Deny writes the 403. A top-level browser navigation gets the branded page so the person reading it learns which account was refused and what to do about it; everything else gets the Problem Details body the portal's other errors use, so the SPA can tell "no access" apart from "signed out" and render the refusal in place instead of bouncing back through the identity provider.

func (*Gate) Require

func (g *Gate) Require(next http.Handler) http.Handler

Require returns middleware that refuses callers whose roles map to no persona. It must be composed INSIDE the portal's authentication middleware: it reads the authenticated user that middleware puts on the context, and treats a missing user as unauthenticated (401) rather than silently allowing the request through.

type PersonaResolver

type PersonaResolver func(roles []string) *portal.PersonaInfo

PersonaResolver reports the persona a set of roles maps to, or nil when the roles map to none. It is satisfied by portal.PersonaResolver.

Jump to

Keyboard shortcuts

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