Feat/fabrica foundation - #44
Draft
alexlovelltroy wants to merge 3 commits into
Draft
Conversation
Establishes Fabrica-based architecture for TokenSmith with zero breaking changes. ## Infrastructure - apis.yaml: Define BootstrapTokenPolicy and RefreshTokenFamily resources - .fabrica.yaml: Fabrica configuration for code generation - internal/storage/: Ent ORM with 44 generated files for PostgreSQL - pkg/apiversion/, pkg/client/, pkg/resources/: Fabrica client libraries - cmd/server/: Fabrica-generated REST handlers (6 files) ## Server Entry Point - cmd/server/main.go: HTTP server with graceful shutdown * OAuth token endpoint: POST /oauth/token (RFC 8693) * JWKS endpoint: GET /.well-known/jwks.json * Health check: GET /health - cmd/server/runtime_helpers.go: Ent initialization and TokenService wiring * initializeStorage(): Ent client + SetEntClient() integration * initializeTokenService(): keyManager + Config from environment ## Key Features - Dual storage: DATABASE_URL → PostgreSQL, else file-based (rollback safety) - Preserves existing pkg/tokenservice (all 66 RFC/NIST annotations intact) - Zero breaking changes to HTTP API - Production-ready with both storage backends ## Verification - Server builds successfully - All 19 test files pass (63.6% coverage) - Compatible with existing TokenService implementation This foundation enables incremental migration of business logic to internal/ packages while maintaining backward compatibility.
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
…eaders in generated files - Created a new document `Relevant_RFC_and_NIST.md` to validate normative references for RFC 8693 and NIST guidelines. - Updated all generated Go files in the `ent` package to include SPDX license headers for OpenCHAMI Contributors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces the initial Fabrica integration for the TokenSmith service, laying the foundation for RFC 8693-compliant token exchange with PostgreSQL-backed storage. The main changes include adding Fabrica resource definitions for bootstrap and refresh tokens, implementing bidirectional adapters for seamless migration from legacy models, and providing a new
main.goserver entrypoint with support for both file-based and PostgreSQL storage. The Makefile is also updated with integration test targets.Fabrica resource definitions and adapters:
BootstrapTokenPolicyandRefreshTokenFamilyFabrica resource types with immutable policy (Spec) and mutable state (Status) separation, supporting RFC 8693 and NIST SP 800-63-4 compliance. (apis/tokensmith.openchami.io/v1/bootstrap_token_policy_types.go[1]apis/tokensmith.openchami.io/v1/refresh_token_family_types.go[2]apis/tokensmith.openchami.io/v1/adapters.goapis/tokensmith.openchami.io/v1/adapters.goR1-R181)Project configuration and Fabrica integration:
.fabrica.yamlandapis.yamlto declare project metadata, enable strict validation, and define Fabrica resources and storage strategies (PostgreSQL via Ent ORM). (.fabrica.yaml[1]apis.yaml[2]Server entrypoint and storage initialization:
cmd/server/main.goas the new main entrypoint, supporting both file-based and PostgreSQL storage, with endpoints for RFC 8693 token exchange and JWKS, and graceful shutdown logic. (cmd/server/main.gocmd/server/main.goR1-R102)Build and test improvements:
Makefileto add integration test targets for both general and PostgreSQL-specific test runs. (Makefile[1] [2]Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryDescription
Please include a summary of the change and which issue is fixed.
Also include relevant motivation and context.
Fixes #(issue)
Type of Change
For more info, see Contributing Guidelines.