Skip to content

Prepare 14.0.0: clean dependency audit, WebAuthn on webauthn-lib 5.3, fixes and tests - #133

Merged
arodu merged 2 commits into
14.x-cake5.4from
feature/14.x
Dec 2, 2026
Merged

arodu merged 2 commits into
14.x-cake5.4from
feature/14.x

Conversation

@arusinowski

@arusinowski arusinowski commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

14.0.0 for CakePHP 5.4. With this release 14.x is the only maintained version for CakePHP 5, and 11.x the only one for CakePHP 4 (see the README).

composer audit reports no security advisory for the plugin's dependencies. Every change is in CHANGELOG.md; what an application must change is in docs/Documentation/upgrading.md.

Breaking changes

  • WebAuthn needs web-auth/webauthn-lib ^5.3.13 instead of 4.x, and cakedc/users ^17.1, which uses the same version. Registered keys keep working and the JSON for clients keeps its shape. A registration or login that is in progress during the deploy must be started again. CakeDC\Api\Webauthn\PublicKeyCredentialLoader is removed; the adapters and the repository work with Webauthn\CredentialRecord.
  • Flysystem renderer uses Flysystem 3: the result filesystem must be a FilesystemOperator, deliverAsset() has a new signature and getFile() is removed.
  • OTP needs robthree/twofactorauth ^3.0.1 and endroid/qr-code ^5 or ^6.
  • JWT: firebase/php-jwt ^7 only, and cakephp/authentication ^4.2 is required directly. lcobucci/jwt and lcobucci/clock are no longer required: tokens are now signed with firebase/php-jwt, byte for byte the same as before, and tokens issued earlier stay valid. A secret shorter than 64 bytes is refused with an InvalidArgumentException instead of Lcobucci\JWT\Signer\InvalidKeyProvided. An application that uses Lcobucci\JWT itself must require it.
  • Attribute resolver: crustum/cakephp-attribute-resolver ^1.0.3. Older versions can read the same attribute twice, which doubled the path of an #[ApiScope].
  • Removed classes: CakeDC\Api\Plugin (use ApiPlugin) and Middleware\RequestHandlerMiddleware (use BodyParserMiddleware).
  • Old member names: a class that still overrides a plugin member by its pre-13.0 underscore name is refused with a CakeException that lists the members, because such an override is never called. Api.legacyMemberGuard => false turns the check off.
  • Signatures: OtpVerifyGetAction::onVerifyGetSecret() no longer types its parameter as array; SecondFactorTrait::hasVerifiedOtp() and hasWebauthnCredential() type theirs as EntityInterface|array|null.
  • Attribute routes: patterns, pass, name and defaults of #[ApiRoute], the verb attributes and #[ApiScope] were ignored in 13.x and now take effect.
  • Configuration: Api.Jwt.enabled and require_ssl are removed from config/api.php. Neither was ever read.

New

  • Sort and ExtendedSort: an order setting for a default order; ignored sort fields are logged at debug level.
  • JWT refresh: an auth_time claim and the Api.Jwt.RefreshToken.maxSessionLifetime setting, which bounds a session however often it is refreshed.
  • A Rector set for applications that upgrade from 12.x (config/rector/cakephp-api-13.php). It renames the members that lost their underscore, replaces the removed classes, and adds the native type of every plugin property a subclass redeclares.
  • Service::mapAction() accepts patterns, pass and name; bin/cake service routes --sort.

Fixes

  • Versioning: a version without its own service class is served by the application's unversioned service instead of FallbackService. Such a version, and the default version, also read the unversioned Api.Service.<service> options, so an option of the service cannot be skipped by asking for another version number.
  • Service errors: a service that cannot be built is no longer answered with an empty HTTP 400 and nothing in the logs. The exception goes to the application's error handling.
  • RBAC: a role that is not a string no longer fails with a TypeError. A role held as an enum is matched by its value; a role that cannot be matched, such as an array, is denied with a logged warning instead of being treated as the default role.
  • WebAuthn: a failed verification answers 401 or 400 instead of 500; no crash without an Authorization header; a domain without settings answers 400; a credential id that is already registered is refused.
  • OTP: a missing or non-scalar code is an invalid code, not a 500.
  • Extensions: services load their $extensions; actions load extensions listed without a plugin prefix.
  • RegisterAction dispatches Users.Global.afterRegister; FileRenderer answers 404 for a missing file; pagination values below 1 fall back to the defaults; reCaptcha without a token fails validation; CrudAction accepts a table name as its table option; Action::transform() returns an empty list for an empty list.
  • Smaller fixes: CORS action mapping, OptionsHandlerExtension, the request method in LogExtension, dates in XmlRenderer, social login.

Documentation

The documentation was checked against the code and corrected in about 70 places, among them:

  • Access is decided by the rules in config/api_permissions.php, not by Auth.allow.
  • A callable or Rule under allowed is also called for a request without a user.
  • Examples now load on CakePHP 5.
  • The JWT tutorial was replaced by the shipped jwt_login and jwt_refresh actions.

Deprecated

The pre-10.0 auth layer: Service\Auth\Auth, AuthenticateTrait, AuthenticationExtension and Action::$Auth. They are removed in 15.0.0.

How it was tested

  • PHPUnit: 931 tests and 4327 assertions on PHP 8.3 with SQLite, also with --display-all-issues --fail-on-all-issues.
  • phpcs, PHPStan and the Rector dry run: clean.
  • composer update with advisory blocking on, and composer audit: no advisories.
  • JWT: tests compare the issued tokens byte for byte with tokens built from hash_hmac. They passed on the old lcobucci/jwt code before the switch and pass now.
  • Mutation testing (Infection) on src/Service/Action/Auth.
  • WebAuthn: the flow tests use a software authenticator; no real browser or hardware key was used.
  • Lowest dependencies (composer update --prefer-lowest) with SQLite: 931 tests pass.
  • Not run locally: PHP 8.4 and 8.5, MySQL and PostgreSQL. CI covers them.

… dependency and tooling updates, bug fixes, tests and docs
@arodu

arodu commented Nov 30, 2026

Copy link
Copy Markdown
Member

🚫 Blocking Issues

  • 🔴 [1] All WebAuthn endpoints fail on a PHP build without ext-sodium at src/Webauthn/BaseAdapter.php:528
    • Scenario: a PHP 8.3+ build with sodium disabled (this workspace’s host PHP 8.5.12 is one), WebAuthn configured. GET /api/auth/webauthn2fa_register_options or ..._auth_options enters getAlgorithmManager() and runs new EdDSA(); cose-lib throws RuntimeException: The EdDSA algorithms require the Sodium extension, which is not loaded. The request becomes HTTP 500, so WebAuthn enrollment and login are unusable (password/OTP login still work).
    • Why existing guards miss it: composer.json declares only php >=8.3, not ext-sodium; there is no suggest entry for sodium and no mention in docs/Documentation/upgrading.md. EdDSA::isSupported() exists precisely for this case but is never called. composer audit is clean, so dependency checks do not reveal it.
    • Evidence: running tests/TestCase/Integration/Service/Action/Auth/Webauthn2faFlowTest.php with the host PHP 8.5.12 reproduces 17 failures and 2 errors, all from this exception; under DDEV PHP 8.4.28 and PHP 8.5.13 with sodium, all 931 tests pass.
    • Fix: only add EdDSA when supported, keeping ES256/RS256 working without sodium:
      $manager = Manager::create()->add(/* ES and RSA algorithms */);
      if (EdDSA::isSupported()) {
          $manager->add(new EdDSA());
      }
      and add "ext-sodium" to suggest (or require if WebAuthn should not work without it), plus the upgrade note.

💡 Non-Blocking Suggestions

  • [2] Upgrade note for Ed256/Ed512 keys at docs/Documentation/upgrading.md:89
    • The note says the algorithms are no longer offered, but not that a key registered with -260/-261 on 13.x can no longer authenticate on 14.x. Worse, Webauthn2faRegisterAction refuses a replacement while hasCredentialOnAnyDomain() finds the old credential, so those users stay locked out of WebAuthn until the stored entry is removed. The population should be tiny (only authenticators that selected those non-standard IDs), but the consequence and the cleanup step belong in the upgrade note, or keep the algorithms in the verifier only.

Outside this diff:

  • src/Service/Action/CrudDeleteAction.php:32: Table::delete() result is ignored. A failed delete (a beforeDelete listener returning false, or a database rule) answers HTTP 200 with data: false; the caller is told the record was deleted. Pre-existing; deleteOrFail() or an explicit result check would fail closed. Worth a separate ticket.

🧪 Missing Tests

  • High [Webauthn/BaseAdapter]: there is no test for the unsupported-sodium path; the suite only runs where sodium is loaded, so this regression is invisible in CI. After adding the guard, add a seam (for example a protected eddsaSupported() returning EdDSA::isSupported()) and a test that options still build with ES256/RS256 when it returns false.
  • Medium [Webauthn]: no test for a credential stored by 13.x with an Ed256/Ed512 algorithm. Add one asserting the chosen behaviour (a clear 401, or successful verification if the algorithms are kept for verification only).
  • Test coverage is otherwise strong: 931 tests, including new coverage for JWT byte compatibility, auth_time/maxSessionLifetime, WebAuthn flows, legacy credential reads, routing options, versioning, sorting, extension loading and migration/schema parity.

@arodu
arodu merged commit 9eb2510 into 14.x-cake5.4 Dec 2, 2026
22 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

Development

Successfully merging this pull request may close these issues.

2 participants