Commit e1c59c8a authored by eiriksm's avatar eiriksm Committed by Joao Ventura
Browse files

Issue #2875537 by pingers, mikejw, sun, eiriksm, jcnventura: Add in an event...

Issue #2875537 by pingers, mikejw, sun, eiriksm, jcnventura: Add in an event for altering the url_options in authorize method
parent 01412181
......@@ -5,6 +5,7 @@ namespace Drupal\openid_connect\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\GeneratedUrl;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
......@@ -236,16 +237,7 @@ abstract class OpenIDConnectClientBase extends PluginBase implements OpenIDConne
*/
public function authorize($scope = 'openid email') {
$redirect_uri = $this->getRedirectUrl()->toString(TRUE);
$url_options = [
'query' => [
'client_id' => $this->configuration['client_id'],
'response_type' => 'code',
'scope' => $scope,
'redirect_uri' => $redirect_uri->getGeneratedUrl(),
'state' => OpenIDConnectStateToken::create(),
],
];
$url_options = $this->getUrlOptions($scope, $redirect_uri);
$endpoints = $this->getEndpoints();
// Clear _GET['destination'] because we need to override it.
......@@ -261,6 +253,29 @@ abstract class OpenIDConnectClientBase extends PluginBase implements OpenIDConne
return $response;
}
/**
* Helper function for URL options.
*
* @param string $scope
* A string of scopes.
* @param \Drupal\Core\GeneratedUrl $redirect_uri
* URI to redirect for authorization.
*
* @return array
* Array with URL options.
*/
protected function getUrlOptions($scope, GeneratedUrl $redirect_uri) {
return [
'query' => [
'client_id' => $this->configuration['client_id'],
'response_type' => 'code',
'scope' => $scope,
'redirect_uri' => $redirect_uri->getGeneratedUrl(),
'state' => OpenIDConnectStateToken::create(),
],
];
}
/**
* Implements OpenIDConnectClientInterface::retrieveIDToken().
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment