Skip to content

feat: permission ID chars, middleware ::class deps, ServiceRouter path#406

Merged
usernane merged 3 commits into
mainfrom
dev
Jul 13, 2026
Merged

feat: permission ID chars, middleware ::class deps, ServiceRouter path#406
usernane merged 3 commits into
mainfrom
dev

Conversation

@usernane

Copy link
Copy Markdown
Member

Summary

Add support for dots/dashes in permission IDs, ::class syntax in middleware dependencies, and custom path property in ServiceRouter.

Motivation

Changes

  • Expanded character validation in Privilege::setID(), PrivilegesGroup::isValidID(), and Access::validateId() to accept . and -
  • Added findByClass() to MiddlewareRegistry
  • Added resolveDepToName() and lookupMiddleware() helpers to RouterUri for class-based dependency resolution
  • Updated resolveDependencies() and sortByDependencies() to support ::class syntax
  • Added path property priority in ServiceRouter::scanNamespace()
  • Updated webfiori/http dependency to 6.0.3

How to Test / Verify

All changes are covered by unit tests:

  • PrivilegeTest — 6 new tests for dotted/dashed IDs
  • AccessTest — updated assertion for dash acceptance
  • MiddlewareClassSyntaxDepsTest — 6 new tests for ::class resolution
  • ServiceRouterTest — 4 new tests for path property routing

Run: composer test

Breaking Changes and Migration Steps

None. All changes are backward compatible:

  • Existing permission IDs using [A-Za-z0-9_] continue to work
  • String-based middleware dependencies still work
  • Services without path property behave as before

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed) Docs Repo
  • I ran lint/cs-fixer (if applicable) (composer fix-cs)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #404, Closes #405, Closes #398

Ibrahim BinAlshikh added 3 commits July 14, 2026 00:23
Expand character validation in Privilege::setID(), PrivilegesGroup::isValidID(),
and Access::validateId() to accept '.' and '-' characters. Previously, IDs
containing these characters silently fell back to the default 'PR', causing
permissions to collide.

Closes #404
Add class name resolution for middleware dependencies. When a dependency
string is a valid class name, the registry is searched for a matching
instance instead of only matching by name. Both string names and ::class
syntax can be mixed in the same getDependencies() array.

Changes:
- Add findByClass() to MiddlewareRegistry
- Add resolveDepToName() and lookupMiddleware() helpers to RouterUri
- Update resolveDependencies() and sortByDependencies() to use them

Closes #405
… path property

When #[RestController] has a non-empty path property, use it as the route
key instead of name or derived class name. This allows multi-segment paths
like 'auth/login' or 'v2/users/profile'. The path property takes priority
over name; existing behavior is unchanged when path is empty.

Closes #398
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.76%. Comparing base (48bd9de) to head (4c2e048).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...bFiori/Framework/Middleware/MiddlewareRegistry.php 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #406      +/-   ##
============================================
+ Coverage     83.72%   83.76%   +0.03%     
- Complexity     3132     3151      +19     
============================================
  Files           106      106              
  Lines          9230     9257      +27     
============================================
+ Hits           7728     7754      +26     
- Misses         1502     1503       +1     
Flag Coverage Δ
php-8.1 82.68% <100.00%> (+0.04%) ⬆️
php-8.2 82.68% <100.00%> (+0.04%) ⬆️
php-8.3 91.92% <97.43%> (+0.01%) ⬆️
php-8.4 91.92% <97.43%> (+0.01%) ⬆️
php-8.5 91.80% <97.43%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@usernane
usernane merged commit 0cb8214 into main Jul 13, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant