Documentation
¶
Index ¶
- Variables
- func AuthMiddleware(keyRing *jwtpkg.KeyRing, expectedTenant string) func(http.Handler) http.Handler
- func CORSMiddleware(allowedOrigins string) func(http.Handler) http.Handler
- func HealthMiddleware(next http.Handler) http.Handler
- func JWKSMiddleware(keyRing *jwtpkg.KeyRing) func(http.Handler) http.Handler
- func LoggingMiddleware(logger *zap.Logger) func(http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
var AuthExemptPaths = map[string]bool{ "/identity.IdentityService/BeginOAuthLogin": true, "/identity.IdentityService/OAuthLogin": true, "/identity.IdentityService/PasswordLogin": true, "/identity.IdentityService/PasswordSignup": true, "/identity.IdentityService/RefreshToken": true, "/identity.IdentityService/Logout": true, "/identity.IdentityService/GetCurrentUser": true, "/identity.IdentityService/BeginPasskeyLogin": true, "/identity.IdentityService/CompletePasskeyLogin": true, "/identity.IdentityService/InitiateQrLogin": true, "/identity.IdentityService/PollQrLogin": true, "/identity.IdentityService/AcceptInvitation": true, "/identity.IdentityService/RequestAdminHelp": true, "/identity.IdentityService/VerifyTotp": true, "/identity.IdentityService/RequestPasswordReset": true, "/identity.IdentityService/ConfirmPasswordReset": true, "/identity.IdentityService/VerifyEmail": true, "/identity.IdentityService/ConfirmEmailChange": true, "/.well-known/jwks.json": true, "/health": true, "/healthz": true, }
AuthExemptPaths lists URL paths that do not require a valid JWT. Connect-Go uses the proto service/method as the URL path.
Functions ¶
func AuthMiddleware ¶
AuthMiddleware verifies JWT Bearer tokens on non-exempt paths and injects the authenticated user ID into the X-Authenticated-User-Id request header so downstream Connect handlers can read it.
expectedTenant, when non-empty, is enforced on every verified token: tokens whose "tenant" claim does not match are rejected. Pass an empty string to disable the cross-tenant check.
For auth-exempt paths the middleware still attempts to parse and verify a token when one is present (e.g. GetCurrentUser may optionally read the caller identity) but never rejects the request.
func CORSMiddleware ¶
CORSMiddleware handles CORS preflight requests and injects the appropriate response headers for allowed origins.
allowedOrigins is a comma-separated list of origins (e.g. "http://localhost:9002,http://localhost:3000").
func HealthMiddleware ¶
HealthMiddleware handles /health, /healthz, and / before the request reaches the Connect handler. This keeps health probes (e.g. Azure Container Apps) cheap and independent of service readiness.
func JWKSMiddleware ¶
JWKSMiddleware serves the /.well-known/jwks.json endpoint from the key ring. The response contains the RSA public keys for all keys in the ring so that third-party services can verify tokens without sharing a secret.
Types ¶
This section is empty.