Skip to content

Conversation

@dereuromark
Copy link
Member

Summary

Adds rector rules to automate the Authentication plugin 3.x to 4.x migration:

  • Class renames:

    • Authentication\UrlChecker\CakeRouterUrlCheckerAuthentication\UrlChecker\DefaultUrlChecker
    • Authentication\UrlChecker\DefaultUrlChecker (framework-agnostic) → Authentication\UrlChecker\GenericUrlChecker
    • Authentication\PluginAuthentication\AuthenticationPlugin
  • Method removal:

    • AuthenticationService::loadIdentifier() - removed in 4.x

Usage

bin/cake upgrade rector --rules authentication40

Or in custom rector config:

use Cake\Upgrade\Rector\Set\CakePHPSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([CakePHPSetList::AUTHENTICATION_40]);
};

Not automated

Some changes require manual intervention and are documented in the upgrade guide:

  1. Constant relocations - CREDENTIAL_USERNAME/CREDENTIAL_PASSWORD moved from AbstractIdentifier to PasswordIdentifier/LdapIdentifier
  2. IdentifierCollection removal - Identifiers are now configured per-authenticator
  3. MultiUrlChecker - Auto-detection removed, requires explicit configuration

Related

Adds rules to automate the 3.x to 4.x migration for the authentication plugin:

- Rename CakeRouterUrlChecker to DefaultUrlChecker
- Rename DefaultUrlChecker (framework-agnostic) to GenericUrlChecker
- Rename Plugin to AuthenticationPlugin
- Remove loadIdentifier() method calls

See: cakephp/authentication#748
Comment on lines +18 to +20
'Authentication\UrlChecker\DefaultUrlChecker' => 'Authentication\UrlChecker\StringUrlChecker',
// CakeRouterUrlChecker renamed to DefaultUrlChecker
'Authentication\UrlChecker\CakeRouterUrlChecker' => 'Authentication\UrlChecker\DefaultUrlChecker',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run this more than once will all the UrlChecker references end up as StringUrlChecker?

Copy link
Member Author

@dereuromark dereuromark Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is not really idempotent right now

I dont have any great ideas other than: Marker comment

  // @upgraded-authentication-4.0
  use Authentication\UrlChecker\DefaultUrlChecker;

and then skip it.

This could be a bit difficult with inline usage of FQCN.

Alternative: file-level docblock

  <?php
  /**
   * @rector-upgraded authentication40
   */

once we run it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or: we just drop the old Default one rename.
And only rename the cake to default one.

No one outside of cake would use the upgrade tool here, and the few cases of people using the "external" over the cake router internal one would be almost irrelevant I assume.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping the rename on the existing default checker could work. I agree that there are likely few references to it in application code.

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.

3 participants