Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
"[D11] Fix simple_oauth normalizer signatures for Symfony 7": "patches/simple_oauth-symfony7-normalizer-signatures.patch",
"[D11] Replace watchdog_exception() usage": "patches/simple_oauth-drupal11-watchdog-exception.patch",
"[Symfony 7] Fix BasicAuthSwap handle signature": "patches/simple_oauth-symfony7-basicauthswap-handle-signature.patch",
"[PHP 7.4+] Initialize ResourceServer subject property": "patches/simple_oauth-resource-server-subject-init.patch"
"[PHP 7.4+] Initialize ResourceServer subject property": "patches/simple_oauth-resource-server-subject-init.patch",
"[D11.1] Implement EntityInterface::getBundleEntity/getOriginal/setOriginal on TokenAuthUser": "patches/simple_oauth-d11-entity-interface-methods.patch"
},
"drupal/config_terms": {
"Drupal 11 compatibility fixes": "https://www.drupal.org/files/issues/2024-06-02/config_terms.1.x-dev.rector.patch"
Expand Down
14 changes: 12 additions & 2 deletions patches.lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_hash": "ccee31539065b31a7ffddc3061bfcc89bf35f33588afaee9162d7b5be83bc859",
"_hash": "bba7ab1d8144f65b9b08f67a72e2b8fa012c597b789a621626f10cd640000d41",
"patches": {
"drupal/helfi_platform_config": [
{
Expand Down Expand Up @@ -48,7 +48,7 @@
"package": "drupal/simple_oauth",
"description": "[D11] Replace watchdog_exception() usage",
"url": "patches/simple_oauth-drupal11-watchdog-exception.patch",
"sha256": "5ff871af833d7d468b7542db43202b8a0530a84fa8e754e114253964f60c0aa3",
"sha256": "c7898af92e634b042d40c8b2005bfcccf7edfebdcffd4002a8a9c5783b7027b9",
"depth": 1,
"extra": {
"provenance": "root"
Expand All @@ -73,6 +73,16 @@
"extra": {
"provenance": "root"
}
},
{
"package": "drupal/simple_oauth",
"description": "[D11.1] Implement EntityInterface::getBundleEntity/getOriginal/setOriginal on TokenAuthUser",
"url": "patches/simple_oauth-d11-entity-interface-methods.patch",
"sha256": "5044b209e54c399a35d447677f414baf0c896dfc2dab83f4d0ee8039dc89867c",
"depth": 1,
"extra": {
"provenance": "root"
}
}
],
"drupal/config_terms": [
Expand Down
47 changes: 47 additions & 0 deletions patches/simple_oauth-d11-entity-interface-methods.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git a/src/Authentication/TokenAuthUser.php b/src/Authentication/TokenAuthUser.php
--- a/src/Authentication/TokenAuthUser.php
+++ b/src/Authentication/TokenAuthUser.php
@@ -3,6 +3,7 @@
namespace Drupal\simple_oauth\Authentication;

use Drupal\consumers\Entity\ConsumerInterface;
+use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Session\AccountInterface;
@@ -74,6 +75,35 @@ class TokenAuthUser implements TokenAuthUserInterface {
*/
public function getConsumer(): ConsumerInterface {
return $this->consumer;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBundleEntity(): ?EntityInterface {
+ // Only supported when the decorated subject is a content entity.
+ return method_exists($this->subject, 'getBundleEntity')
+ ? $this->subject->getBundleEntity()
+ : NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getOriginal(): ?static {
+ return method_exists($this->subject, 'getOriginal')
+ ? $this->subject->getOriginal()
+ : NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setOriginal(?EntityInterface $original): static {
+ if (method_exists($this->subject, 'setOriginal')) {
+ $this->subject->setOriginal($original);
+ }
+ return $this;
}

/**
38 changes: 37 additions & 1 deletion patches/simple_oauth-drupal11-watchdog-exception.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
diff --git a/src/Controller/Oauth2Token.php b/src/Controller/Oauth2Token.php
index a00f01b..9811498 100644
--- a/src/Controller/Oauth2Token.php
+++ b/src/Controller/Oauth2Token.php
@@ -69,7 +69,7 @@ class Oauth2Token extends ControllerBase {
Expand All @@ -11,3 +10,40 @@ index a00f01b..9811498 100644
$response = $exception->generateHttpResponse(new Response());
}
return $response;
diff --git a/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php b/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
--- a/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
+++ b/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
@@ -4,6 +4,7 @@ namespace Drupal\simple_oauth\Authentication\Provider;

use Drupal\Core\Authentication\AuthenticationProviderInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Logger\LoggerChannelTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\simple_oauth\Authentication\TokenAuthUser;
use Drupal\simple_oauth\PageCache\SimpleOauthRequestPolicyInterface;
@@ -18,6 +19,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class SimpleOauthAuthenticationProvider implements AuthenticationProviderInterface {

use StringTranslationTrait;
+ use LoggerChannelTrait;

/**
* @var \Drupal\simple_oauth\Server\ResourceServerInterface
@@ -79,7 +81,7 @@ class SimpleOauthAuthenticationProvider implements AuthenticationProviderInterfa
}
catch (OAuthServerException $exception) {
// Procedural code here is hard to avoid.
- watchdog_exception('simple_oauth', $exception);
+ $this->getLogger('simple_oauth')->error($exception->getMessage(), ['exception' => $exception]);

throw new HttpException(
$exception->getHttpStatusCode(),
@@ -106,7 +108,7 @@ class SimpleOauthAuthenticationProvider implements AuthenticationProviderInterfa
['%name' => $account->getAccountName()]
)
);
- watchdog_exception('simple_oauth', $exception);
+ $this->getLogger('simple_oauth')->error($exception->getMessage(), ['exception' => $exception]);
throw new HttpException(
$exception->getHttpStatusCode(),
$exception->getHint(),
Loading