-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from arlina-espinoza/merge-hybrid-work
Merge hybrid work
- Loading branch information
Showing
20 changed files
with
590 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Copyright 2019 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License version 2 as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
use Apigee\Edge\Utility\OrganizationFeatures; | ||
|
||
/** | ||
* @file | ||
* Install, update and uninstall functions for Apigee Edge Teams. | ||
*/ | ||
|
||
/** | ||
* Implements hook_requirements(). | ||
*/ | ||
function apigee_edge_teams_requirements($phase) { | ||
$requirements = []; | ||
|
||
if ($phase == 'install' || $phase == 'runtime') { | ||
try { | ||
/** @var \Drupal\apigee_edge\SDKConnectorInterface $sdk_connector */ | ||
$sdk_connector = \Drupal::service('apigee_edge.sdk_connector'); | ||
$org_controller = \Drupal::service('apigee_edge.controller.organization'); | ||
/* @var \Apigee\Edge\Api\Management\Entity\Organization $organization */ | ||
$organization = $org_controller->load($sdk_connector->getOrganization()); | ||
if ($organization && !OrganizationFeatures::isCompaniesFeatureAvailable($organization)) { | ||
$url = [ | ||
':url' => 'https://docs.apigee.com/hybrid/compare-hybrid-edge#unsupported-apis', | ||
]; | ||
$message = ($phase == 'runtime') ? | ||
t("The Apigee Edge Teams module functionality is not available for your org and should be uninstalled, because <a href=':url' target='_blank'>Edge company APIs are not supported in Apigee hybrid orgs</a>.", $url) : | ||
t("The Apigee Edge Teams module functionality is not available for your org because <a href=':url' target='_blank'>Edge company APIs are not supported in Apigee hybrid orgs</a>.", $url); | ||
$requirements['apigee_edge_teams_not_supported'] = [ | ||
'title' => t('Apigee Edge Teams'), | ||
'description' => $message, | ||
'severity' => REQUIREMENT_ERROR, | ||
]; | ||
} | ||
} | ||
catch (\Exception $exception) { | ||
// Do nothing if connection to Edge is not available. | ||
} | ||
} | ||
|
||
return $requirements; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2019 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace Drupal\apigee_edge\Connector; | ||
|
||
use Apigee\Edge\ClientInterface; | ||
use Apigee\Edge\HttpClient\Plugin\Authentication\HybridOauth2; | ||
use Apigee\Edge\HttpClient\Plugin\Authentication\NullAuthentication; | ||
|
||
/** | ||
* Decorator for Hybrid authentication plugin. | ||
*/ | ||
class HybridAuthentication extends HybridOauth2 { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function authClient(): ClientInterface { | ||
/** @var \Drupal\apigee_edge\SDKConnectorInterface $sdk_connector */ | ||
$sdk_connector = \Drupal::service('apigee_edge.sdk_connector'); | ||
return $sdk_connector->buildClient(new NullAuthentication(), $this->getAuthServer()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2019 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License version 2 as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace Drupal\apigee_edge\Connector; | ||
|
||
use Drupal\apigee_edge\Credentials; | ||
use Drupal\apigee_edge\Exception\InvalidArgumentException; | ||
use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface; | ||
use Drupal\key\KeyInterface; | ||
|
||
/** | ||
* The API credentials for HybridCredentials. | ||
*/ | ||
class HybridCredentials extends Credentials { | ||
|
||
/** | ||
* HybridCredentials constructor. | ||
* | ||
* @param \Drupal\key\KeyInterface $key | ||
* The key entity which stores the API credentials. | ||
* | ||
* @throws \InvalidArgumentException | ||
* An InvalidArgumentException is thrown if the key type | ||
* does not implement EdgeKeyTypeInterface. | ||
*/ | ||
public function __construct(KeyInterface $key) { | ||
if ($key->getKeyType() instanceof EdgeKeyTypeInterface | ||
&& ($auth_type = $key->getKeyType()->getAuthenticationType($key)) | ||
&& $auth_type === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_JWT | ||
) { | ||
parent::__construct($key); | ||
} | ||
else { | ||
throw new InvalidArgumentException("The `{$key->id()}` key is not configured for Hybrid Authentication."); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.