From 8a6437a05b0e511ea271767878f944d75bc45aeb Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Wed, 22 Jan 2025 16:42:24 +0200 Subject: [PATCH 1/3] Issue #16: Added support for PHP 8.4 Signed-off-by: alexmerlin --- README.md | 29 ++++++++++++++++------------- composer.json | 11 ++++++----- docs/book/index.md | 0 docs/book/v3/configuration.md | 2 +- docs/book/v3/installation.md | 4 +++- docs/book/v3/overview.md | 2 +- docs/book/v3/usage.md | 22 ++++++++++++++++------ mkdocs.yml | 2 +- 8 files changed, 44 insertions(+), 28 deletions(-) mode change 100644 => 120000 docs/book/index.md diff --git a/README.md b/README.md index fff9b5b..ae23e1e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # dot-authorization -Authorization base package defining interfaces for authorization services to be used with DotKernel applications. +Authorization base package defining interfaces for authorization services to be used with Dotkernel applications. ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-authorization) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authorization/3.4.1) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authorization/3.6.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/network) @@ -13,21 +13,19 @@ Authorization base package defining interfaces for authorization services to be [![Build Static](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-authorization/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-authorization) -[![SymfonyInsight](https://insight.symfony.com/projects/014df510-1cf7-4876-b1a8-303fbef2f364/big.svg)](https://insight.symfony.com/projects/014df510-1cf7-4876-b1a8-303fbef2f364) - ## Installation -Run the following command in you project directory +Run the following command in you project directory: -```bash -$ composer require dotkernel/dot-authorization +```shell +composer require dotkernel/dot-authorization ``` -Please note that usually this pacakge will be installed as a dependency to a concrete implementation, so you won't need to add this to your project manually. +Please note that usually this package will be installed as a dependency to a concrete implementation, so you won't need to add this to your project manually. ## AuthorizationInterface -Defines the interface that should be implemented by any authorization service, in order to work with DotKernel applications. This is a result of the fact that, by default, any DotKernel package which has to do with authorization is assuming that a service is registered in the service container using as service name this interface's FQN +Defines the interface that should be implemented by any authorization service, in order to work with Dotkernel applications. This is a result of the fact that, by default, any Dotkernel package which has to do with authorization is assuming that a service is registered in the service container using as service name this interface's FQN ### Methods @@ -47,12 +45,17 @@ public function getName(): string; ## IdentityInterface -Interface that needs to be implemented by entities that support roles. They should be able to retrieve their roles by defining a `getRoles()` method. -The roles should be an array of role names or role objects +Interface that needs to be implemented by entities that support roles. +They should be able to retrieve their roles by defining a `getRoles()` method. +The roles should be an array of role names or role objects. -This package is suitable for RBAC style authorization. Roles can be flat or hierarchical and they are assigned permissions. +This package is suitable for RBAC style authorization. +Roles can be flat or hierarchical, and they are assigned permissions. A role is granted if it has the required permission. ## ForbiddenException -Exception to be thrown when accessing content without having the required permissions. This can be used withing an application to trigger a forbidden error and do a custom action(like displaying a forbidden page or redirecting). This package does not define how you should handle such situations. There is a concrete authorization implementation in [dot-rbac](https://github.com/dotkernel/dot-rbac) and a forbidden exception handler in [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) as DotKernel default packages for authorization. +Exception to be thrown when accessing content without having the required permissions. +This can be used withing an application to trigger a forbidden error and do a custom action(like displaying a forbidden page or redirecting). +This package does not define how you should handle such situations. +There is a concrete authorization implementation in [dot-rbac](https://github.com/dotkernel/dot-rbac) and a forbidden exception handler in [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) as Dotkernel default packages for authorization. diff --git a/composer.json b/composer.json index e42eb0e..0651da4 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { "name": "dotkernel/dot-authorization", "type": "library", - "description": "DotKernel authorization service abstractions", + "description": "Dotkernel authorization service abstractions", "license": "MIT", "homepage": "https://github.com/dotkernel/dot-authorization", "authors": [ { - "name": "DotKernel Team", + "name": "Dotkernel Team", "email": "team@dotkernel.com" } ], @@ -16,10 +16,10 @@ "laminas-dependency" ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "require-dev": { - "laminas/laminas-coding-standard": "^2.5", + "laminas/laminas-coding-standard": "^3.0", "phpunit/phpunit": "10.2", "vimeo/psalm": "^5.13" }, @@ -42,7 +42,8 @@ "scripts": { "check": [ "@cs-check", - "@test" + "@test", + "@static-analysis" ], "cs-check": "phpcs", "cs-fix": "phpcbf", diff --git a/docs/book/index.md b/docs/book/index.md deleted file mode 100644 index fe84005..0000000 --- a/docs/book/index.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md \ No newline at end of file diff --git a/docs/book/index.md b/docs/book/index.md new file mode 120000 index 0000000..fe84005 --- /dev/null +++ b/docs/book/index.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/docs/book/v3/configuration.md b/docs/book/v3/configuration.md index 70109b0..dafc7a6 100644 --- a/docs/book/v3/configuration.md +++ b/docs/book/v3/configuration.md @@ -1,3 +1,3 @@ # Configuration -Please note that usually this pacakge will be installed as a dependency to a concrete implementation, so you won't need to add this to your project manually. +Please note that usually this package will be installed as a dependency to a concrete implementation, so you won't need to add this to your project manually. diff --git a/docs/book/v3/installation.md b/docs/book/v3/installation.md index 97b7fcb..7b019f1 100644 --- a/docs/book/v3/installation.md +++ b/docs/book/v3/installation.md @@ -2,4 +2,6 @@ Install `dot-authorization` by executing the following Composer command: - composer require dotkernel/dot-authorization +```shell +composer require dotkernel/dot-authorization +``` diff --git a/docs/book/v3/overview.md b/docs/book/v3/overview.md index 7916f16..b41e2a6 100644 --- a/docs/book/v3/overview.md +++ b/docs/book/v3/overview.md @@ -1,3 +1,3 @@ # Overview -`dot-authorization` is DotKernel's authorization base package which define interfaces for authorization services to be used with DotKernel applications. +`dot-authorization` is Dotkernel's authorization base package which define interfaces for authorization services to be used with Dotkernel applications. diff --git a/docs/book/v3/usage.md b/docs/book/v3/usage.md index e4d18c9..2bab03c 100644 --- a/docs/book/v3/usage.md +++ b/docs/book/v3/usage.md @@ -2,7 +2,8 @@ ## AuthorizationInterface -Defines the interface that should be implemented by any authorization service, in order to work with DotKernel applications. This is a result of the fact that, by default, any DotKernel package which has to do with authorization is assuming that a service is registered in the service container using as service name this interface's FQN +Defines the interface that should be implemented by any authorization service, in order to work with Dotkernel applications. +This is a result of the fact that, by default, any Dotkernel package which has to do with authorization is assuming that a service is registered in the service container using as service name this interface's FQN. ### Methods @@ -10,11 +11,15 @@ Defines the interface that should be implemented by any authorization service, i public function isGranted(string $permission, array $roles = [], $context = null): bool; ``` -* this is the only method that deals with authorization. Given a permission and a list of roles, should return a boolean value of true if at least one role has access to the requested permission. As you can see, we expect that the authorization service to be implemented as an RBAC. +> This is the only method that deals with authorization. + +Given a permission and a list of roles, should return a boolean value of true if at least one role has access to the requested permission. +As you can see, we expect that the authorization service to be implemented as an RBAC. ## RoleInterface -Defines the interface that Role objects must implement. A role object should be able to retrieve its name, so this interface has only one method defined +Defines the interface that Role objects must implement. +A role object should be able to retrieve its name, so this interface has only one method defined. ```php public function getName(): string; @@ -22,12 +27,17 @@ public function getName(): string; ## IdentityInterface -Interface that needs to be implemented by entities that support roles. They should be able to retrieve their roles by defining a `getRoles()` method. +Interface that needs to be implemented by entities that support roles. +They should be able to retrieve their roles by defining a `getRoles()` method. The roles should be an array of role names or role objects -This package is suitable for RBAC style authorization. Roles can be flat or hierarchical and they are assigned permissions. +This package is suitable for RBAC style authorization. +Roles can be flat or hierarchical and they are assigned permissions. A role is granted if it has the required permission. ## ForbiddenException -Exception to be thrown when accessing content without having the required permissions. This can be used withing an application to trigger a forbidden error and do a custom action(like displaying a forbidden page or redirecting). This package does not define how you should handle such situations. There is a concrete authorization implementation in [dot-rbac](https://github.com/dotkernel/dot-rbac) and a forbidden exception handler in [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) as DotKernel default packages for authorization. +Exception to be thrown when accessing content without having the required permissions. +This can be used withing an application to trigger a forbidden error and do a custom action(like displaying a forbidden page or redirecting). +This package does not define how you should handle such situations. +There is a concrete authorization implementation in [dot-rbac](https://github.com/dotkernel/dot-rbac) and a forbidden exception handler in [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) as Dotkernel default packages for authorization. diff --git a/mkdocs.yml b/mkdocs.yml index 1a97e33..c9f39c9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,7 +13,7 @@ nav: - Configuration: v3/configuration.md - Usage: v3/usage.md site_name: dot-authorization -site_description: "DotKernel authorization service abstractions" +site_description: "Dotkernel authorization service abstractions" repo_url: "https://github.com/dotkernel/dot-authorization" plugins: - search From 1ee8250973ebba3f0b854dccc3a92dc0c606a7c7 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Wed, 22 Jan 2025 16:45:10 +0200 Subject: [PATCH 2/3] Added .laminas-ci.json Signed-off-by: alexmerlin --- .laminas-ci.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .laminas-ci.json diff --git a/.laminas-ci.json b/.laminas-ci.json new file mode 100644 index 0000000..790cfe4 --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,6 @@ +{ + "ignore_php_platform_requirements": { + "8.4": true + }, + "backwardCompatibilityCheck": true +} From f2c25349abc10407eb7c23a43525475506c9353d Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Wed, 22 Jan 2025 16:45:53 +0200 Subject: [PATCH 3/3] Fixed .laminas-ci.json Signed-off-by: alexmerlin --- .laminas-ci.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index 790cfe4..82cd446 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,6 +1,6 @@ -{ - "ignore_php_platform_requirements": { - "8.4": true - }, - "backwardCompatibilityCheck": true -} +{ + "ignore_php_platform_requirements": { + "8.4": true + }, + "backwardCompatibilityCheck": true +}