Skip to content

Commit

Permalink
Merge pull request #17 from dotkernel/issue-16
Browse files Browse the repository at this point in the history
Issue #16: Added support for PHP 8.4
  • Loading branch information
alexmerlin authored Jan 22, 2025
2 parents 657817b + f2c2534 commit b8f3955
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignore_php_platform_requirements": {
"8.4": true
},
"backwardCompatibilityCheck": true
}
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -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.
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
],
Expand All @@ -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"
},
Expand All @@ -42,7 +42,8 @@
"scripts": {
"check": [
"@cs-check",
"@test"
"@test",
"@static-analysis"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
Expand Down
1 change: 0 additions & 1 deletion docs/book/index.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/book/index.md
2 changes: 1 addition & 1 deletion docs/book/v3/configuration.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 3 additions & 1 deletion docs/book/v3/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

Install `dot-authorization` by executing the following Composer command:

composer require dotkernel/dot-authorization
```shell
composer require dotkernel/dot-authorization
```
2 changes: 1 addition & 1 deletion docs/book/v3/overview.md
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 16 additions & 6 deletions docs/book/v3/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,42 @@

## 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

```php
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;
```

## 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.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b8f3955

Please sign in to comment.