diff --git a/composer.json b/composer.json index 8ae36a5..0046573 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ ], "require": { "php": ">=8.3", - "league/oauth2-server": "^8.4", - "hassankhan/config": "^3.1", + "league/oauth2-server": "^9.4", + "hassankhan/config": "^3.2", "defuse/php-encryption": "^2.4", - "psr/http-message": "2.0", - "league/uri": "7.4", + "psr/http-message": "^2.0", + "league/uri": "^7.8", "paragonie/sodium_compat_ext_sodium": "^1.0" }, "config": { diff --git a/composer.lock b/composer.lock index 12efa5d..929a184 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1c2efbf54a0334eb6783f85315a855cf", + "content-hash": "2e6ef2c412009efcb015564e2410d33c", "packages": [ { "name": "defuse/php-encryption", @@ -135,70 +135,6 @@ }, "time": "2024-12-09T16:20:44+00:00" }, - { - "name": "lcobucci/clock", - "version": "3.5.0", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/clock.git", - "reference": "a3139d9e97d47826f27e6a17bb63f13621f86058" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/a3139d9e97d47826f27e6a17bb63f13621f86058", - "reference": "a3139d9e97d47826f27e6a17bb63f13621f86058", - "shasum": "" - }, - "require": { - "php": "~8.3.0 || ~8.4.0 || ~8.5.0", - "psr/clock": "^1.0" - }, - "provide": { - "psr/clock-implementation": "1.0" - }, - "require-dev": { - "infection/infection": "^0.31", - "lcobucci/coding-standard": "^11.2.0", - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan": "^2.0.0", - "phpstan/phpstan-deprecation-rules": "^2.0.0", - "phpstan/phpstan-phpunit": "^2.0.0", - "phpstan/phpstan-strict-rules": "^2.0.0", - "phpunit/phpunit": "^12.0.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\Clock\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com" - } - ], - "description": "Yet another clock abstraction", - "support": { - "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/3.5.0" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2025-10-27T09:03:17+00:00" - }, { "name": "lcobucci/jwt", "version": "5.6.0", @@ -274,29 +210,34 @@ }, { "name": "league/event", - "version": "2.3.0", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/thephpleague/event.git", - "reference": "062ebb450efbe9a09bc2478e89b7c933875b0935" + "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/event/zipball/062ebb450efbe9a09bc2478e89b7c933875b0935", - "reference": "062ebb450efbe9a09bc2478e89b7c933875b0935", + "url": "https://api.github.com/repos/thephpleague/event/zipball/ec38ff7ea10cad7d99a79ac937fbcffb9334c210", + "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210", "shasum": "" }, "require": { - "php": ">=7.1.0" + "php": ">=7.2.0", + "psr/event-dispatcher": "^1.0" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0" }, "require-dev": { - "henrikbjorn/phpspec-code-coverage": "~1.0.1", - "phpspec/phpspec": "^2.2" + "friendsofphp/php-cs-fixer": "^2.16", + "phpstan/phpstan": "^0.12.45", + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -322,44 +263,53 @@ ], "support": { "issues": "https://github.com/thephpleague/event/issues", - "source": "https://github.com/thephpleague/event/tree/2.3.0" + "source": "https://github.com/thephpleague/event/tree/3.0.3" }, - "time": "2025-03-14T19:51:10+00:00" + "time": "2024-09-04T16:06:53+00:00" }, { "name": "league/oauth2-server", - "version": "8.5.5", + "version": "9.4.1", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth2-server.git", - "reference": "cc8778350f905667e796b3c2364a9d3bd7a73518" + "reference": "9d2f6fc0a0b5aa1bb02506971d3a4ecff2c6526c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/cc8778350f905667e796b3c2364a9d3bd7a73518", - "reference": "cc8778350f905667e796b3c2364a9d3bd7a73518", + "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/9d2f6fc0a0b5aa1bb02506971d3a4ecff2c6526c", + "reference": "9d2f6fc0a0b5aa1bb02506971d3a4ecff2c6526c", "shasum": "" }, "require": { - "defuse/php-encryption": "^2.3", + "defuse/php-encryption": "^2.4", + "ext-json": "*", "ext-openssl": "*", - "lcobucci/clock": "^2.2 || ^3.0", - "lcobucci/jwt": "^4.3 || ^5.0", - "league/event": "^2.2", - "league/uri": "^6.7 || ^7.0", - "php": "^8.0", - "psr/http-message": "^1.0.1 || ^2.0" + "lcobucci/jwt": "^5.6", + "league/event": "^3.0", + "league/uri": "^7.8", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "psr/clock": "^1.0", + "psr/http-message": "^2.0", + "psr/http-server-middleware": "^1.0" }, "replace": { "league/oauth2server": "*", "lncd/oauth2": "*" }, "require-dev": { - "laminas/laminas-diactoros": "^3.0.0", - "phpstan/phpstan": "^0.12.57", - "phpstan/phpstan-phpunit": "^0.12.16", - "phpunit/phpunit": "^9.6.6", - "roave/security-advisories": "dev-master" + "laminas/laminas-diactoros": "^3.8", + "paragonie/random_compat": "^9.99.100", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.1.38", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0.12", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^11.5.50", + "roave/security-advisories": "dev-master", + "slevomat/coding-standard": "^8.27.1", + "squizlabs/php_codesniffer": "^4.0" }, "type": "library", "autoload": { @@ -404,7 +354,7 @@ ], "support": { "issues": "https://github.com/thephpleague/oauth2-server/issues", - "source": "https://github.com/thephpleague/oauth2-server/tree/8.5.5" + "source": "https://github.com/thephpleague/oauth2-server/tree/9.4.1" }, "funding": [ { @@ -412,37 +362,42 @@ "type": "github" } ], - "time": "2024-12-20T23:06:10+00:00" + "time": "2026-06-25T15:24:07+00:00" }, { "name": "league/uri", - "version": "7.4.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri.git", - "reference": "bf414ba956d902f5d98bf9385fcf63954f09dce5" + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/bf414ba956d902f5d98bf9385fcf63954f09dce5", - "reference": "bf414ba956d902f5d98bf9385fcf63954f09dce5", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/08cf38e3924d4f56238125547b5720496fac8fd4", + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4", "shasum": "" }, "require": { - "league/uri-interfaces": "^7.3", - "php": "^8.1" + "league/uri-interfaces": "^7.8.1", + "php": "^8.1", + "psr/http-factory": "^1" }, "conflict": { "league/uri-schemes": "^1.0" }, "suggest": { "ext-bcmath": "to improve IPV4 host parsing", + "ext-dom": "to convert the URI into an HTML anchor tag", "ext-fileinfo": "to create Data URI from file contennts", "ext-gmp": "to improve IPV4 host parsing", "ext-intl": "to handle IDN host with the best performance", - "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", - "league/uri-components": "Needed to easily manipulate URI objects components", + "ext-uri": "to use the PHP native URI class", + "jeremykendall/php-domain-parser": "to further parse the URI host and resolve its Public Suffix and Top Level Domain", + "league/uri-components": "to provide additional tools to manipulate URI objects components", + "league/uri-polyfill": "to backport the PHP URI extension for older versions of PHP", "php-64bit": "to improve IPV4 host parsing", + "rowbot/url": "to handle URLs using the WHATWG URL Living Standard specification", "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" }, "type": "library", @@ -470,6 +425,7 @@ "description": "URI manipulation library", "homepage": "https://uri.thephpleague.com", "keywords": [ + "URN", "data-uri", "file-uri", "ftp", @@ -482,9 +438,11 @@ "psr-7", "query-string", "querystring", + "rfc2141", "rfc3986", "rfc3987", "rfc6570", + "rfc8141", "uri", "uri-template", "url", @@ -494,7 +452,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.4.0" + "source": "https://github.com/thephpleague/uri/tree/7.8.1" }, "funding": [ { @@ -502,7 +460,7 @@ "type": "github" } ], - "time": "2023-12-01T06:24:25+00:00" + "time": "2026-03-15T20:22:25+00:00" }, { "name": "league/uri-interfaces", @@ -821,6 +779,111 @@ }, "time": "2022-11-25T14:36:26+00:00" }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, { "name": "psr/http-message", "version": "2.0", @@ -873,6 +936,119 @@ "source": "https://github.com/php-fig/http-message/tree/2.0" }, "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/http-server-handler", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/84c4fb66179be4caaf8e97bd239203245302e7d4", + "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "support": { + "source": "https://github.com/php-fig/http-server-handler/tree/1.0.2" + }, + "time": "2023-04-10T20:06:20+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/c1481f747daaa6a0782775cd6a8c26a1bf4a3829", + "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/http-server-handler": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-middleware/issues", + "source": "https://github.com/php-fig/http-server-middleware/tree/1.0.2" + }, + "time": "2023-04-11T06:14:47+00:00" } ], "packages-dev": [ @@ -933,22 +1109,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.15.3", + "version": "7.15.5", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "ae311b8f045ea93ce7b1c9cdb7cec06c53f944bc" + "reference": "ee80339fd9177ba44c49cdb653ff02a4d1106b9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ae311b8f045ea93ce7b1c9cdb7cec06c53f944bc", - "reference": "ae311b8f045ea93ce7b1c9cdb7cec06c53f944bc", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee80339fd9177ba44c49cdb653ff02a4d1106b9a", + "reference": "ee80339fd9177ba44c49cdb653ff02a4d1106b9a", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^2.5.2", - "guzzlehttp/psr7": "^2.13", + "guzzlehttp/promises": "^2.5.3", + "guzzlehttp/psr7": "^2.13.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.5 || ^3.0", @@ -1041,7 +1217,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.15.3" + "source": "https://github.com/guzzle/guzzle/tree/7.15.5" }, "funding": [ { @@ -1057,20 +1233,20 @@ "type": "tidelift" } ], - "time": "2026-08-05T19:48:21+00:00" + "time": "2026-08-24T09:21:06+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.5.2", + "version": "2.5.3", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "2823687acff28b2dbe67b2508a6b300e2c3fa4ce" + "reference": "cde49999552d185d64715fe9c1f77a2aadd2f9f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/2823687acff28b2dbe67b2508a6b300e2c3fa4ce", - "reference": "2823687acff28b2dbe67b2508a6b300e2c3fa4ce", + "url": "https://api.github.com/repos/guzzle/promises/zipball/cde49999552d185d64715fe9c1f77a2aadd2f9f1", + "reference": "cde49999552d185d64715fe9c1f77a2aadd2f9f1", "shasum": "" }, "require": { @@ -1125,7 +1301,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.5.2" + "source": "https://github.com/guzzle/promises/tree/2.5.3" }, "funding": [ { @@ -1141,20 +1317,20 @@ "type": "tidelift" } ], - "time": "2026-08-05T19:30:54+00:00" + "time": "2026-08-24T09:11:28+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.13.0", + "version": "2.13.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "dad89620b7a6edb60c15858442eb2e408b45d8f4" + "reference": "95e7828100de18b4e269fb1703be530082d5166d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/dad89620b7a6edb60c15858442eb2e408b45d8f4", - "reference": "dad89620b7a6edb60c15858442eb2e408b45d8f4", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/95e7828100de18b4e269fb1703be530082d5166d", + "reference": "95e7828100de18b4e269fb1703be530082d5166d", "shasum": "" }, "require": { @@ -1244,7 +1420,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.13.0" + "source": "https://github.com/guzzle/psr7/tree/2.13.1" }, "funding": [ { @@ -1260,7 +1436,7 @@ "type": "tidelift" } ], - "time": "2026-07-16T22:23:49+00:00" + "time": "2026-08-24T09:13:11+00:00" }, { "name": "league/oauth2-client", @@ -1379,61 +1555,6 @@ }, "time": "2023-09-23T14:17:50+00:00" }, - { - "name": "psr/http-factory", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", - "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory" - }, - "time": "2024-04-15T12:06:14+00:00" - }, { "name": "ralouphie/getallheaders", "version": "3.0.3", diff --git a/lib/GaletteOAuth2/Controllers/AuthorizationController.php b/lib/GaletteOAuth2/Controllers/AuthorizationController.php index 5d0a064..16892e7 100755 --- a/lib/GaletteOAuth2/Controllers/AuthorizationController.php +++ b/lib/GaletteOAuth2/Controllers/AuthorizationController.php @@ -111,7 +111,7 @@ public function authorize(Request $request, Response $response): Response|Respon $user = new UserEntity(); //FIXME: for both isLoggedIn and user_id, we can rely on login object stored in session - $user->setIdentifier($this->session->user_id); + $user->setIdentifier((string)$this->session->user_id); $authRequest->setUser($user); $server_title = $this->config->get('global.title', 'Galette'); @@ -175,7 +175,7 @@ public function doAuthorize(Request $request, Response $response): Response|Resp $authRequest = $server->validateAuthorizationRequest($request); $user = new UserEntity(); //FIXME: for both isLoggedIn and user_id, we can rely on login object stored in session - $user->setIdentifier($this->session->user_id); + $user->setIdentifier((string)$this->session->user_id); $authRequest->setUser($user); // Once the user has approved or denied the client update the status diff --git a/lib/GaletteOAuth2/Repositories/AccessTokenRepository.php b/lib/GaletteOAuth2/Repositories/AccessTokenRepository.php index 5272b71..e5a1f9f 100755 --- a/lib/GaletteOAuth2/Repositories/AccessTokenRepository.php +++ b/lib/GaletteOAuth2/Repositories/AccessTokenRepository.php @@ -28,18 +28,21 @@ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEnt // Some logic here to save the access token to a database } - public function revokeAccessToken($tokenId): void + public function revokeAccessToken(string $tokenId): void { // Some logic here to revoke the access token } - public function isAccessTokenRevoked($tokenId) + public function isAccessTokenRevoked(string $tokenId): bool { return false; // Access token hasn't been revoked } - public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null) - { + public function getNewToken( + ClientEntityInterface $clientEntity, + array $scopes, + ?string $userIdentifier = null + ): AccessTokenEntityInterface { $accessToken = new AccessTokenEntity(); $accessToken->setClient($clientEntity); diff --git a/lib/GaletteOAuth2/Repositories/AuthCodeRepository.php b/lib/GaletteOAuth2/Repositories/AuthCodeRepository.php index eb86241..5883458 100755 --- a/lib/GaletteOAuth2/Repositories/AuthCodeRepository.php +++ b/lib/GaletteOAuth2/Repositories/AuthCodeRepository.php @@ -27,17 +27,17 @@ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity): voi // Some logic to persist the auth code to a database } - public function revokeAuthCode($codeId): void + public function revokeAuthCode(string $codeId): void { // Some logic to revoke the auth code in a database } - public function isAuthCodeRevoked($codeId) + public function isAuthCodeRevoked(string $codeId): bool { return false; // The auth code has not been revoked } - public function getNewAuthCode() + public function getNewAuthCode(): AuthCodeEntityInterface { return new AuthCodeEntity(); } diff --git a/lib/GaletteOAuth2/Repositories/ClientRepository.php b/lib/GaletteOAuth2/Repositories/ClientRepository.php index a243262..edc5c41 100755 --- a/lib/GaletteOAuth2/Repositories/ClientRepository.php +++ b/lib/GaletteOAuth2/Repositories/ClientRepository.php @@ -48,7 +48,7 @@ public function clientExists(?string $client_id): bool return $this->config->get($client_id) !== ''; } - public function getClientEntity($client_id): ClientEntityInterface + public function getClientEntity(string $client_id): ClientEntityInterface { $client = new ClientEntity(); $client->setIdentifier($this->config->get("{$client_id}.id", $client_id)); @@ -73,7 +73,7 @@ public function getClientEntity($client_id): ClientEntityInterface return $client; } - public function validateClient($clientIdentifier, $clientSecret, $grantType) + public function validateClient(string $clientIdentifier, ?string $clientSecret, ?string $grantType): bool { if (!preg_match('/galette_/', $clientIdentifier)) { Debug::log("validateClient({$clientIdentifier}) denied"); diff --git a/lib/GaletteOAuth2/Repositories/RefreshTokenRepository.php b/lib/GaletteOAuth2/Repositories/RefreshTokenRepository.php index 29f5092..2eba08b 100755 --- a/lib/GaletteOAuth2/Repositories/RefreshTokenRepository.php +++ b/lib/GaletteOAuth2/Repositories/RefreshTokenRepository.php @@ -27,12 +27,12 @@ public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshToken // Some logic to persist the refresh token in a database } - public function revokeRefreshToken($tokenId): void + public function revokeRefreshToken(string $tokenId): void { // Some logic to revoke the refresh token in a database } - public function isRefreshTokenRevoked($tokenId) + public function isRefreshTokenRevoked(string $tokenId): bool { return false; // The refresh token has not been revoked } diff --git a/lib/GaletteOAuth2/Repositories/ScopeRepository.php b/lib/GaletteOAuth2/Repositories/ScopeRepository.php index 2f2bf74..2656c1c 100755 --- a/lib/GaletteOAuth2/Repositories/ScopeRepository.php +++ b/lib/GaletteOAuth2/Repositories/ScopeRepository.php @@ -13,6 +13,7 @@ use Analog\Analog; use GaletteOAuth2\Entities\ScopeEntity; use League\OAuth2\Server\Entities\ClientEntityInterface; +use League\OAuth2\Server\Entities\ScopeEntityInterface; use League\OAuth2\Server\Repositories\ScopeRepositoryInterface; use function array_key_exists; @@ -55,7 +56,7 @@ public static function knownScopes(): array ]; } - public function getScopeEntityByIdentifier($scopeIdentifier) + public function getScopeEntityByIdentifier(string $scopeIdentifier): ?ScopeEntityInterface { $scopes = static::knownScopes(); if (array_key_exists($scopeIdentifier, $scopes) === false) { @@ -77,10 +78,11 @@ public function getScopeEntityByIdentifier($scopeIdentifier) */ public function finalizeScopes( array $scopes, - $grantType, + string $grantType, ClientEntityInterface $clientEntity, - $userIdentifier = null - ) { + ?string $userIdentifier = null, + ?string $authCodeId = null + ): array { /*TODO : ? [JC] 2024-06-12: does not seems required; or maybe I misunderstood something. Anyway; that works without it. // Example of programmatically modifying the final scope of the access token diff --git a/lib/GaletteOAuth2/Repositories/UserRepository.php b/lib/GaletteOAuth2/Repositories/UserRepository.php index 579a695..f02e63e 100755 --- a/lib/GaletteOAuth2/Repositories/UserRepository.php +++ b/lib/GaletteOAuth2/Repositories/UserRepository.php @@ -34,15 +34,17 @@ public function __construct(Container $container) } public function getUserEntityByUserCredentials( - $username, - $password, - $grantType, + string $username, + string $password, + string $grantType, ClientEntityInterface $clientEntity ): ?UserEntityInterface { Debug::log("getUserEntityByUserCredentials({$username}, '***', {$grantType}) "); - if (UserHelper::login($this->container, $username, $password)) { - //FIXME? Returned entity may be related to just logged-in user? - return new UserEntity(); + $user_id = UserHelper::login($this->container, $username, $password); + if ($user_id !== false) { + $user = new UserEntity(); + $user->setIdentifier((string)$user_id); + return $user; } return null;