Skip to content

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

Open
arusinowski wants to merge 1 commit into
14.x-cake5.4from
feature/14.x
Open

arusinowski wants to merge 1 commit 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
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