Skip to content

Commit

Permalink
Update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Bäse committed Dec 24, 2024
1 parent 58cbbf4 commit 7564f1f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
4 changes: 2 additions & 2 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"Issue #3434213: Drupal 11 Compatibility": "patches/responsive_favicons/drupal-11-compatibility.patch"
},
"drupal/simple_oauth": {
"Issue #3082984: Reduce logging severity/don't log expired tokens/401s": "patches/simple_oauth/3082984-d2c39a92.patch",
"Issue #2946882: Auth revoke on profile update": "patches/simple_oauth/2946882-c33fa214.patch"
"Issue #2946882: Auth revoke on profile update": "patches/simple_oauth/2946882-c33fa214.patch",
"Issue #3082984: Reduce logging severity/don't log expired tokens/401s": "patches/simple_oauth/3082984-2a5cb2a8.patch"
},
"drupal/warmer": {
"Custom: Add items list to queue command": "patches/warmer/custom-add-items-limit-to-queue-command.patch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ index 2fbc8a929bab56f4c507be3c2dee6a829fc28c51..7eb33261421be870fae5f8eaf786ca99
simple_oauth.normalizer.oauth2_token:
class: Drupal\simple_oauth\Normalizer\TokenEntityNormalizer
diff --git a/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php b/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
index 47d0e73f07282de8c178b3dbace964d56f44a50e..e702c3abb8b15b36f3811d14eb5e3448e3cfa034 100644
index 47d0e73f07282de8c178b3dbace964d56f44a50e..fb03015acb32c706a935c61c7d442516bda3ee87 100644
--- a/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
+++ b/src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
@@ -5,16 +5,14 @@ namespace Drupal\simple_oauth\Authentication\Provider;
Expand Down Expand Up @@ -112,11 +112,10 @@ index 47d0e73f07282de8c178b3dbace964d56f44a50e..e702c3abb8b15b36f3811d14eb5e3448
$exception
);
}
@@ -174,4 +159,25 @@ class SimpleOauthAuthenticationProvider implements AuthenticationProviderInterfa
@@ -174,4 +159,24 @@ class SimpleOauthAuthenticationProvider implements AuthenticationProviderInterfa
return $account;
}

+
+ /**
+ * Formats challenge for unauthorized exception.
+ *
Expand All @@ -139,10 +138,18 @@ index 47d0e73f07282de8c178b3dbace964d56f44a50e..e702c3abb8b15b36f3811d14eb5e3448
+
}
diff --git a/src/Controller/Oauth2AuthorizeController.php b/src/Controller/Oauth2AuthorizeController.php
index a69e0ea0df53489f27cce24532385259339d3227..6c39bb265276a322e7c81f385a0f4134eb9b2db4 100644
index a69e0ea0df53489f27cce24532385259339d3227..7a22230487ebb0a3c4c790560b70cbc8c53d8e13 100644
--- a/src/Controller/Oauth2AuthorizeController.php
+++ b/src/Controller/Oauth2AuthorizeController.php
@@ -166,7 +166,7 @@ class Oauth2AuthorizeController extends ControllerBase {
@@ -5,7 +5,6 @@ namespace Drupal\simple_oauth\Controller;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
-use Drupal\Core\Utility\Error;
use Drupal\simple_oauth\Entities\ScopeEntity;
use Drupal\simple_oauth\Entities\UserEntity;
use Drupal\simple_oauth\Form\Oauth2AuthorizeForm;
@@ -166,7 +165,7 @@ class Oauth2AuthorizeController extends ControllerBase {
}
}
catch (OAuthServerException $exception) {
Expand All @@ -152,18 +159,24 @@ index a69e0ea0df53489f27cce24532385259339d3227..6c39bb265276a322e7c81f385a0f4134
}

diff --git a/src/Controller/Oauth2Token.php b/src/Controller/Oauth2Token.php
index 51e4d80449f79dd80653e7afe51f459b68789c9b..84ee091f4362cd3d79ce434266f1ba826f0b0fe3 100644
index 51e4d80449f79dd80653e7afe51f459b68789c9b..954cab875b938243cbb074c5d2d1b1c3c354e9d9 100644
--- a/src/Controller/Oauth2Token.php
+++ b/src/Controller/Oauth2Token.php
@@ -10,6 +10,7 @@ use League\OAuth2\Server\Exception\OAuthServerException;
@@ -3,12 +3,12 @@
namespace Drupal\simple_oauth\Controller;

use Drupal\Core\Controller\ControllerBase;
-use Drupal\Core\Utility\Error;
use Drupal\simple_oauth\Server\AuthorizationServerFactoryInterface;
use GuzzleHttp\Psr7\Response;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -114,7 +115,10 @@ class Oauth2Token extends ControllerBase {
@@ -114,7 +114,10 @@ class Oauth2Token extends ControllerBase {
$response = $server->respondToAccessTokenRequest($server_request, $server_response);
}
catch (OAuthServerException $exception) {
Expand All @@ -177,18 +190,18 @@ index 51e4d80449f79dd80653e7afe51f459b68789c9b..84ee091f4362cd3d79ce434266f1ba82

diff --git a/src/EventSubscriber/ExceptionLoggingSubscriber.php b/src/EventSubscriber/ExceptionLoggingSubscriber.php
new file mode 100644
index 0000000000000000000000000000000000000000..cf351d3fcf89cdfb43944642721355d20d322c3e
index 0000000000000000000000000000000000000000..b91d129cd245a02212db1b9ae4990f25d21a34af
--- /dev/null
+++ b/src/EventSubscriber/ExceptionLoggingSubscriber.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Drupal\simple_oauth\EventSubscriber;
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber as CoreExceptionLoggingSubscriber;
+use Drupal\simple_oauth\Exception\OAuthUnauthorizedHttpException;
+use Psr\Log\LoggerInterface;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpKernel\Event\ExceptionEvent;
+
+/**
Expand Down Expand Up @@ -216,7 +229,7 @@ index 0000000000000000000000000000000000000000..cf351d3fcf89cdfb43944642721355d2
+ */
+ public function __construct(
+ EventSubscriberInterface $inner,
+ LoggerInterface $logger
+ LoggerInterface $logger,
+ ) {
+ $this->inner = $inner;
+ $this->logger = $logger;
Expand Down Expand Up @@ -248,22 +261,33 @@ index 0000000000000000000000000000000000000000..cf351d3fcf89cdfb43944642721355d2
+}
diff --git a/src/Exception/OAuthUnauthorizedHttpException.php b/src/Exception/OAuthUnauthorizedHttpException.php
new file mode 100644
index 0000000000000000000000000000000000000000..75baa81aef6b1f8517f95cb8889d723b74975c0f
index 0000000000000000000000000000000000000000..b0c00bae6a7f0286b389b6013f7fe6da3e8a831b
--- /dev/null
+++ b/src/Exception/OAuthUnauthorizedHttpException.php
@@ -0,0 +1,7 @@
@@ -0,0 +1,10 @@
+<?php
+
+namespace Drupal\simple_oauth\Exception;
+
+use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
+
+/**
+ * Exception thrown when the request is unauthorized.
+ */
+final class OAuthUnauthorizedHttpException extends UnauthorizedHttpException {}
diff --git a/tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php b/tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php
index f1dff6637ece6bff99b7cc06f458ee6552a1c1fa..d18fdec4e4e6ae44fd148420be1b4c1aa15dbd10 100644
index f1dff6637ece6bff99b7cc06f458ee6552a1c1fa..6671ac7327beea6bc25eeee1df4b63140e46edaf 100644
--- a/tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php
+++ b/tests/src/Unit/Authentication/Provider/SimpleOauthAuthenticationTest.php
@@ -49,14 +49,12 @@ class SimpleOauthAuthenticationTest extends UnitTestCase {
@@ -4,7 +4,6 @@ namespace Drupal\Tests\simple_oauth\Unit\Authentication\Provider;

use Drupal\Core\Authentication\AuthenticationProviderInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\PageCache\RequestPolicyInterface;
use Drupal\TestTools\Random;
use Drupal\Tests\UnitTestCase;
@@ -49,14 +48,12 @@ class SimpleOauthAuthenticationTest extends UnitTestCase {
$this->oauthPageCacheRequestPolicy = new DisallowSimpleOauthRequests();
$http_message_factory = $this->prophesize(HttpMessageFactoryInterface::class);
$http_foundation_factory = $this->prophesize(HttpFoundationFactoryInterface::class);
Expand All @@ -277,3 +301,4 @@ index f1dff6637ece6bff99b7cc06f458ee6552a1c1fa..d18fdec4e4e6ae44fd148420be1b4c1a
- $logger->reveal()
);
}

0 comments on commit 7564f1f

Please sign in to comment.