diff --git a/.env b/.env index 9bb8af6162..cb0a1af3ac 100644 --- a/.env +++ b/.env @@ -41,9 +41,3 @@ MESSENGER_TRANSPORT_DSN_HIGH=doctrine://default?queue_name=high MESSENGER_TRANSPORT_DSN_LOW=doctrine://default?queue_name=low # MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages ###< symfony/messenger ### - -###> trikoder/oauth2-bundle ### -# Fallback OAuth2 encryption key -# Please override this with a secure value: https://oauth2.thephpleague.com/installation/#string-password -OAUTH2_ENCRYPTION_KEY=6cfc355e274dc909f82730c8741eb1e0 -###< trikoder/oauth2-bundle ### diff --git a/composer.lock b/composer.lock index ffc618e96e..191d815402 100644 --- a/composer.lock +++ b/composer.lock @@ -4,74 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c0a2f7b8e803cba4400571f9a087948", + "content-hash": "7ed86573c398de55843ceec839486431", "packages": [ - { - "name": "ajgarlag/psr-http-message-bundle", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/ajgarlag/psr-http-message-bundle.git", - "reference": "7f7e82f8a70b54c0c48a797b1b537421c9049e65" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ajgarlag/psr-http-message-bundle/zipball/7f7e82f8a70b54c0c48a797b1b537421c9049e65", - "reference": "7f7e82f8a70b54c0c48a797b1b537421c9049e65", - "shasum": "" - }, - "require": { - "psr/http-factory": "^1.0", - "symfony/dependency-injection": "^4.4.8|^5.2.4", - "symfony/framework-bundle": "^4.4|^5.0", - "symfony/psr-http-message-bridge": "^1.1|^2.0" - }, - "conflict": { - "sensio/framework-extra-bundle": "<5.3" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.18", - "nyholm/psr7": "^1.1", - "sensio/framework-extra-bundle": "^5.3|^6.0", - "symfony/browser-kit": "^4.4|^5.0", - "symfony/monolog-bridge": "^4.0|^5.0", - "symfony/monolog-bundle": "^3.2", - "symfony/phpunit-bridge": "^4.4.11|^5.0.11", - "symfony/yaml": "^4.4|^5.0" - }, - "suggest": { - "nyholm/psr7": "Provides autowiring aliases for PSR-17" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-main": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Ajgarlag\\Bundle\\PsrHttpMessageBundle\\": "src/" - }, - "exclude-from-classmap": [ - "/tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Antonio J. García Lagar", - "email": "aj@garcialagar.es" - } - ], - "support": { - "issues": "https://github.com/ajgarlag/psr-http-message-bundle/issues", - "source": "https://github.com/ajgarlag/psr-http-message-bundle/tree/1.2.1" - }, - "time": "2021-03-10T18:29:27+00:00" - }, { "name": "alchemy/binary-driver", "version": "v5.2.0", @@ -138,6 +72,50 @@ }, "time": "2020-02-12T19:35:11+00:00" }, + { + "name": "barnabywalters/mf-cleaner", + "version": "v0.1.4", + "source": { + "type": "git", + "url": "https://github.com/barnabywalters/php-mf-cleaner.git", + "reference": "ef6a16628db6e8aee2b4f8bb8093d18c24b74cd4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barnabywalters/php-mf-cleaner/zipball/ef6a16628db6e8aee2b4f8bb8093d18c24b74cd4", + "reference": "ef6a16628db6e8aee2b4f8bb8093d18c24b74cd4", + "shasum": "" + }, + "require-dev": { + "php": ">=5.3", + "phpunit/phpunit": "*" + }, + "suggest": { + "mf2/mf2": "To parse microformats2 structures from (X)HTML" + }, + "type": "library", + "autoload": { + "files": [ + "src/BarnabyWalters/Mf2/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barnaby Walters", + "email": "barnaby@waterpigs.co.uk" + } + ], + "description": "Cleans up microformats2 array structures", + "support": { + "issues": "https://github.com/barnabywalters/php-mf-cleaner/issues", + "source": "https://github.com/barnabywalters/php-mf-cleaner/tree/v0.1.4" + }, + "time": "2014-10-06T23:11:15+00:00" + }, { "name": "composer/ca-bundle", "version": "1.3.1", @@ -288,34 +266,43 @@ "time": "2021-09-13T08:41:34+00:00" }, { - "name": "defuse/php-encryption", - "version": "v2.3.1", + "name": "dflydev/fig-cookies", + "version": "v3.0.0", "source": { "type": "git", - "url": "https://github.com/defuse/php-encryption.git", - "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2" + "url": "https://github.com/dflydev/dflydev-fig-cookies.git", + "reference": "ea6934204b1b34ffdf5130dc7e0928d18ced2498" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/defuse/php-encryption/zipball/77880488b9954b7884c25555c2a0ea9e7053f9d2", - "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2", + "url": "https://api.github.com/repos/dflydev/dflydev-fig-cookies/zipball/ea6934204b1b34ffdf5130dc7e0928d18ced2498", + "reference": "ea6934204b1b34ffdf5130dc7e0928d18ced2498", "shasum": "" }, "require": { - "ext-openssl": "*", - "paragonie/random_compat": ">= 2", - "php": ">=5.6.0" + "ext-pcre": "*", + "php": "^7.2 || ^8.0", + "psr/http-message": "^1" }, "require-dev": { - "phpunit/phpunit": "^4|^5|^6|^7|^8|^9" + "doctrine/coding-standard": "^8", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12.16", + "phpunit/phpunit": "^7.2.6 || ^9", + "scrutinizer/ocular": "^1.8", + "squizlabs/php_codesniffer": "^3.3", + "vimeo/psalm": "^4.4" }, - "bin": [ - "bin/generate-defuse-key" - ], "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0.x-dev" + } + }, "autoload": { "psr-4": { - "Defuse\\Crypto\\": "src" + "Dflydev\\FigCookies\\": "src/Dflydev/FigCookies" } }, "notification-url": "https://packagist.org/downloads/", @@ -324,34 +311,21 @@ ], "authors": [ { - "name": "Taylor Hornby", - "email": "taylor@defuse.ca", - "homepage": "https://defuse.ca/" - }, - { - "name": "Scott Arciszewski", - "email": "info@paragonie.com", - "homepage": "https://paragonie.com" + "name": "Beau Simensen", + "email": "beau@dflydev.com" } ], - "description": "Secure PHP Encryption Library", + "description": "Cookies for PSR-7 HTTP Message Interface.", "keywords": [ - "aes", - "authenticated encryption", - "cipher", - "crypto", - "cryptography", - "encrypt", - "encryption", - "openssl", - "security", - "symmetric key cryptography" + "cookies", + "psr-7", + "psr7" ], "support": { - "issues": "https://github.com/defuse/php-encryption/issues", - "source": "https://github.com/defuse/php-encryption/tree/v2.3.1" + "issues": "https://github.com/dflydev/dflydev-fig-cookies/issues", + "source": "https://github.com/dflydev/dflydev-fig-cookies/tree/v3.0.0" }, - "time": "2021-04-09T23:57:26+00:00" + "time": "2021-01-22T02:53:56+00:00" }, { "name": "doctrine/annotations", @@ -1367,20 +1341,20 @@ }, { "name": "doctrine/migrations", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/migrations.git", - "reference": "b6e43bb5815f4dbb88c79a0fef1c669dfba52d58" + "reference": "e17a946a9d3693cc2f3c285e6667522ded237f71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/migrations/zipball/b6e43bb5815f4dbb88c79a0fef1c669dfba52d58", - "reference": "b6e43bb5815f4dbb88c79a0fef1c669dfba52d58", + "url": "https://api.github.com/repos/doctrine/migrations/zipball/e17a946a9d3693cc2f3c285e6667522ded237f71", + "reference": "e17a946a9d3693cc2f3c285e6667522ded237f71", "shasum": "" }, "require": { - "composer/package-versions-deprecated": "^1.8", + "composer-runtime-api": "^2", "doctrine/dbal": "^2.11 || ^3.0", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.0", @@ -1403,7 +1377,7 @@ "phpstan/phpstan-strict-rules": "^0.12", "phpstan/phpstan-symfony": "^0.12", "phpunit/phpunit": "^8.5 || ^9.4", - "symfony/cache": "^3.4.26 || ~4.1.12 || ^4.2.7 || ^5.0 || ^6.0", + "symfony/cache": "^3.4.26 || ^4.2.12 || ^5.0 || ^6.0", "symfony/process": "^3.4 || ^4.0 || ^5.0 || ^6.0", "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0" }, @@ -1453,7 +1427,7 @@ ], "support": { "issues": "https://github.com/doctrine/migrations/issues", - "source": "https://github.com/doctrine/migrations/tree/3.3.2" + "source": "https://github.com/doctrine/migrations/tree/3.4.0" }, "funding": [ { @@ -1469,7 +1443,7 @@ "type": "tidelift" } ], - "time": "2021-11-12T09:03:27+00:00" + "time": "2022-01-14T08:19:22+00:00" }, { "name": "doctrine/orm", @@ -2369,32 +2343,29 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.1.0", + "version": "1.8.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" + "reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", - "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/1afdd860a2566ed3c2b0b4a3de6e23434a79ec85", + "reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85", "shasum": "" }, "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "ralouphie/getallheaders": "^3.0" + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" }, "provide": { - "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.8 || ^9.3.10" + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -2402,13 +2373,16 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "1.7-dev" } }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" - } + }, + "files": [ + "src/functions_include.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2444,11 +2418,6 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" } ], "description": "PSR-7 message implementation that also provides common utility methods", @@ -2464,7 +2433,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.1.0" + "source": "https://github.com/guzzle/psr7/tree/1.8.3" }, "funding": [ { @@ -2480,7 +2449,158 @@ "type": "tidelift" } ], - "time": "2021-10-06T17:43:30+00:00" + "time": "2021-10-05T13:56:00+00:00" + }, + { + "name": "indieauth/client", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/indieweb/indieauth-client-php.git", + "reference": "2ebd8396913ae8c72438dc24f037c8e1717b66ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/indieweb/indieauth-client-php/zipball/2ebd8396913ae8c72438dc24f037c8e1717b66ed", + "reference": "2ebd8396913ae8c72438dc24f037c8e1717b66ed", + "shasum": "" + }, + "require": { + "indieweb/representative-h-card": "^0.1.2", + "mf2/mf2": ">=0.3.2", + "p3k/http": ">=0.1.6", + "php": ">5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "4.8.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "IndieAuth": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "https://aaronparecki.com" + } + ], + "description": "IndieAuth Client Library", + "support": { + "issues": "https://github.com/indieweb/indieauth-client-php/issues", + "source": "https://github.com/indieweb/indieauth-client-php/tree/1.1.5" + }, + "funding": [ + { + "url": "https://opencollective.com/indieweb", + "type": "opencollective" + } + ], + "time": "2021-01-10T00:19:07+00:00" + }, + { + "name": "indieweb/link-rel-parser", + "version": "0.1.3", + "source": { + "type": "git", + "url": "https://github.com/indieweb/link-rel-parser-php.git", + "reference": "295420e4f16d9a9d262a3c25a7a583794428f055" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/indieweb/link-rel-parser-php/zipball/295420e4f16d9a9d262a3c25a7a583794428f055", + "reference": "295420e4f16d9a9d262a3c25a7a583794428f055", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/IndieWeb/link_rel_parser.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "http://aaronparecki.com" + }, + { + "name": "Tantek Çelik", + "homepage": "http://tantek.com" + } + ], + "description": "Parse rel values from HTTP headers", + "homepage": "https://github.com/indieweb/link-rel-parser-php", + "keywords": [ + "http", + "indieweb", + "microformats2" + ], + "support": { + "issues": "https://github.com/indieweb/link-rel-parser-php/issues", + "source": "https://github.com/indieweb/link-rel-parser-php/tree/master" + }, + "time": "2017-01-11T17:14:49+00:00" + }, + { + "name": "indieweb/representative-h-card", + "version": "0.1.2", + "source": { + "type": "git", + "url": "https://github.com/indieweb/representative-h-card-php.git", + "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/indieweb/representative-h-card-php/zipball/b70b01bd0dd7f2a940602137335dbf46ab6e2e38", + "reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "mf2/mf2": "0.2.*", + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "files": [ + "src/mf2/representative-h-card.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "http://aaronparecki.com" + } + ], + "keywords": [ + "h-card", + "indieweb", + "mf2", + "microformats" + ], + "support": { + "issues": "https://github.com/indieweb/representative-h-card-php/issues", + "source": "https://github.com/indieweb/representative-h-card-php/tree/0.1.2" + }, + "time": "2015-12-23T18:11:19+00:00" }, { "name": "jcupitt/vips", @@ -2731,281 +2851,6 @@ }, "time": "2021-04-11T16:10:46+00:00" }, - { - "name": "lcobucci/clock", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/clock.git", - "reference": "903513d28e85376a33385ebc601afd2ee69e5653" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/903513d28e85376a33385ebc601afd2ee69e5653", - "reference": "903513d28e85376a33385ebc601afd2ee69e5653", - "shasum": "" - }, - "require": { - "php": "^8.0" - }, - "require-dev": { - "infection/infection": "^0.25", - "lcobucci/coding-standard": "^8.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^9.5" - }, - "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/2.1.0" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2021-10-31T21:32:07+00:00" - }, - { - "name": "lcobucci/jwt", - "version": "4.1.5", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/jwt.git", - "reference": "fe2d89f2eaa7087af4aa166c6f480ef04e000582" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/jwt/zipball/fe2d89f2eaa7087af4aa166c6f480ef04e000582", - "reference": "fe2d89f2eaa7087af4aa166c6f480ef04e000582", - "shasum": "" - }, - "require": { - "ext-hash": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-openssl": "*", - "ext-sodium": "*", - "lcobucci/clock": "^2.0", - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "infection/infection": "^0.21", - "lcobucci/coding-standard": "^6.0", - "mikey179/vfsstream": "^1.6.7", - "phpbench/phpbench": "^1.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/php-invoker": "^3.1", - "phpunit/phpunit": "^9.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\JWT\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com", - "role": "Developer" - } - ], - "description": "A simple library to work with JSON Web Token and JSON Web Signature", - "keywords": [ - "JWS", - "jwt" - ], - "support": { - "issues": "https://github.com/lcobucci/jwt/issues", - "source": "https://github.com/lcobucci/jwt/tree/4.1.5" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2021-09-28T19:34:56+00:00" - }, - { - "name": "league/event", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/event.git", - "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/event/zipball/d2cc124cf9a3fab2bb4ff963307f60361ce4d119", - "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "~1.0.1", - "phpspec/phpspec": "^2.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Event\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "description": "Event package", - "keywords": [ - "emitter", - "event", - "listener" - ], - "support": { - "issues": "https://github.com/thephpleague/event/issues", - "source": "https://github.com/thephpleague/event/tree/master" - }, - "time": "2018-11-26T11:52:41+00:00" - }, - { - "name": "league/oauth2-server", - "version": "8.3.3", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/oauth2-server.git", - "reference": "f5698a3893eda9a17bcd48636990281e7ca77b2a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/f5698a3893eda9a17bcd48636990281e7ca77b2a", - "reference": "f5698a3893eda9a17bcd48636990281e7ca77b2a", - "shasum": "" - }, - "require": { - "defuse/php-encryption": "^2.2.1", - "ext-json": "*", - "ext-openssl": "*", - "lcobucci/jwt": "^3.4.6 || ^4.0.4", - "league/event": "^2.2", - "php": "^7.2 || ^8.0", - "psr/http-message": "^1.0.1" - }, - "replace": { - "league/oauth2server": "*", - "lncd/oauth2": "*" - }, - "require-dev": { - "laminas/laminas-diactoros": "^2.4.1", - "phpstan/phpstan": "^0.12.57", - "phpstan/phpstan-phpunit": "^0.12.16", - "phpunit/phpunit": "^8.5.13", - "roave/security-advisories": "dev-master" - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\OAuth2\\Server\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Bilbie", - "email": "hello@alexbilbie.com", - "homepage": "http://www.alexbilbie.com", - "role": "Developer" - }, - { - "name": "Andy Millington", - "email": "andrew@noexceptions.io", - "homepage": "https://www.noexceptions.io", - "role": "Developer" - } - ], - "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.", - "homepage": "https://oauth2.thephpleague.com/", - "keywords": [ - "Authentication", - "api", - "auth", - "authorisation", - "authorization", - "oauth", - "oauth 2", - "oauth 2.0", - "oauth2", - "protect", - "resource", - "secure", - "server" - ], - "support": { - "issues": "https://github.com/thephpleague/oauth2-server/issues", - "source": "https://github.com/thephpleague/oauth2-server/tree/8.3.3" - }, - "funding": [ - { - "url": "https://github.com/sephster", - "type": "github" - } - ], - "time": "2021-10-11T20:41:49+00:00" - }, { "name": "league/uri-parser", "version": "1.4.1", @@ -3923,6 +3768,48 @@ }, "time": "2020-11-19T17:43:46+00:00" }, + { + "name": "p3k/http", + "version": "0.1.12", + "source": { + "type": "git", + "url": "https://github.com/aaronpk/p3k-http.git", + "reference": "cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aaronpk/p3k-http/zipball/cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b", + "reference": "cf9c5b7cdbe1800bfb9587a20953ed8d20322e0b", + "shasum": "" + }, + "require": { + "indieweb/link-rel-parser": "0.1.*", + "mf2/mf2": ">=0.3.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "p3k\\": "src/p3k" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "https://aaronparecki.com" + } + ], + "description": "A simple wrapper API around the PHP curl functions", + "homepage": "https://github.com/aaronpk/p3k-http", + "support": { + "issues": "https://github.com/aaronpk/p3k-http/issues", + "source": "https://github.com/aaronpk/p3k-http/tree/0.1.12" + }, + "time": "2021-10-12T14:12:29+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.4.0", @@ -4808,6 +4695,120 @@ }, "time": "2016-08-06T14:39:51+00:00" }, + { + "name": "psr/http-server-handler", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^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": "http://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": { + "issues": "https://github.com/php-fig/http-server-handler/issues", + "source": "https://github.com/php-fig/http-server-handler/tree/master" + }, + "time": "2018-10-30T16:46:14+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.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": "http://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/master" + }, + "time": "2018-10-30T17:12:04+00:00" + }, { "name": "psr/link", "version": "1.1.1", @@ -5194,67 +5195,6 @@ }, "time": "2021-04-01T19:09:10+00:00" }, - { - "name": "symfony-bundles/json-request-bundle", - "version": "4.1.1", - "source": { - "type": "git", - "url": "https://github.com/symfony-bundles/json-request-bundle.git", - "reference": "dfb6ca1697496a3c4d3914901c64ed946cce2f4b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony-bundles/json-request-bundle/zipball/dfb6ca1697496a3c4d3914901c64ed946cce2f4b", - "reference": "dfb6ca1697496a3c4d3914901c64ed946cce2f4b", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=7.4 || ^8.0", - "symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.4", - "phpunit/php-code-coverage": "^9.2", - "phpunit/phpunit": "^9.5", - "symfony/browser-kit": "^5.2 || ^6.0", - "symfony/yaml": "^5.2 || ^6.0" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "SymfonyBundles\\JsonRequestBundle\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dmitry Khaperets", - "email": "khaperets@gmail.com" - } - ], - "description": "Symfony JsonRequest Bundle", - "homepage": "https://github.com/symfony-bundles/json-request-bundle", - "keywords": [ - "angular", - "bundle", - "json", - "symfony" - ], - "support": { - "issues": "https://github.com/symfony-bundles/json-request-bundle/issues", - "source": "https://github.com/symfony-bundles/json-request-bundle/tree/4.1.1" - }, - "time": "2022-01-16T16:27:40+00:00" - }, { "name": "symfony/amqp-messenger", "version": "v5.4.0", @@ -10960,6 +10900,64 @@ }, "time": "2021-11-30T17:26:37+00:00" }, + { + "name": "taproot/indieauth", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/Taproot/indieauth.git", + "reference": "13ebdf68e98fc1be35740279d9463ea9c996600b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Taproot/indieauth/zipball/13ebdf68e98fc1be35740279d9463ea9c996600b", + "reference": "13ebdf68e98fc1be35740279d9463ea9c996600b", + "shasum": "" + }, + "require": { + "barnabywalters/mf-cleaner": "^0.1.4", + "dflydev/fig-cookies": "^3.0", + "guzzlehttp/psr7": "^1.8", + "indieauth/client": "^1.1", + "mf2/mf2": "^0.4.6", + "nyholm/psr7": "^1.4", + "php": ">= 7.3.0", + "psr/http-message": "^1.0", + "psr/http-server-middleware": "^1.0", + "psr/log": "^1.1", + "webmozart/path-util": "^2.3" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.3", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.7" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Taproot\\IndieAuth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barnaby Walters", + "email": "barnaby@waterpigs.co.uk" + } + ], + "description": "PHP PSR-7-compliant IndieAuth Server and Client implementation.", + "support": { + "issues": "https://github.com/Taproot/indieauth/issues", + "source": "https://github.com/Taproot/indieauth/tree/v0.1.0" + }, + "time": "2021-06-24T11:48:53+00:00" + }, { "name": "tgalopin/html-sanitizer", "version": "1.5.0", @@ -11126,89 +11124,6 @@ ], "time": "2021-12-29T22:21:17+00:00" }, - { - "name": "trikoder/oauth2-bundle", - "version": "v3.x-dev", - "source": { - "type": "git", - "url": "https://github.com/trikoder/oauth2-bundle.git", - "reference": "f970a9c6f4275960d77f24b851563ce99e70ba8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/trikoder/oauth2-bundle/zipball/f970a9c6f4275960d77f24b851563ce99e70ba8d", - "reference": "f970a9c6f4275960d77f24b851563ce99e70ba8d", - "shasum": "" - }, - "require": { - "ajgarlag/psr-http-message-bundle": "^1.1", - "doctrine/doctrine-bundle": "^1.8|^2.0", - "doctrine/orm": "^2.7", - "league/oauth2-server": "^8.0", - "php": ">=7.2", - "psr/http-factory": "^1.0", - "symfony/framework-bundle": "^4.4|^5.0", - "symfony/psr-http-message-bridge": "^2.0", - "symfony/security-bundle": "^4.4|^5.0" - }, - "require-dev": { - "ext-timecop": "*", - "ext-xdebug": "*", - "laminas/laminas-diactoros": "^2.2", - "nyholm/psr7": "^1.2", - "phpunit/phpunit": "^8.5|^9.4", - "symfony/browser-kit": "^4.4|^5.0", - "symfony/phpunit-bridge": "^5.0" - }, - "suggest": { - "defuse/php-encryption": "For better performance when doing encryption", - "nelmio/cors-bundle": "For handling CORS requests", - "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" - }, - "default-branch": true, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Trikoder\\Bundle\\OAuth2Bundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Antonio Pauletich", - "email": "antonio.pauletich@trikoder.net" - }, - { - "name": "Berislav Balogović", - "email": "berislav.balogovic@trikoder.net" - }, - { - "name": "Petar Obradović", - "email": "petar.obradovic@trikoder.net" - } - ], - "description": "Symfony bundle which provides OAuth 2.0 authorization/resource server capabilities.", - "homepage": "https://www.trikoder.net/", - "keywords": [ - "oauth2" - ], - "support": { - "issues": "https://github.com/trikoder/oauth2-bundle/issues", - "source": "https://github.com/trikoder/oauth2-bundle/tree/v3.x" - }, - "time": "2021-03-09T14:59:54+00:00" - }, { "name": "twig/extra-bundle", "version": "v3.3.7", @@ -11717,6 +11632,57 @@ }, "time": "2021-03-09T10:59:23+00:00" }, + { + "name": "webmozart/path-util", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/path-util.git", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "webmozart/assert": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\PathUtil\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "support": { + "issues": "https://github.com/webmozart/path-util/issues", + "source": "https://github.com/webmozart/path-util/tree/2.3.0" + }, + "abandoned": "symfony/filesystem", + "time": "2015-12-17T08:42:14+00:00" + }, { "name": "wikimedia/composer-merge-plugin", "version": "v2.0.1", @@ -15121,8 +15087,7 @@ "minimum-stability": "stable", "stability-flags": { "someonewithpc/redis-polyfill": 20, - "phpstan/phpstan": 20, - "trikoder/oauth2-bundle": 20 + "phpstan/phpstan": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/config/bundles.php b/config/bundles.php index 500b915ef6..e2d6d24551 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -21,7 +21,4 @@ return [ SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true], Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], Fidry\PsyshBundle\PsyshBundle::class => ['all' => true], - Trikoder\Bundle\OAuth2Bundle\TrikoderOAuth2Bundle::class => ['all' => true], - Ajgarlag\Bundle\PsrHttpMessageBundle\AjgarlagPsrHttpMessageBundle::class => ['all' => true], - SymfonyBundles\JsonRequestBundle\JsonRequestBundle::class => ['all' => true], ]; diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 547226b8c4..10fe777b8e 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -31,9 +31,7 @@ security: pattern: ^/api/ security: true stateless: true - guard: - authenticators: - - Trikoder\Bundle\OAuth2Bundle\Security\Guard\Authenticator\OAuth2Authenticator + main: entry_point: App\Security\Authenticator guard: diff --git a/config/packages/trikoder_oauth2.yaml b/config/packages/trikoder_oauth2.yaml deleted file mode 100644 index 84e933065d..0000000000 --- a/config/packages/trikoder_oauth2.yaml +++ /dev/null @@ -1,32 +0,0 @@ -trikoder_oauth2: - - authorization_server: - private_key: '%kernel.project_dir%/var/oauth/private.key' - private_key_passphrase: null # Passphrase of the private key, if any - - encryption_key: '%env(string:OAUTH2_ENCRYPTION_KEY)%' # (Optional) Change this - - grant_types: - authorization_code: - enable: true - client_credentials: - enable: true - implicit: - enable: true - password: - enable: true - refresh_token: - enable: true - - resource_server: - public_key: '%kernel.project_dir%/var/oauth/public.key' - - persistence: - doctrine: null - - # Scopes that you wish to utilize in your application. - # This should be a simple array of strings. - scopes: - - read - - write - - follow \ No newline at end of file diff --git a/config/routes/trikoder_oauth2.yaml b/config/routes/trikoder_oauth2.yaml deleted file mode 100644 index 76f98e294a..0000000000 --- a/config/routes/trikoder_oauth2.yaml +++ /dev/null @@ -1,7 +0,0 @@ -oauth2_authorization_code: - controller: Trikoder\Bundle\OAuth2Bundle\Controller\AuthorizationController::indexAction - path: '/oauth/authorize' - -oauth2_token: - controller: Trikoder\Bundle\OAuth2Bundle\Controller\TokenController::indexAction - path: '/oauth/token' diff --git a/plugins/IndieAuth/Controller/Apps.php b/plugins/IndieAuth/Controller/Apps.php new file mode 100644 index 0000000000..981dec4aac --- /dev/null +++ b/plugins/IndieAuth/Controller/Apps.php @@ -0,0 +1,85 @@ +. +// }}} + +/** + * ActivityPub implementation for GNU social + * + * @package OAuth2 + * @category API + * + * @author Diogo Peralta Cordeiro <@diogo.site> + * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +namespace Plugin\IndieAuth\Controller; + +use App\Core\Controller; +use App\Core\DB\DB; +use App\Core\Log; +use App\Util\Common; +use Plugin\IndieAuth\Entity\OAuth2Client; +use Symfony\Component\HttpFoundation\JsonResponse; + +/** + * App Management Endpoint + * + * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ +class Apps extends Controller +{ + public function onPost(): JsonResponse + { + Log::debug('OAuth2 Apps: Received a POST request.'); + Log::debug('OAuth2 Apps: Request content: ', [$body = $this->request->getContent()]); + $args = json_decode($body, true); + + $identifier = hash('md5', random_bytes(16)); + // Random string Length should be between 43 and 128 + $secret = Common::base64url_encode(hash('sha256', random_bytes(57))); + + DB::persist($app = OAuth2Client::create([ + 'identifier' => $identifier, + 'secret' => $secret, + 'redirect_uris' => $args['redirect_uris'], + 'grants' => 'client_credentials authorization_code', + 'scopes' => $args['scopes'], + 'active' => true, + 'allow_plain_text_pkce' => false, + 'client_name' => $args['client_name'], + 'website' => $args['website'], + ])); + + Log::debug('OAuth2 Apps: Created App: ', [$app]); + + DB::flush(); + + // Success + return new JsonResponse([ + 'name' => $app->getClientName(), + 'website' => $app->getWebsite(), + 'redirect_uri' => $app->getRedirectUris()[0], + 'client_id' => $app->getIdentifier(), + 'client_secret' => $app->getSecret(), + ], status: 200, headers: ['content_type' => 'application/json; charset=utf-8']); + } +} diff --git a/plugins/IndieAuth/Controller/OAuth2.php b/plugins/IndieAuth/Controller/OAuth2.php new file mode 100644 index 0000000000..5af78cb2a5 --- /dev/null +++ b/plugins/IndieAuth/Controller/OAuth2.php @@ -0,0 +1,70 @@ +. +// }}} + +/** + * ActivityPub implementation for GNU social + * + * @package OAuth2 + * @category API + * + * @author Diogo Peralta Cordeiro <@diogo.site> + * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +namespace Plugin\IndieAuth\Controller; + +use App\Core\Controller; +use Nyholm\Psr7\Factory\Psr17Factory; +use Plugin\IndieAuth\IndieAuth; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; +use Symfony\Component\HttpFoundation\RequestStack; + +/** + * App Management Endpoint + * + * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ +class OAuth2 extends Controller +{ + private ServerRequestInterface $psrRequest; + + public function __construct(RequestStack $requestStack) + { + parent::__construct($requestStack); + $psr17Factory = new Psr17Factory(); + $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory); + $this->psrRequest = $psrHttpFactory->createRequest($this->request); + } + + public function handleAuthorizationEndpointRequest(): ResponseInterface + { + return IndieAuth::$server->handleAuthorizationEndpointRequest($this->psrRequest); + } + + public function handleTokenEndpointRequest(): ResponseInterface + { + return IndieAuth::$server->handleTokenEndpointRequest($this->psrRequest); + } +} diff --git a/plugins/IndieAuth/Entity/OAuth2Client.php b/plugins/IndieAuth/Entity/OAuth2Client.php new file mode 100644 index 0000000000..47616b6342 --- /dev/null +++ b/plugins/IndieAuth/Entity/OAuth2Client.php @@ -0,0 +1,225 @@ +. +// }}} + +/** + * ActivityPub implementation for GNU social + * + * @package GNUsocial + * @category OAuth2 + * + * @author Diogo Peralta Cordeiro <@diogo.site> + * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +namespace Plugin\IndieAuth\Entity; + +use App\Core\Entity; +use DateTimeInterface; + +/** + * OAuth application registration record + * + * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ +class OAuth2Client extends Entity +{ + // {{{ Autocode + // @codeCoverageIgnoreStart + private string $identifier; + private ?string $secret; + private string $redirect_uris = ''; + private string $grants = ''; + private string $scopes = ''; + private bool $active = true; + private bool $allow_plain_text_pkce = false; + private ?string $client_name = null; + private ?string $website = null; + private DateTimeInterface $created; + private DateTimeInterface $modified; + + public function __toString(): string + { + return $this->getIdentifier(); + } + + public function getIdentifier(): string + { + return $this->identifier; + } + + public function getSecret(): ?string + { + return $this->secret; + } + + public function setSecret(?string $secret): self + { + $this->secret = $secret; + + return $this; + } + + public function getRedirectUris(): array + { + return explode(' ', $this->redirect_uris); + } + + public function setRedirectUris(string ...$redirect_uris): self + { + $this->redirect_uris = implode(' ', $redirect_uris); + + return $this; + } + + public function getGrants(): array + { + return explode(' ', $this->grants); + } + + public function setGrants(string ...$grants): self + { + $this->grants = implode(' ', $grants); + + return $this; + } + + public function getScopes(): array + { + return explode(' ', $this->scopes); + } + + public function setScopes(string ...$scopes): self + { + $this->scopes = implode(' ', $scopes); + + return $this; + } + + public function isActive(): bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + + public function isConfidential(): bool + { + return !empty($this->secret); + } + + public function isPlainTextPkceAllowed(): bool + { + return $this->allow_plain_text_pkce; + } + + public function setAllowPlainTextPkce(bool $allow_plain_text_pkce): self + { + $this->allow_plain_text_pkce = $allow_plain_text_pkce; + + return $this; + } + + public function setIdentifier(string $identifier): self + { + $this->identifier = $identifier; + return $this; + } + + public function getClientName(): string + { + return $this->client_name; + } + + public function setClientName(string $client_name): self + { + $this->client_name = $client_name; + return $this; + } + + public function getWebsite(): ?string + { + return $this->website; + } + + public function setWebsite(?string $website): self + { + $this->website = $website; + return $this; + } + + public function setCreated(DateTimeInterface $created): self + { + $this->created = $created; + return $this; + } + + public function getCreated(): DateTimeInterface + { + return $this->created; + } + + public function setModified(DateTimeInterface $modified): self + { + $this->modified = $modified; + return $this; + } + + public function getModified(): DateTimeInterface + { + return $this->modified; + } + + // @codeCoverageIgnoreEnd + // }}} Autocode + + /** + * Return table definition for Schema setup and Entity usage. + * + * @return array array of column definitions + */ + public static function schemaDef(): array + { + return [ + 'name' => 'oauth2_client', + 'fields' => [ + 'identifier' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'foreign key to oauth2_client->identifier'], + 'secret' => ['type' => 'varchar', 'length' => 128, 'not null' => false, 'description' => 'foreign key to oauth2_client->identifier'], + 'client_name' => ['type' => 'varchar', 'length' => 191, 'not null' => false, 'description' => 'name of the application'], + 'redirect_uris' => ['type' => 'text', 'not null' => false, 'description' => 'application homepage - used for source link'], + 'grants' => ['type' => 'text', 'not null' => true, 'default' => '', 'description' => 'application homepage - used for source link'], + 'scopes' => ['type' => 'text', 'not null' => true, 'default' => '', 'description' => 'application homepage - used for source link'], + 'active' => ['type' => 'bool', 'not null' => true, 'description' => 'was this note generated by a local actor'], + 'allow_plain_text_pkce' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'was this note generated by a local actor'], + 'website' => ['type' => 'text', 'not null' => false, 'description' => 'application homepage - used for source link'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + ], + 'primary key' => ['identifier'], + ]; + } +} diff --git a/plugins/OAuth2/OAuth2.php b/plugins/IndieAuth/IndieAuth.php similarity index 57% rename from plugins/OAuth2/OAuth2.php rename to plugins/IndieAuth/IndieAuth.php index 0f764eaad3..7951b6890a 100644 --- a/plugins/OAuth2/OAuth2.php +++ b/plugins/IndieAuth/IndieAuth.php @@ -30,21 +30,19 @@ declare(strict_types = 1); * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -namespace Plugin\OAuth2; +namespace Plugin\IndieAuth; use App\Core\Event; +use App\Core\Log; use App\Core\Modules\Plugin; use App\Core\Router\RouteLoader; use App\Core\Router\Router; use App\Util\Common; -use App\Util\Exception\NoLoggedInUser; use Nyholm\Psr7\Response; -use Plugin\OAuth2\Controller\Apps; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEvent; -use Trikoder\Bundle\OAuth2Bundle\Event\UserResolveEvent; -use Trikoder\Bundle\OAuth2Bundle\Model\Grant; -use Trikoder\Bundle\OAuth2Bundle\OAuth2Events; +use Plugin\IndieAuth\Controller\Apps; +use Plugin\IndieAuth\Controller\OAuth2; +use Psr\Http\Message\ServerRequestInterface; +use Taproot\IndieAuth\Server; use XML_XRD_Element_Link; /** @@ -53,12 +51,39 @@ use XML_XRD_Element_Link; * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class OAuth2 extends Plugin implements EventSubscriberInterface +class IndieAuth extends Plugin { public const OAUTH_ACCESS_TOKEN_REL = 'http://apinamespace.org/oauth/access_token'; public const OAUTH_REQUEST_TOKEN_REL = 'http://apinamespace.org/oauth/request_token'; public const OAUTH_AUTHORIZE_REL = 'http://apinamespace.org/oauth/authorize'; + public static Server $server; + + public function onInitializePlugin() + { + self::$server = new Server([ + 'secret' => 'YOUR_APP_INDIEAUTH_SECRET$config["secret"] must be a string with a minimum length of 64 characters.yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + 'logger' => Log::getLogger(), + 'requirePKCE' => false, + // A path to store token data, or an object implementing TokenStorageInterface. + 'tokenStorage' => '/../data/auth_tokens/', + + // An authentication callback function, which either returns data about the current user, + // or redirects to/implements an authentication flow. + 'authenticationHandler' => function (ServerRequestInterface $request, string $authenticationRedirect, ?string $normalizedMeUrl) { + // If the request is authenticated, return an array with a `me` key containing the + // canonical URL of the currently logged-in user. + if ($actor = Common::actor()) { + return ['me' => $actor->getUri(Router::ABSOLUTE_URL)]; + } + + // Otherwise, redirect the user to a login page, ensuring that they will be redirected + // back to the IndieAuth flow with query parameters intact once logged in. + return new Response(302, ['Location' => Router::url('security_login') . '?returnUrl=' . urlencode($authenticationRedirect)]); + }, + ]); + } + public function version(): string { return '3.0.0'; @@ -78,6 +103,19 @@ class OAuth2 extends Plugin implements EventSubscriberInterface Apps::class, ['http-methods' => ['POST']], ); + + $r->connect( + 'oauth2_authorization_code', + '/oauth/authorize', + [OAuth2::class, 'handleAuthorizationEndpointRequest'], + ); + + $r->connect( + 'oauth2_token', + '/oauth/token', + [OAuth2::class, 'handleTokenEndpointRequest'], + ); + return Event::next; } @@ -88,40 +126,4 @@ class OAuth2 extends Plugin implements EventSubscriberInterface $links[] = new XML_XRD_Element_link(self::OAUTH_ACCESS_TOKEN_REL, Router::url('oauth2_token', type: Router::ABSOLUTE_URL)); return Event::next; } - - public function userResolve(UserResolveEvent $event): void - { - $user = Common::user(); - - if (\is_null($user)) { - return; - } - - $event->setUser($user); - } - - public function authorizeRequestResolve(AuthorizationRequestResolveEvent $event): void - { - $request = Common::getRequest(); - try { - $user = Common::ensureLoggedIn(); - $event->setUser($user); - $event->resolveAuthorization(AuthorizationRequestResolveEvent::AUTHORIZATION_APPROVED); - $event->getClient()->setGrants(new Grant('client_credentials'), new Grant('authorization_code')); - } catch (NoLoggedInUser) { - $event->setResponse(new Response(302, [ - 'Location' => Router::url('security_login', [ - 'returnUrl' => $request->getUri(), - ]), - ])); - } - } - - public static function getSubscribedEvents(): array - { - return [ - OAuth2Events::USER_RESOLVE => 'userResolve', - OAuth2Events::AUTHORIZATION_REQUEST_RESOLVE => 'authorizeRequestResolve', - ]; - } } diff --git a/plugins/IndieAuth/composer.json b/plugins/IndieAuth/composer.json new file mode 100644 index 0000000000..ca75678e60 --- /dev/null +++ b/plugins/IndieAuth/composer.json @@ -0,0 +1,7 @@ +{ + "require": { + "nyholm/psr7": "^1.4", + "symfony/psr-http-message-bridge": "^2.1", + "taproot/indieauth": "^0.1.0" + } +} diff --git a/plugins/OAuth2/Controller/Apps.php b/plugins/OAuth2/Controller/Apps.php deleted file mode 100644 index 9c466bd6e2..0000000000 --- a/plugins/OAuth2/Controller/Apps.php +++ /dev/null @@ -1,106 +0,0 @@ -. -// }}} - -/** - * ActivityPub implementation for GNU social - * - * @package OAuth2 - * @category API - * - * @author Diogo Peralta Cordeiro <@diogo.site> - * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ - -namespace Plugin\OAuth2\Controller; - -use App\Core\Controller; -use App\Core\DB\DB; -use App\Core\Log; -use App\Util\Common; -use Plugin\OAuth2\Entity\OAuth2ClientMeta; -use Symfony\Component\HttpFoundation\JsonResponse; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; -use Trikoder\Bundle\OAuth2Bundle\Model\Grant; -use Trikoder\Bundle\OAuth2Bundle\Model\RedirectUri; -use Trikoder\Bundle\OAuth2Bundle\Model\Scope; - -/** - * App Management Endpoint - * - * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ -class Apps extends Controller -{ - public function onPost(): JsonResponse - { - Log::debug('OAuth2 Apps: Received a POST request.'); - Log::debug('OAuth2 Apps: Request content: ', [$body = $this->request->getContent()]); - $args = json_decode($body, true); - - $identifier = hash('md5', random_bytes(16)); // Random string Length should be between 43 and 128 - $secret = Common::base64url_encode(hash('sha256', random_bytes(57))); - - $client = new Client($identifier, $secret); - $client->setActive(true); - $client->setAllowPlainTextPkce(false); - - $redirectUris = array_map( - static fn (string $redirectUri): RedirectUri => new RedirectUri($redirectUri), - explode(' ', $args['redirect_uris']), - ); - $client->setRedirectUris(...$redirectUris); - - $client->setGrants(new Grant('client_credentials')); - - $scopes = array_map( - static fn (string $scope): Scope => new Scope($scope), - explode(' ', $args['scopes']), - ); - $client->setScopes(...$scopes); - - DB::persist($client); - - DB::persist($additional_meta = OAuth2ClientMeta::create([ - 'identifier' => $client->getIdentifier(), - 'client_name' => $args['client_name'], - 'website' => $args['website'], - ])); - - Log::debug('OAuth2 Apps: Created App: ', [$client, $additional_meta]); - $app_meta = [ - 'id' => (string) $additional_meta->getId(), - 'name' => $additional_meta->getClientName(), - 'website' => $additional_meta->getWebsite(), - 'redirect_uri' => (string) $client->getRedirectUris()[0], - 'client_id' => $client->getIdentifier(), - 'client_secret' => $client->getSecret(), - ]; - - Log::debug('OAuth2 Apps: Create App Meta: ', [$app_meta]); - - DB::flush(); - - // Success - return new JsonResponse($app_meta, status: 200, headers: ['content_type' => 'application/json; charset=utf-8']); - } -} diff --git a/plugins/OAuth2/Entity/OAuth2ClientMeta.php b/plugins/OAuth2/Entity/OAuth2ClientMeta.php deleted file mode 100644 index d3f58bfbfa..0000000000 --- a/plugins/OAuth2/Entity/OAuth2ClientMeta.php +++ /dev/null @@ -1,144 +0,0 @@ -. -// }}} - -/** - * ActivityPub implementation for GNU social - * - * @package GNUsocial - * @category OAuth2 - * - * @author Diogo Peralta Cordeiro <@diogo.site> - * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ - -namespace Plugin\OAuth2\Entity; - -use App\Core\Entity; -use DateTimeInterface; - -/** - * OAuth application registration record - * - * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ -class OAuth2ClientMeta extends Entity -{ - // {{{ Autocode - // @codeCoverageIgnoreStart - private int $id; - private string $identifier; - private string $client_name; - private ?string $website = null; - private DateTimeInterface $created; - private DateTimeInterface $modified; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - return $this; - } - - public function getIdentifier(): string - { - return $this->identifier; - } - - public function setIdentifier(string $identifier): self - { - $this->identifier = $identifier; - return $this; - } - - public function getClientName(): string - { - return $this->client_name; - } - - public function setClientName(string $client_name): self - { - $this->client_name = $client_name; - return $this; - } - - public function getWebsite(): ?string - { - return $this->website; - } - - public function setWebsite(?string $website): self - { - $this->website = $website; - return $this; - } - - public function setCreated(DateTimeInterface $created): self - { - $this->created = $created; - return $this; - } - - public function getCreated(): DateTimeInterface - { - return $this->created; - } - - public function setModified(DateTimeInterface $modified): self - { - $this->modified = $modified; - return $this; - } - - public function getModified(): DateTimeInterface - { - return $this->modified; - } - - // @codeCoverageIgnoreEnd - // }}} Autocode - - /** - * Return table definition for Schema setup and Entity usage. - * - * @return array array of column definitions - */ - public static function schemaDef(): array - { - return [ - 'name' => 'oauth2_client_meta', - 'fields' => [ - 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], - 'identifier' => ['type' => 'varchar', 'length' => 32, 'description' => 'foreign key to oauth2_client->identifier'], - 'client_name' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the application'], - 'website' => ['type' => 'text', 'not null' => false, 'description' => 'application homepage - used for source link'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], - ], - 'primary key' => ['id'], - ]; - } -} diff --git a/plugins/OAuth2/composer.json b/plugins/OAuth2/composer.json deleted file mode 100644 index b44a0dd6b9..0000000000 --- a/plugins/OAuth2/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "require": { - "nyholm/psr7": "*", - "symfony-bundles/json-request-bundle": "^4.1", - "trikoder/oauth2-bundle": "v3.x-dev" - } -} diff --git a/src/Core/Log.php b/src/Core/Log.php index ea146702ba..a5e891ba0d 100644 --- a/src/Core/Log.php +++ b/src/Core/Log.php @@ -58,6 +58,11 @@ abstract class Log self::$logger = $l; } + public static function getLogger(): LoggerInterface + { + return self::$logger; + } + /** * Log a critical error when a really unexpected exception occured. This indicates a bug in the software * diff --git a/symfony.lock b/symfony.lock index 6c88c865f7..6c7c456eca 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,10 +1,10 @@ { - "ajgarlag/psr-http-message-bundle": { - "version": "1.2.1" - }, "alchemy/binary-driver": { "version": "v5.2.0" }, + "barnabywalters/mf-cleaner": { + "version": "v0.1.4" + }, "behat/gherkin": { "version": "v4.9.0" }, @@ -68,8 +68,8 @@ "composer/xdebug-handler": { "version": "1.4.6" }, - "defuse/php-encryption": { - "version": "v2.3.1" + "dflydev/fig-cookies": { + "version": "v3.0.0" }, "doctrine/annotations": { "version": "1.0", @@ -208,6 +208,15 @@ "guzzlehttp/psr7": { "version": "2.1.0" }, + "indieauth/client": { + "version": "1.1.5" + }, + "indieweb/link-rel-parser": { + "version": "0.1.3" + }, + "indieweb/representative-h-card": { + "version": "0.1.2" + }, "jchook/phpunit-assert-throws": { "version": "v1.0.3" }, @@ -229,18 +238,6 @@ "landrok/activitypub": { "version": "0.5.6" }, - "lcobucci/clock": { - "version": "2.1.0" - }, - "lcobucci/jwt": { - "version": "4.1.5" - }, - "league/event": { - "version": "2.2.0" - }, - "league/oauth2-server": { - "version": "8.3.3" - }, "league/uri-parser": { "version": "1.4.1" }, @@ -301,6 +298,9 @@ "oscarotero/html-parser": { "version": "v0.1.6" }, + "p3k/http": { + "version": "0.1.12" + }, "paragonie/constant_time_encoding": { "version": "v2.4.0" }, @@ -390,6 +390,12 @@ "psr/http-message": { "version": "1.0.1" }, + "psr/http-server-handler": { + "version": "1.0.1" + }, + "psr/http-server-middleware": { + "version": "1.0.1" + }, "psr/link": { "version": "1.1.1" }, @@ -468,9 +474,6 @@ "someonewithpc/redis-polyfill": { "version": "dev-master" }, - "symfony-bundles/json-request-bundle": { - "version": "4.1.1" - }, "symfony/amqp-messenger": { "version": "v5.4.0" }, @@ -868,6 +871,9 @@ "symfonycasts/verify-email-bundle": { "version": "v1.3.0" }, + "taproot/indieauth": { + "version": "v0.1.0" + }, "tgalopin/html-sanitizer": { "version": "1.4.0" }, @@ -886,19 +892,6 @@ "theseer/tokenizer": { "version": "1.2.0" }, - "trikoder/oauth2-bundle": { - "version": "3.2", - "recipe": { - "repo": "github.com/symfony/recipes-contrib", - "branch": "master", - "version": "3.0", - "ref": "43774de114904e86d18de0cea92f368d8e3c7499" - }, - "files": [ - "config/packages/trikoder_oauth2.yaml", - "config/routes/trikoder_oauth2.yaml" - ] - }, "twig/extra-bundle": { "version": "v3.3.0" }, @@ -923,6 +916,9 @@ "webmozart/assert": { "version": "1.10.0" }, + "webmozart/path-util": { + "version": "2.3.0" + }, "wikimedia/composer-merge-plugin": { "version": "v2.0.1" },