From db00070f047adc952906d032ba11d1d83b504069 Mon Sep 17 00:00:00 2001 From: r3h6 Date: Sat, 19 Oct 2024 11:23:13 +0200 Subject: [PATCH] Refactor site sets --- Classes/Middleware/Initializer.php | 16 ++++++--- Configuration/Sets/Configuration/config.yaml | 2 +- .../Configuration/settings.definitions.yaml | 34 +++++++++---------- .../Sets/IdentitityProvider/config.yaml | 7 ---- Configuration/Sets/Template/config.yaml | 2 ++ .../page.tsconfig | 0 .../settings.definitions.yaml | 0 .../setup.typoscript | 0 Documentation/QuickStart/Configuration.rst | 16 ++++++--- Documentation/QuickStart/Integration.rst | 2 +- Documentation/Upgrade/Index.rst | 25 ++++++++++++-- config/sites/main/config.yaml | 5 ++- 12 files changed, 70 insertions(+), 39 deletions(-) delete mode 100644 Configuration/Sets/IdentitityProvider/config.yaml create mode 100644 Configuration/Sets/Template/config.yaml rename Configuration/Sets/{IdentitityProvider => Template}/page.tsconfig (100%) rename Configuration/Sets/{IdentitityProvider => Template}/settings.definitions.yaml (100%) rename Configuration/Sets/{IdentitityProvider => Template}/setup.typoscript (100%) diff --git a/Classes/Middleware/Initializer.php b/Classes/Middleware/Initializer.php index acff496..55f6016 100644 --- a/Classes/Middleware/Initializer.php +++ b/Classes/Middleware/Initializer.php @@ -51,17 +51,23 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface return $handler->handle($request); } - $siteConfiguration = $site->getConfiguration()['oauth2'] ?? []; - $siteSettings = $site->getSettings()->get('oauth2_server') ?? []; - if ($siteConfiguration === [] && $siteSettings === []) { + $siteConfiguration = $site->getConfiguration()['oauth2'] ?? false; + $siteSettings = $site->getSettings()->get('oauth2_server') ?? false; + if ($siteConfiguration === false && $siteSettings === false) { return $handler->handle($request); } $this->logger->debug('Configure oauth2 server', $this->configuration->toArray()); $this->configuration->merge($this->extensionConfiguration->get('oauth2_server')); - $this->configuration->merge($siteConfiguration); - $this->configuration->merge($siteSettings); + + if ($siteConfiguration !== false) { + $this->configuration->merge($siteConfiguration); + } + + if ($siteSettings !== false) { + $this->configuration->merge($siteSettings); + } if ($this->configuration->isEnabled() === false) { return $handler->handle($request); diff --git a/Configuration/Sets/Configuration/config.yaml b/Configuration/Sets/Configuration/config.yaml index 9ac5dbd..b76cd22 100644 --- a/Configuration/Sets/Configuration/config.yaml +++ b/Configuration/Sets/Configuration/config.yaml @@ -1,2 +1,2 @@ name: oauth2-server/configuration -label: OAuth2 Server Configuration +label: "OAuth2 Server: Configuration" diff --git a/Configuration/Sets/Configuration/settings.definitions.yaml b/Configuration/Sets/Configuration/settings.definitions.yaml index 2ab5298..3b32180 100644 --- a/Configuration/Sets/Configuration/settings.definitions.yaml +++ b/Configuration/Sets/Configuration/settings.definitions.yaml @@ -27,19 +27,19 @@ settings: oauth2_server.routePrefix: label: 'Authorization server route prefix' category: OAuth2Server.configuration - description: '' + description: 'Defaults to "oauth2"' type: string default: '' oauth2_server.accessTokensExpireIn: label: 'Access token TTL' category: OAuth2Server.configuration - description: '' + description: 'Defaults to "PT1H" (1 hour)' type: string default: '' oauth2_server.refreshTokensExpireIn: label: 'Refresh token TTL' category: OAuth2Server.configuration - description: '' + description: 'Defaults to "P1M" (1 month)' type: string default: '' oauth2_server.requireCodeChallengeForPublicClients: @@ -60,17 +60,17 @@ settings: description: '' type: int default: '' - oauth2_server.scopes: - label: 'Scopes' - category: OAuth2Server.configuration - description: '' - type: stringlist - default: '' - readonly: true - oauth2_server.resources: - label: 'Resources' - category: OAuth2Server.configuration - description: '' - type: stringlist - default: '' - readonly: true + # oauth2_server.scopes: + # label: 'Scopes' + # category: OAuth2Server.configuration + # description: 'Configurable only directly in the yaml file' + # type: stringlist + # default: '' + # readonly: true + # oauth2_server.resources: + # label: 'Resources' + # category: OAuth2Server.configuration + # description: 'Configurable only directly in the yaml file' + # type: stringlist + # default: '' + # readonly: true diff --git a/Configuration/Sets/IdentitityProvider/config.yaml b/Configuration/Sets/IdentitityProvider/config.yaml deleted file mode 100644 index df94f93..0000000 --- a/Configuration/Sets/IdentitityProvider/config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: oauth2-server/identity-provider -label: OAuth2 Server Identity Provider - -dependencies: - - typo3/fluid-styled-content - - typo3/felogin - - oauth2-server/configuration diff --git a/Configuration/Sets/Template/config.yaml b/Configuration/Sets/Template/config.yaml new file mode 100644 index 0000000..ab484b5 --- /dev/null +++ b/Configuration/Sets/Template/config.yaml @@ -0,0 +1,2 @@ +name: oauth2-server/template +label: "OAuth2 Server: Template" diff --git a/Configuration/Sets/IdentitityProvider/page.tsconfig b/Configuration/Sets/Template/page.tsconfig similarity index 100% rename from Configuration/Sets/IdentitityProvider/page.tsconfig rename to Configuration/Sets/Template/page.tsconfig diff --git a/Configuration/Sets/IdentitityProvider/settings.definitions.yaml b/Configuration/Sets/Template/settings.definitions.yaml similarity index 100% rename from Configuration/Sets/IdentitityProvider/settings.definitions.yaml rename to Configuration/Sets/Template/settings.definitions.yaml diff --git a/Configuration/Sets/IdentitityProvider/setup.typoscript b/Configuration/Sets/Template/setup.typoscript similarity index 100% rename from Configuration/Sets/IdentitityProvider/setup.typoscript rename to Configuration/Sets/Template/setup.typoscript diff --git a/Documentation/QuickStart/Configuration.rst b/Documentation/QuickStart/Configuration.rst index dcd7b29..8ad34fd 100644 --- a/Documentation/QuickStart/Configuration.rst +++ b/Documentation/QuickStart/Configuration.rst @@ -7,6 +7,18 @@ Quick configuration =================== +TYPO3 v13 +========= + +1. Create your own `public and private keys`__. + Change the permissions of the keys to :code:`600` or :code:`660` + +2. Include site sets and configure settings + + +TYPO3 v12 +========= + 1. Create your own `public and private keys`__. Change the permissions of the keys to :code:`600` or :code:`660` @@ -31,7 +43,3 @@ Quick configuration oauth2_server: resources: - 'EXT:my_extension/Configuration/Yaml/Routes.yaml' - -.. note:: - - In TYPO3 v13 you can do most configuration directly within site set settings. diff --git a/Documentation/QuickStart/Integration.rst b/Documentation/QuickStart/Integration.rst index 01e38bb..2963675 100644 --- a/Documentation/QuickStart/Integration.rst +++ b/Documentation/QuickStart/Integration.rst @@ -46,4 +46,4 @@ Create this page as "Folder" and add your client records. Setup template ============== -Include the TypoScript template provided by this extension or use the site set in TYPO3 v13. +Include the TypoScript template provided by this extension or use the site sets in TYPO3 v13. diff --git a/Documentation/Upgrade/Index.rst b/Documentation/Upgrade/Index.rst index a1731d2..a8f5eb2 100644 --- a/Documentation/Upgrade/Index.rst +++ b/Documentation/Upgrade/Index.rst @@ -6,15 +6,26 @@ Upgrade from 1.x to 2.x ======================= + +Breaking changes +================ + + +Library updates +--------------- + +The library ``league/oauth2-server`` has been updated to version ``9.*``. + + Resource routes -=============== +--------------- The configuration and registration of resource routes has changed. Configuration is now done in YAML files. See section ":ref:`resourceRoutes`". Simplified middleware stack -=========================== +--------------------------- The middleware stack has been simplified. The middleware stack is now: @@ -26,7 +37,15 @@ The middleware stack has been simplified. The middleware stack is now: #. :txt:`r3h6/oauth2-server/dispatcher` #. ... + Removed class ExtbaseGuard -========================== +-------------------------- Check the attributes on the request object instead. + + +Deprecations +============ + +Configuration in site `config.yaml` under the key `oauth2` is condsidered deprecated. +Use site `settings.yaml` instead under the key `oauth2_server`. diff --git a/config/sites/main/config.yaml b/config/sites/main/config.yaml index 331ae81..625ec30 100644 --- a/config/sites/main/config.yaml +++ b/config/sites/main/config.yaml @@ -1,6 +1,9 @@ base: 'https://typo3-oauth2-server.ddev.site/' dependencies: - - oauth2-server/identity-provider + - oauth2-server/template + - oauth2-server/configuration + - typo3/felogin + - typo3/fluid-styled-content languages: - title: English