serverauth

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeOff              = "off"
	ModeExternalRequired = "external-required"
	ModeRequired         = "required"

	DefaultWorkspaceHeader          = "Tars-Workspace-Id"
	DefaultBrowserSessionCookieName = "tars_session"
	TailscaleUserLoginHeader        = "Tailscale-User-Login"
)
View Source
const (
	RoleUser  = "user"
	RoleAdmin = "admin"
)

Variables

This section is empty.

Functions

func AuthSourceFromRequest added in v0.32.0

func AuthSourceFromRequest(r *http.Request) string

func EndpointAllowsRole added in v0.32.0

func EndpointAllowsRole(method, path, role string) bool

func HasTailscaleIdentityHeader added in v0.32.0

func HasTailscaleIdentityHeader(r *http.Request) bool

func NewMiddleware

func NewMiddleware(opts Options, logOut io.Writer) func(http.Handler) http.Handler

func NormalizeMode

func NormalizeMode(raw string) string

func RoleFromContext

func RoleFromContext(ctx context.Context) string

func RoleFromRequest

func RoleFromRequest(r *http.Request) string

func WithWorkspaceID

func WithWorkspaceID(ctx context.Context, workspaceID string) context.Context

func WorkspaceIDFromContext

func WorkspaceIDFromContext(ctx context.Context) string

func WorkspaceIDFromRequest

func WorkspaceIDFromRequest(r *http.Request) string

Types

type EndpointAccess added in v0.32.0

type EndpointAccess string

EndpointAccess describes the minimum browser-session role needed for an API endpoint. Unknown endpoints default to admin so the remote user surface is fail-closed as new routes are added.

const (
	EndpointAccessPublic EndpointAccess = "public"
	EndpointAccessUser   EndpointAccess = "user"
	EndpointAccessAdmin  EndpointAccess = "admin"
)

func ResolveEndpointAccess added in v0.32.0

func ResolveEndpointAccess(method, path string) EndpointAccess

type EndpointPolicyRule added in v0.32.0

type EndpointPolicyRule struct {
	Methods []string
	Pattern string
	Access  EndpointAccess
	Note    string
}

EndpointPolicyRule is the remote browser allowlist skeleton. It is not wired into middleware yet; PR1b will use this table when cookie auth lands.

func DefaultEndpointPolicyRules added in v0.32.0

func DefaultEndpointPolicyRules() []EndpointPolicyRule

type Options

type Options struct {
	Mode                          string
	BearerToken                   string
	UserToken                     string
	AdminToken                    string
	WorkspaceHeader               string
	RequireWorkspaceForAuthorized bool
	UserWorkspaceAllowlist        []string
	AdminWorkspaceAllowlist       []string
	SkipPaths                     []string
	LoopbackSkipPaths             []string
	AdminPaths                    []string
	BrowserSessionCookieName      string
	BrowserSessionRoleResolver    func(sessionID string) (string, bool)
}

Jump to

Keyboard shortcuts

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