Documentation
¶
Index ¶
- Constants
- func AuthSourceFromRequest(r *http.Request) string
- func EndpointAllowsRole(method, path, role string) bool
- func HasTailscaleIdentityHeader(r *http.Request) bool
- func NewMiddleware(opts Options, logOut io.Writer) func(http.Handler) http.Handler
- func NormalizeMode(raw string) string
- func RoleFromContext(ctx context.Context) string
- func RoleFromRequest(r *http.Request) string
- func WithWorkspaceID(ctx context.Context, workspaceID string) context.Context
- func WorkspaceIDFromContext(ctx context.Context) string
- func WorkspaceIDFromRequest(r *http.Request) string
- type EndpointAccess
- type EndpointPolicyRule
- type Options
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 EndpointAllowsRole ¶ added in v0.32.0
func HasTailscaleIdentityHeader ¶ added in v0.32.0
func NewMiddleware ¶
func NormalizeMode ¶
func RoleFromContext ¶
func RoleFromRequest ¶
func WithWorkspaceID ¶
func WorkspaceIDFromContext ¶
func WorkspaceIDFromRequest ¶
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)
}
Click to show internal directories.
Click to hide internal directories.