Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-9857: Removed overridden ::authorize() method #33

Merged
merged 2 commits into from
Mar 21, 2024
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
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
Loading