Skip to content

Commit

Permalink
Merge pull request #33 from City-of-Helsinki/UHF-9857
Browse files Browse the repository at this point in the history
UHF-9857: Removed overridden ::authorize() method
  • Loading branch information
tuutti authored Mar 21, 2024
2 parents de999b6 + 21e0eac commit 826dabf
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 43 deletions.
2 changes: 1 addition & 1 deletion helfi_tunnistamo.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Contains installation tasks for 'helfi_tunnistamo' module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\user\Entity\User;

Expand Down
2 changes: 1 addition & 1 deletion helfi_tunnistamo.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Contains alterations for the Hel.fi tunnistamo module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Component\Uuid\Uuid;
use Drupal\Core\Form\FormStateInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Event/RedirectUrlEvent.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\helfi_tunnistamo\Event;

Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/HttpExceptionSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\helfi_tunnistamo\EventSubscriber;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/DebugDataItem/Tunnistamo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\helfi_tunnistamo\Plugin\DebugDataItem;

Expand Down
30 changes: 0 additions & 30 deletions src/Plugin/OpenIDConnectClient/Tunnistamo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Drupal\helfi_tunnistamo\Plugin\OpenIDConnectClient;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\helfi_tunnistamo\Event\RedirectUrlEvent;
Expand All @@ -15,7 +14,6 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;

/**
* Implements OpenID Connect Client plugin for Tunnistamo.
Expand Down Expand Up @@ -113,34 +111,6 @@ protected function getRedirectUrl(
return $urlEvent->getRedirectUrl();
}

/**
* {@inheritdoc}
*/
public function authorize(string $scope = 'openid email', array $additional_params = []): Response {
// @todo Remove this override once https://www.drupal.org/project/openid_connect/issues/3317308
// is merged.
$redirect_uri = $this->getRedirectUrl()->toString(TRUE);
$url_options = $this->getUrlOptions($scope, $redirect_uri);

if (!empty($additional_params)) {
$url_options['query'] = array_merge($url_options['query'], $additional_params);
}

$endpoints = $this->getEndpoints();
// Clear _GET['destination'] because we need to override it.
$this->requestStack->getCurrentRequest()->query->remove('destination');
$authorization_endpoint = Url::fromUri($endpoints['authorization'], $url_options)->toString(TRUE);

$this->loggerFactory->get('openid_connect_' . $this->pluginId)->debug('Send authorize request to @url', ['@url' => $authorization_endpoint->getGeneratedUrl()]);
$response = new TrustedRedirectResponse($authorization_endpoint->getGeneratedUrl());
// We can't cache the response, since this will prevent the state to be
// added to the session. The kill switch will prevent the page getting
// cached for anonymous users when page cache is active.
$this->pageCacheKillSwitch->trigger();

return $response;
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Functional/LoginFormTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Functional;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/HttpExceptionSubscriberTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/KernelTestBase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/RedirectUrlEventTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/RoleMapTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/TunnistamoClientTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/TunnistamoDebugDataPluginTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/UserInfoAlterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\helfi_tunnistamo\Kernel;

Expand Down

0 comments on commit 826dabf

Please sign in to comment.