From 7c880455bfc6759b11a35fa7926b1aab968045e4 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Thu, 23 Jan 2025 11:21:54 +0200 Subject: [PATCH 1/2] Issue #30: Added support for PHP 8.4 Signed-off-by: alexmerlin --- LICENSE.md | 2 +- README.md | 33 ++++++++++++++++++++------------- composer.json | 9 +++++---- docs/book/index.md | 0 docs/book/v2/installation.md | 4 +++- docs/book/v2/overview.md | 2 +- docs/book/v2/usage.md | 23 ++++++++++++++++------- 7 files changed, 46 insertions(+), 27 deletions(-) mode change 100644 => 120000 docs/book/index.md diff --git a/LICENSE.md b/LICENSE.md index 189eddf..3a5fcde 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 DotKernel +Copyright (c) 2016 Dotkernel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index df8ea30..7469370 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # dot-authentication -Authentication base package defining interfaces for authentication services to be used with DotKernel applications. +Authentication base package defining interfaces for authentication services to be used with Dotkernel applications. ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-authentication) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authentication/2.3.4) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authentication/2.5.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-authentication)](https://github.com/dotkernel/dot-authentication/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-authentication)](https://github.com/dotkernel/dot-authentication/network) @@ -13,21 +13,20 @@ Authentication base package defining interfaces for authentication services to b [![Build Static](https://github.com/dotkernel/dot-authentication/actions/workflows/continuous-integration.yml/badge.svg?branch=2.0)](https://github.com/dotkernel/dot-authentication/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-authentication/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-authentication) -[![SymfonyInsight](https://insight.symfony.com/projects/8a0dfa12-fdda-43d7-bdbe-1c6996b30c12/big.svg)](https://insight.symfony.com/projects/8a0dfa12-fdda-43d7-bdbe-1c6996b30c12) - ## Installation Run the following command in you project directory -```bash -$ composer require dotkernel/dot-authentication +```shell +composer require dotkernel/dot-authentication ``` Please note that usually this package will be installed as a dependency to a concrete implementation, so usually you won't need to add this to you project manually. ## AuthenticationInterface -Defines the interface that should be implemented by any authentication service, in order to work with DotKernel applications. This is a result of the fact that the default packages used by DotKernel applications, that need access to the authentication service are type-hinted against this interface. +Defines the interface that should be implemented by any authentication service, in order to work with Dotkernel applications. +This is a result of the fact that the default packages used by Dotkernel applications, that need access to the authentication service are type-hinted against this interface. Also, concrete implementations should be registered in the service manager using this interface's FQN. @@ -37,13 +36,16 @@ Also, concrete implementations should be registered in the service manager using public function authenticate(ServerRequestInterface $request): AuthenticationResult; ``` -* method to implement the actual authentication process. It should extract credentials from the `$request` object(Authorization header, custom request attributes etc.). It should return an `AuthenticationResult` object, defined in this package, which carry the authentication status and identity on success. +This method is the implementation of the actual authentication process. + +It should extract credentials from the `$request` object (Authorization header, custom request attributes etc.). +It should return an `AuthenticationResult` object, defined in this package, which carry the authentication status and identity on success. ```php public function challenge(ServerRequestInterface $request): ResponseInterface; ``` -* this method should return a valid PSR-7 `ResponseInterface` used to notify the client or browser that it needs to authenticate first(usually using the `WWW-Authenticate` header - usefull for HTTP basic and digest authentication) +This method should return a valid PSR-7 `ResponseInterface` used to notify the client or browser that it needs to authenticate first(usually using the `WWW-Authenticate` header - useful for HTTP basic and digest authentication). ```php public function hasIdentity(): bool; @@ -52,16 +54,21 @@ public function setIdentity(IdentityInterface $identity); public function clearIdentity(); ``` -* these methods are used to check if authenticated, get the authenticated identity object, force set an identity(maybe useful for auto-login) or clear an identity(logout) +These methods are used to check if authenticated, get the authenticated identity object, force set an identity(maybe useful for auto-login) or clear an identity(logout) ## IdentityInterface -You can use any object to represent an authenticated identity(user) as long as it implements this interface. It requires 2 methods, `getId()` which should return the unique identifier of the identity, and `getName(): string` which should return a string representation of the identity(for display purposes, usually the email or username) +You can use any object to represent an authenticated identity(user) as long as it implements this interface. +It requires 2 methods, `getId()` which should return the unique identifier of the identity, and `getName(): string` which should return a string representation of the identity(for display purposes, usually the email or username). ## AuthenticationResult -Returned by the authentication service, on authentication success or failure. It composes one of the predefined authentication codes, which describes the authentication status, an error message in case the authentication has failed, and the identity object on success. +Returned by the authentication service, on authentication success or failure. +It composes one of the predefined authentication codes, which describes the authentication status, an error message in case the authentication has failed, and the identity object on success. ## UnauthorizedException -Exception to be thrown when accessing content that need authentication first. This can be used within an application to trigger an error and do a custom action(like redirecting to a login page). There is not a predefined way to handle this, DotKernel packages use this exception paired with a custom error handler to handle unauthorized errors. When using the frontend or admin applications, this is already setup among the authentication/authorization packages, and throwing an UnauthorizedException from anywhere your application, it will redirect to the login page by default. +Exception to be thrown when accessing content that need authentication first. +This can be used within an application to trigger an error and do a custom action(like redirecting to a login page). +There is not a predefined way to handle this, Dotkernel packages use this exception paired with a custom error handler to handle unauthorized errors. +When using the frontend or admin applications, this is already setup among the authentication/authorization packages, and throwing an UnauthorizedException from anywhere your application, it will redirect to the login page by default. diff --git a/composer.json b/composer.json index 7164042..b0b1db3 100644 --- a/composer.json +++ b/composer.json @@ -5,17 +5,17 @@ "license": "MIT", "authors": [ { - "name": "DotKernel Team", + "name": "Dotkernel Team", "email": "team@dotkernel.com" } ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { + "laminas/laminas-coding-standard": "^3.0", "phpunit/phpunit": "^10.2", - "laminas/laminas-coding-standard": "^2.5", "vimeo/psalm": "^5.13" }, "autoload": { @@ -38,7 +38,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/v2/installation.md b/docs/book/v2/installation.md index 46463d0..aa1c492 100644 --- a/docs/book/v2/installation.md +++ b/docs/book/v2/installation.md @@ -2,4 +2,6 @@ Install `dot-authentication` by executing the following Composer command: - composer require dotkernel/dot-authentication +```shell +composer require dotkernel/dot-authentication +``` diff --git a/docs/book/v2/overview.md b/docs/book/v2/overview.md index e0d7f51..152b2e8 100644 --- a/docs/book/v2/overview.md +++ b/docs/book/v2/overview.md @@ -1,3 +1,3 @@ # Overview -`dot-authentication` is DotKernel's authentication base package which define interfaces for authentication services to be used with DotKernel applications. +`dot-authentication` is Dotkernel's authentication base package which define interfaces for authentication services to be used with Dotkernel applications. diff --git a/docs/book/v2/usage.md b/docs/book/v2/usage.md index 44bd6c2..e23a89d 100644 --- a/docs/book/v2/usage.md +++ b/docs/book/v2/usage.md @@ -2,7 +2,8 @@ ## AuthenticationInterface -Defines the interface that should be implemented by any authentication service, in order to work with DotKernel applications. This is a result of the fact that the default packages used by DotKernel applications, that need access to the authentication service are type-hinted against this interface. +Defines the interface that should be implemented by any authentication service, in order to work with Dotkernel applications. +This is a result of the fact that the default packages used by Dotkernel applications, that need access to the authentication service are type-hinted against this interface. Also, concrete implementations should be registered in the service manager using this interface's FQN. @@ -12,13 +13,16 @@ Also, concrete implementations should be registered in the service manager using public function authenticate(ServerRequestInterface $request): AuthenticationResult; ``` -* method to implement the actual authentication process. It should extract credentials from the `$request` object(Authorization header, custom request attributes etc.). It should return an `AuthenticationResult` object, defined in this package, which carry the authentication status and identity on success. +This method is the implementation of the actual authentication process. + +It should extract credentials from the `$request` object (Authorization header, custom request attributes etc.). +It should return an `AuthenticationResult` object, defined in this package, which carry the authentication status and identity on success. ```php public function challenge(ServerRequestInterface $request): ResponseInterface; ``` -* this method should return a valid PSR-7 `ResponseInterface` used to notify the client or browser that it needs to authenticate first(usually using the `WWW-Authenticate` header - usefull for HTTP basic and digest authentication) +This method should return a valid PSR-7 `ResponseInterface` used to notify the client or browser that it needs to authenticate first(usually using the `WWW-Authenticate` header - usefull for HTTP basic and digest authentication) ```php public function hasIdentity(): bool; @@ -27,16 +31,21 @@ public function setIdentity(IdentityInterface $identity); public function clearIdentity(); ``` -* these methods are used to check if authenticated, get the authenticated identity object, force set an identity(maybe useful for auto-login) or clear an identity(logout) +These methods are used to check if authenticated, get the authenticated identity object, force set an identity(maybe useful for auto-login) or clear an identity(logout). ## IdentityInterface -You can use any object to represent an authenticated identity(user) as long as it implements this interface. It requires 2 methods, `getId()` which should return the unique identifier of the identity, and `getName(): string` which should return a string representation of the identity(for display purposes, usually the email or username) +You can use any object to represent an authenticated identity(user) as long as it implements this interface. +It requires 2 methods, `getId()` which should return the unique identifier of the identity, and `getName(): string` which should return a string representation of the identity(for display purposes, usually the email or username) ## AuthenticationResult -Returned by the authentication service, on authentication success or failure. It composes one of the predefined authentication codes, which describes the authentication status, an error message in case the authentication has failed, and the identity object on success. +Returned by the authentication service, on authentication success or failure. +It composes one of the predefined authentication codes, which describes the authentication status, an error message in case the authentication has failed, and the identity object on success. ## UnauthorizedException -Exception to be thrown when accessing content that need authentication first. This can be used within an application to trigger an error and do a custom action(like redirecting to a login page). There is not a predefined way to handle this, DotKernel packages use this exception paired with a custom error handler to handle unauthorized errors. When using the frontend or admin applications, this is already setup among the authentication/authorization packages, and throwing an UnauthorizedException from anywhere your application, it will redirect to the login page by default. +Exception to be thrown when accessing content that need authentication first. +This can be used within an application to trigger an error and do a custom action(like redirecting to a login page). +There is not a predefined way to handle this, Dotkernel packages use this exception paired with a custom error handler to handle unauthorized errors. +When using the frontend or admin applications, this is already setup among the authentication/authorization packages, and throwing an UnauthorizedException from anywhere your application, it will redirect to the login page by default. From 7ab9d648173447e5d6bc4401f67d4b0f1cb01f83 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Thu, 23 Jan 2025 11:24:10 +0200 Subject: [PATCH 2/2] 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..82cd446 --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,6 @@ +{ + "ignore_php_platform_requirements": { + "8.4": true + }, + "backwardCompatibilityCheck": true +}