Rename package from httpauth to httpauthfirebase to follow ecosystem convention (repo name = package name, hyphens removed). Bump httpauth dependency from v0.1.0 to v1.0.0 and rbac indirect dependency from v0.9.0 to v1.0.0. BREAKING CHANGE: import path unchanged (code.nochebuena.dev/go/httpauth-firebase) but package identifier changes from httpauth to httpauthfirebase — remove any import alias previously used to disambiguate from code.nochebuena.dev/go/httpauth.
4.1 KiB
4.1 KiB
Changelog
All notable changes to this module will be documented in this file.
The format is based on Keep a Changelog, and this module adheres to Semantic Versioning.
1.0.0 - 2026-05-08
Changed
- Package renamed from
httpauthtohttpauthfirebase— follows ecosystem convention (repo name = package name, hyphens removed); import path is unchanged (code.nochebuena.dev/go/httpauth-firebase); remove any alias previously used to disambiguate fromcode.nochebuena.dev/go/httpauth EnrichmentMiddleware,AuthzMiddleware,IdentityEnricher,PermissionProvider,WithTenantHeader, andEnrichOptremoved; they now live incode.nochebuena.dev/go/httpauth(provider-agnostic middleware layer)AuthMiddlewareupdated to callhttpauth.SetTokenData— fulfills the integration contract between provider-specific auth and generic middleware- Dependency
code.nochebuena.dev/go/httpauthbumped to v1.0.0 - Dependency
code.nochebuena.dev/go/rbacbumped to v1.0.0 (indirect)
0.9.0 - 2026-03-18
Added
TokenVerifierinterface — abstracts*auth.Clientfor unit-test mockability;*auth.Clientsatisfies it directly in production via itsVerifyIDTokenAndCheckRevokedmethodIdentityEnricherinterface — application-implemented; receivesuid stringandclaims map[string]any, returnsrbac.Identity; called byEnrichmentMiddlewareon every requestPermissionProviderinterface — application-implemented; receivesuidandresourcestring, returnsrbac.PermissionMask; called byAuthzMiddlewareon every requestEnrichOptfunctional option type for configuringEnrichmentMiddlewareWithTenantHeader(header string) EnrichOpt— reads a tenant ID from the named request header and attaches it to the identity viarbac.Identity.WithTenant; absent header leavesTenantIDas an empty string with no errorAuthMiddleware(verifier TokenVerifier, publicPaths []string) func(http.Handler) http.Handler— verifiesAuthorization: Bearer <token>via Firebase JWT verification and injects the verifieduidand raw claims into the request context under unexported typed keys; paths matching any pattern inpublicPathsbypass token verification (glob patterns viapath.Match,*wildcard supported); returns 401 on missing or invalid tokensEnrichmentMiddleware(enricher IdentityEnricher, opts ...EnrichOpt) func(http.Handler) http.Handler— reads the uid and claims stored byAuthMiddleware, callsenricher.Enrich, and stores the resultingrbac.Identityin context viarbac.SetInContext; returns 401 ifAuthMiddlewarehas not run upstream; returns 500 if the enricher failsAuthzMiddleware(provider PermissionProvider, resource string, required rbac.Permission) func(http.Handler) http.Handler— readsrbac.Identityfrom context viarbac.FromContext, resolves the permission mask for the identity's UID onresource, and gates the request against the required permission bit; returns 401 if no identity is in context; returns 403 if the permission check fails or the provider returns an error
Design Notes
- The three middleware functions are intentionally separate so they can be applied at different scopes:
AuthMiddlewareat the root router,EnrichmentMiddlewareon authenticated route groups, andAuthzMiddlewareper-route or per-group with different resource and permission arguments - The module is named
httpauth-firebaserather thanhttpauthbecause it imports the Firebase SDK directly; other providers (httpauth-auth0,httpauth-jwt, etc.) are separate sibling modules that all converge on the samerbac.Identityoutput contract, which means downstream handlers and business logic never depend on a specific auth provider - No logger parameter is accepted; errors are returned as plain-text HTTP responses, keeping the dependency surface to
rbacandfirebase.google.com/go/v4only