Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 2.x
- 2.next
- 3.x
- 4.x
pull_request:
branches:
- '*'
Expand All @@ -16,9 +17,9 @@ permissions:

jobs:
testsuite:
uses: cakephp/.github/.github/workflows/testsuite-without-db.yml@5.x
uses: cakephp/.github/.github/workflows/testsuite-without-db.yml@6.x
secrets: inherit

cs-stan:
uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x
uses: cakephp/.github/.github/workflows/cs-stan.yml@6.x
secrets: inherit
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="2.1.55" installed="2.1.55" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="2.2.14" installed="2.2.14" location="./tools/phpstan" copy="false"/>
</phive>
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
"docs": "https://cakephp.org/authorization/2/en/"
},
"require": {
"php": ">=8.1",
"cakephp/http": "^5.1",
"php": ">=8.4",
"cakephp/http": "^6.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"cakephp/authentication": "^3.0 || ^4.0",
"cakephp/bake": "^3.2",
"cakephp/cakephp": "^5.1",
"cakephp/cakephp-codesniffer": "^5.3",
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4 || ^13.0"
"cakephp/authentication": "^5.0",
"cakephp/bake": "^4.0",
"cakephp/cakephp": "^6.0",
"cakephp/cakephp-codesniffer": "^6.0",
"phpunit/phpunit": "^13.0"
},
"suggest": {
"cakephp/http": "To use \"RequestPolicyInterface\" (Not needed separately if using full CakePHP framework).",
Expand Down Expand Up @@ -73,12 +73,12 @@
"stan": "@phpstan",
"stan-baseline": "tools/phpstan --generate-baseline",
"stan-setup": "phive install",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.3.1\" && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.6.0\" && mv composer.backup composer.json",
"rector-check": "vendor/bin/rector process --dry-run",
"rector-fix": "vendor/bin/rector process",
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover=clover.xml"
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true
}
11 changes: 6 additions & 5 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const tocFr = require('./toc_fr.json')
const tocJa = require('./toc_ja.json')

const versions = {
text: '3.x',
text: '4.x',
items: [
{ text: '3.x (current)', link: 'https://book.cakephp.org/authorization/3/', target: '_self' },
{ text: '4.x (current)', link: 'https://book.cakephp.org/authorization/4/', target: '_self' },
{ text: '3.x', link: 'https://book.cakephp.org/authorization/3/', target: '_self' },
{ text: '2.x', link: 'https://book.cakephp.org/authorization/2/en/', target: '_self' },
],
}
Expand All @@ -20,12 +21,12 @@ export default {
srcDir: '.',
title: 'Authorization',
description: 'CakePHP Authorization Documentation',
base: '/authorization/3/',
base: '/authorization/4/',
rewrites: {
'en/:slug*': ':slug*',
},
sitemap: {
hostname: 'https://book.cakephp.org/authorization/3/',
hostname: 'https://book.cakephp.org/authorization/4/',
},
themeConfig: {
siteTitle: false,
Expand All @@ -34,7 +35,7 @@ export default {
{ icon: 'github', link: 'https://github.com/cakephp/authorization' },
],
editLink: {
pattern: 'https://github.com/cakephp/authorization/edit/3.x/docs/:path',
pattern: 'https://github.com/cakephp/authorization/edit/4.x/docs/:path',
text: 'Edit this page on GitHub',
},
sidebar: tocEn,
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/toc_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"collapsed": false,
"items": [
{ "text": "2.0 Migration Guide", "link": "/2-0-migration-guide" },
{ "text": "3.0 Migration Guide", "link": "/3-0-migration-guide" }
{ "text": "3.0 Migration Guide", "link": "/3-0-migration-guide" },
{ "text": "4.0 Migration Guide", "link": "/4-0-migration-guide" }
]
}
]
Expand Down
74 changes: 74 additions & 0 deletions docs/en/4-0-migration-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 4.0 Migration Guide

Authorization 4.0 supports CakePHP 6.

## Requirements

Authorization 4.0 requires CakePHP 6.0 and PHP 8.4.0 or higher.

## Container Classes Moved

`Cake\Core\Container` and `Cake\Core\ContainerInterface` moved to the
`Cake\Container` namespace:

- `Cake\Core\Container` is now `Cake\Container\Container`
- `Cake\Core\ContainerInterface` is now `Cake\Container\ContainerInterface`

`AuthorizationMiddleware`, `MapResolver`, and `OrmResolver` accept a container
as their constructor argument, and now type hint `Cake\Container\ContainerInterface`.
Update your imports, including where you subclass these classes and override
their constructors.

## Protected Properties Renamed

CakePHP 6 dropped the underscore prefix from protected properties. The
following properties were renamed. This only affects applications that
subclass these classes:

- `AuthorizationComponent`, `AuthorizationMiddleware`, and
`RequestAuthorizationMiddleware`: `$_defaultConfig` is now `$defaultConfig`
- `AuthorizationComponent`: `$_config`, from `InstanceConfigTrait`, is now
`$config`
- `MissingIdentityException`, `AuthorizationRequiredException`,
`ForbiddenException`, `MissingMethodException`, and `MissingPolicyException`:
`$_defaultCode` and `$_messageTemplate` are now `$defaultCode` and
`$messageTemplate`

The exception properties must match the names used by
`Cake\Http\Exception\HttpException`, otherwise the status codes and message
templates defined by these classes are ignored.

## Fluent Methods Declare Static Return Types

The following methods now declare a `static` return type. Subclasses that
override them must declare a compatible return type:

- `AuthorizationComponent::skipAuthorization()`
- `AuthorizationComponent::mapAction()`
- `AuthorizationComponent::mapActions()`
- `AuthorizationComponent::authorizeModel()`
- `MapResolver::map()`
- `ResolverCollection::add()`

## Constructor Changes

`IdentityDecorator::__construct()` renamed its first parameter from `$service`
to `$authorization` to match the promoted property. Positional arguments are
unaffected. Calls using named arguments must be updated.

`AuthorizationService`, `IdentityDecorator`, `AuthorizationMiddleware`,
`ForbiddenException`, `MapResolver`, `OrmResolver`, and `Result` now declare
their constructor-assigned properties as promoted properties. The visibility
and default values of these properties are unchanged.

## Bake Command

`Authorization\Command\PolicyCommand` targets the Bake 6 API:

- `templateData()` no longer accepts an `Arguments` instance, it reads the name
and type from the command's stored arguments.
- `bakeTest()` now only accepts a class name.
- `buildOptionParser()` is now `protected`.

Only applications that subclass `PolicyCommand` are affected. The
`bin/cake bake policy` command line interface is unchanged.
4 changes: 2 additions & 2 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Install the plugin with [Composer](https://getcomposer.org/) from your CakePHP
project root, where `composer.json` is located:

```bash
php composer.phar require "cakephp/authorization:^3.0"
php composer.phar require "cakephp/authorization:^4.0"
```

Authorization 3.x is compatible with CakePHP 5.
Authorization 4.x is compatible with CakePHP 6.

Load the plugin in `src/Application.php`:

Expand Down
2 changes: 1 addition & 1 deletion docs/es/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Instale el plugin con [Composer](https://getcomposer.org/) desde el directorio
raíz de su proyecto CakePHP:

```bash
php composer.phar require "cakephp/authorization:^3.0"
php composer.phar require "cakephp/authorization:^4.0"
```

Cargue el plugin en `src/Application.php`:
Expand Down
4 changes: 2 additions & 2 deletions docs/fr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Installez le plugin avec [Composer](https://getcomposer.org/) depuis le
répertoire racine de votre projet CakePHP, là où se trouve `composer.json` :

```bash
php composer.phar require "cakephp/authorization:^3.0"
php composer.phar require "cakephp/authorization:^4.0"
```

La version 3 du plugin Authorization est compatible avec CakePHP 5.
La version 4 du plugin Authorization est compatible avec CakePHP 6.

Chargez le plugin dans `src/Application.php` :

Expand Down
4 changes: 2 additions & 2 deletions docs/ja/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ CakePHP プロジェクトのルートディレクトリで
[Composer](https://getcomposer.org/) を使ってプラグインを追加します。

```bash
php composer.phar require "cakephp/authorization:^3.0"
php composer.phar require "cakephp/authorization:^4.0"
```

Authorization 3.x は CakePHP 5 に対応しています。
Authorization 4.x は CakePHP 6 に対応しています。

`src/Application.php` でプラグインを読み込みます。

Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<file>src/</file>
<file>tests/</file>

<arg value="nps"/>
<arg value="ps"/>
<arg name="colors"/>
<arg name="parallel" value="4"/>
<arg name="cache" value=".phpcs.cache"/>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ bin/cake plugin load Authorization
## Documentation

Documentation for this plugin can be found in the [CakePHP
Cookbook](https://book.cakephp.org/authorization/3/en/)
Cookbook](https://book.cakephp.org/authorization/4/)
Loading
Loading