auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DomainAllowed

func DomainAllowed(ctx context.Context, domain string) bool

DomainAllowed returns true if the domain is allowed to the user If the authorization context contains a domain allowlist, the value must be present in the claim If the allowlist is not set or nil, then all domains are allowed

func GetClaims

func GetClaims(ctx context.Context) (jwt.Token, bool)

GetClaims retrieves the full token from the request context

func GetDomains

func GetDomains(ctx context.Context) ([]string, bool)

GetDomains retrieves the list of allowed domains (if any) from the request context

func GetUser

func GetUser(ctx context.Context) (string, bool)

GetUser retrieves user information from the request context

Types

type Authenticator

type Authenticator interface {
	// Middleware returns an HTTP middleware that validates authentication
	Middleware(next http.Handler) http.Handler
}

Authenticator is the interface that all authenticators must implement

type JWTAuthenticator

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

JWTAuthenticator handles OAuth2/OIDC authentication for the API

func NewJWTAuthenticator

func NewJWTAuthenticator(ctx context.Context, issuerURL string, audience string, requiredScopes []string, domainsClaim string) (*JWTAuthenticator, error)

NewJWTAuthenticator creates a new OAuth2/OIDC authenticator

func (*JWTAuthenticator) Middleware

func (a *JWTAuthenticator) Middleware(next http.Handler) http.Handler

Middleware returns an HTTP middleware that validates OAuth2 bearer tokens

type OIDCDiscovery

type OIDCDiscovery struct {
	Issuer  string `json:"issuer"`
	JWKSURI string `json:"jwks_uri"`
}

OIDCDiscovery represents the OIDC discovery document

type PSKAuthenticator

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

PSKAuthenticator handles pre-shared key authentication

func NewPSKAuthenticator

func NewPSKAuthenticator(preSharedKey string) (*PSKAuthenticator, error)

NewPSKAuthenticator creates a new pre-shared key authenticator

func (*PSKAuthenticator) Middleware

func (a *PSKAuthenticator) Middleware(next http.Handler) http.Handler

Middleware returns an HTTP middleware that validates pre-shared key authentication

type TSNetAuthenticator

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

TSNetAuthenticator handles authentication using Tailscale identity This authenticator can only be used when the server is running with tsnet listener

func NewTSNetAuthenticator

func NewTSNetAuthenticator(tsnetServer *tsnetserver.TSNetServer) (*TSNetAuthenticator, error)

NewTSNetAuthenticator creates a new Tailscale identity authenticator The localClient is used to query the Tailscale LocalAPI for identity information

func (*TSNetAuthenticator) Middleware

func (a *TSNetAuthenticator) Middleware(next http.Handler) http.Handler

Middleware returns an HTTP middleware that validates Tailscale identity

Jump to

Keyboard shortcuts

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