Skip to content

Multi-tenant enhancements: JWT resolver, PHPStan, HTTP layer, coverage#7

Merged
vedavith merged 5 commits into
mainfrom
feature/forge-multi-tenant
Jun 8, 2026
Merged

Multi-tenant enhancements: JWT resolver, PHPStan, HTTP layer, coverage#7
vedavith merged 5 commits into
mainfrom
feature/forge-multi-tenant

Conversation

@vedavith

@vedavith vedavith commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • JwtTenantResolver — extracts tenant_id from a signed Bearer JWT; registered
    as resolver: jwt; configurable algorithm, claim name, and public key
  • PHPStan level 5 — added as dev dependency, wired into CI before tests
  • Topological entity generation — generate:all resolves belongsTo dependencies
    so migration timestamps are ordered correctly across related entities
  • Post entity schema — example entity with belongsTo User and composite indexes
  • CI fix — Codecov GPG key import + fail_ci_if_error: false
  • Readme rewrite — fully reflects HTTP layer, DI container, middleware pipeline,
    tenant lifecycle, migration dry-run, boot sequence, and key invariants

vedavith added 5 commits June 8, 2026 10:56
…key handling

- Add `sortByDependencies` to ensure entities with dependencies are generated in the correct order.
- Detect and report circular dependencies during sorting.
- Enhance handling of primary keys in `EntityGenerator` and `MigrationBuilder` to support entities with non-standard primary key names.
- Update `EntitySchema` to expose primary key details.
Extracts tenant_id (or a configurable claim) from a signed JWT in the
Authorization header. Registered in TenantResolverFactory as resolver
type 'jwt'. Configurable via tenancy.jwt_public_key, jwt_algorithm
(default RS256), and jwt_tenant_claim (default tenant_id).

8 tests covering happy path, custom claim, case-insensitive header,
missing header, wrong scheme, invalid token, missing claim, and expiry.
User.json: rename id→user_id, add unique email index and name index.
Post.json: new entity with belongsTo User relation and composite indexes.
application.yaml: switch active resolver back to header, leave JWT
config commented for reference.
The unsupported-type test was using 'jwt' as the unknown resolver, which
is now valid. Changed to 'unknown' so the test correctly exercises the
default throw branch.
@vedavith vedavith merged commit 8fceb5f into main Jun 8, 2026
2 checks passed
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.01266% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Console/GenerateAllCommand.php 75.67% 9 Missing ⚠️
src/Tenant/TenantResolverFactory.php 0.00% 5 Missing ⚠️
src/Generator/Schema/EntitySchema.php 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant