Common Packages
To maintain consistency across Citadel's distributed architecture, we use shared packages for cross-cutting concerns like authentication, configuration, and caching.
Go Commons
The go-commons package is the foundational shared library for all Go-based microservices in the Citadel ecosystem. It mirrors the functionality of our NestJS shared libraries to ensure standardized behavior across languages.
Key Features
- Standardized Configuration: A type-safe YAML loader that ensures all services follow the same configuration patterns.
- Middleware Suite: A set of Gin middleware for:
- Request Context: Extracting tracing and tenant headers.
- Authentication: Supporting both
TRUST_PROXYandZERO_TRUSTstrategies. - Authorization: Role-based access control (RBAC) enforcement.
- Caching & Locking: A Redis-backed cache implementation with support for distributed locking.
- S2S Authentication: Secure server-to-server communication using identity provider admin tokens.
Location
Development Workflow
When adding functionality that is needed by multiple services (e.g., a new logging format or a shared metric), it should be implemented in the appropriate common package first.
- Modify the package in
citadel/packages/. - Run Tests for the package to ensure no regressions.
- Update the
go.mod(for Go) orpackage.json(for TS) in the dependent services to use the new version.