-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
UPDATE.SH
committed
Nov 4, 2021
0 parents
commit e5284b1
Showing
58 changed files
with
3,194 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.idea | ||
/vendor/ | ||
.php_cs | ||
.php_cs.cache | ||
/phpunit.xml | ||
.phpunit.result.cache | ||
composer.phar | ||
composer.lock |
Empty file.
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,13 @@ | ||
CHANGELOG | ||
========= | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
- Implemented `FeatureFlagHeaderExtractor` | ||
- Implemented `TenantIdHeaderExtractor` | ||
- Implemented `AuthorizationDetailsHeaderMarker` | ||
- Implemented `\Grpc\ConfigurationRepository` | ||
- Implemented `\Grpc\FeatureFlagRepository` | ||
- Implemented `\Grpc\LtiRegistrationRepository` | ||
- Implemented `\Grpc\Oauth2ClientRepository` |
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,25 @@ | ||
# Environment Management Client Library | ||
|
||
PHP Library to ease communication with Environment Management. | ||
|
||
## Installation | ||
|
||
```console | ||
$ composer require oat-sa/lib-em-php-client | ||
``` | ||
|
||
## Concepts | ||
- [Feature Flags Extractor](docs/feature-flags.md) | ||
- [Tenant Id Extractor](docs/tenant-id.md) | ||
- [Request Authorization Details](docs/auth-details.md) | ||
- [gRPC - Fetching Configuration](docs/grpc/configuration.md) | ||
- [gRPC - Fetching Feature Flag](docs/grpc/feature-flag.md) | ||
- [gRPC - Fetching LTI Registration](docs/grpc/lti-registration.md) | ||
- [gRPC - Fetching OAuth2 Client](docs/grpc/oauth2-client.md) | ||
## Tests | ||
|
||
To run tests: | ||
|
||
```console | ||
$ vendor/bin/phpunit | ||
``` |
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,37 @@ | ||
{ | ||
"name": "oat-sa/lib-em-php-client", | ||
"description": "PHP library to assist communication with Environment Management", | ||
"type": "library", | ||
"license": "GPL-2.0-only", | ||
"minimum-stability": "dev", | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/oat-sa/lib-em-php-proto" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.4.0", | ||
"ext-grpc": "*", | ||
"oat-sa/lib-em-php-proto": "*", | ||
"psr/http-message": "^1.0", | ||
"psr/log": "^1.0 || ^2.0 || ^3.0" | ||
}, | ||
"require-dev": { | ||
"nyholm/psr7": "^1.4", | ||
"phpunit/phpunit": "^9.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"OAT\\Library\\EnvironmentManagementClient\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"OAT\\Library\\EnvironmentManagementClient\\Tests\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
} | ||
} |
Empty file.
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,37 @@ | ||
# Request Authorization Details | ||
|
||
Using [AuthorizationDetailsHeaderMarker](../src/Http/AuthorizationDetailsHeaderMarker.php), there is a way to set a special header | ||
on any PSR-7 Response which is an indicator for Envoy to add authorization information to the response before forwarding. | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Http\AuthorizationDetailsMarkerInterface; | ||
use OAT\Library\EnvironmentManagementClient\Http\AuthorizationDetailsHeaderMarker; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class MyService { | ||
/** @var AuthorizationDetailsMarkerInterface */ | ||
private $authorizationDetailsMarker; | ||
|
||
public function __construct(AuthorizationDetailsMarkerInterface $authorizationDetailsMarker) | ||
{ | ||
$this->authorizationDetailsMarker = $authorizationDetailsMarker; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
/** @var ResponseInterface $response */ | ||
$response = ... | ||
|
||
$response = $this->authorizationDetailsMarker->withAuthDetails($response); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new AuthorizationDetailsHeaderMarker()); | ||
$myService->myMethod(); | ||
``` |
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,49 @@ | ||
# Feature Flags Extractor | ||
|
||
- Interface: [FeatureFlagExtractorInterface](../src/Http/FeatureFlagExtractorInterface.php) | ||
- Default implementation: [FeatureFlagHeaderExtractor](../src/Http/FeatureFlagHeaderExtractor.php) - extracts any Feature Flag from the headers | ||
of an HTTP Message | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Http\FeatureFlagExtractorInterface; | ||
use OAT\Library\EnvironmentManagementClient\Http\FeatureFlagHeaderExtractor; | ||
use OAT\Library\EnvironmentManagementClient\Model\FeatureFlag; | ||
use Psr\Http\Message\MessageInterface; | ||
|
||
class MyService { | ||
/** @var FeatureFlagExtractorInterface */ | ||
private $featureFlagExtractor; | ||
|
||
public function __construct(FeatureFlagExtractorInterface $featureFlagExtractor) | ||
{ | ||
$this->featureFlagExtractor = $featureFlagExtractor; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
/** @var MessageInterface $message */ | ||
$message = ... | ||
|
||
$flagCollection = $this->featureFlagExtractor->extract($message); | ||
|
||
$flagCollection->isEmpty(); | ||
$flagCollection->has('flag-1'); | ||
|
||
/** @var FeatureFlag $flag */ | ||
$flag = $flagCollection->get('flag-1'); | ||
$flag->getName(); | ||
$flag->getValue(); | ||
|
||
$flagCollection->all(); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new FeatureFlagHeaderExtractor()); | ||
$myService->myMethod(); | ||
``` |
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,42 @@ | ||
# Fetching Configuration through gRPC | ||
|
||
- Interface: [ConfigurationRepositoryInterface](../../src/Repository/ConfigurationRepositoryInterface.php) | ||
- gRPC implementation: [ConfigurationRepository](../../src/Grpc/ConfigurationRepository.php) | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Repository\ConfigurationRepositoryInterface; | ||
use OAT\Library\EnvironmentManagementClient\Grpc\ConfigurationRepository; | ||
|
||
class MyService { | ||
/** @var ConfigurationRepositoryInterface */ | ||
private $configurationRepository; | ||
|
||
public function __construct(ConfigurationRepositoryInterface $configurationRepository) | ||
{ | ||
$this->configurationRepository = $configurationRepository; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
$configuration = $this->configurationRepository->find(new TenantId('t1'), 'conf-1'); | ||
|
||
//... | ||
|
||
$configCollection = $this->configurationRepository->findAll(new TenantId('t1')); | ||
|
||
$configCollection->isEmpty(); | ||
$configCollection->has('conf-1'); | ||
$configCollection->get('conf-1'); | ||
$configCollection->all(); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new ConfigurationRepository()); | ||
$myService->myMethod(); | ||
``` |
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,42 @@ | ||
# Fetching Feature Flag through gRPC | ||
|
||
- Interface: [FeatureFlagRepositoryInterface](../../src/Repository/FeatureFlagRepositoryInterface.php) | ||
- gRPC implementation: [FeatureFlagRepository](../../src/Grpc/FeatureFlagRepository.php) | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Repository\FeatureFlagRepositoryInterface; | ||
use OAT\Library\EnvironmentManagementClient\Grpc\FeatureFlagRepository; | ||
|
||
class MyService { | ||
/** @var FeatureFlagRepositoryInterface */ | ||
private $featureFlagRepository; | ||
|
||
public function __construct(FeatureFlagRepositoryInterface $featureFlagRepository) | ||
{ | ||
$this->featureFlagRepository = $featureFlagRepository; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
$flag = $this->featureFlagRepository->find(new TenantId('t1'), 'flag-1'); | ||
|
||
//... | ||
|
||
$flagCollection = $this->featureFlagRepository->findAll(new TenantId('t1')); | ||
|
||
$flagCollection->isEmpty(); | ||
$flagCollection->has('flag-1'); | ||
$flagCollection->get('flag-1'); | ||
$flagCollection->all(); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new FeatureFlagRepository()); | ||
$myService->myMethod(); | ||
``` |
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,47 @@ | ||
# Fetching LTI Registration through gRPC | ||
|
||
- Interface: [LtiRegistrationRepositoryInterface](../../src/Repository/LtiRegistrationRepositoryInterface.php) | ||
- gRPC implementation: [LtiRegistrationRepository](../../src/Grpc/LtiRegistrationRepository.php) | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Repository\LtiRegistrationRepositoryInterface; | ||
use OAT\Library\EnvironmentManagementClient\Grpc\LtiRegistrationRepository; | ||
|
||
class MyService { | ||
/** @var LtiRegistrationRepositoryInterface */ | ||
private $ltiRegistrationRepository; | ||
|
||
public function __construct(LtiRegistrationRepositoryInterface $ltiRegistrationRepository) | ||
{ | ||
$this->ltiRegistrationRepository = $ltiRegistrationRepository; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
$registration = $this->ltiRegistrationRepository->find(new TenantId('t1'), 'reg-1'); | ||
|
||
//... | ||
|
||
$ltiRegistrationCollection = $this->ltiRegistrationRepository->findAll( | ||
new TenantId('t1'), | ||
'client-id', | ||
'platform-iss', | ||
'tool-iss' | ||
); | ||
|
||
$ltiRegistrationCollection->isEmpty(); | ||
$ltiRegistrationCollection->has('reg-1'); | ||
$ltiRegistrationCollection->get('reg-1'); | ||
$ltiRegistrationCollection->all(); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new LtiRegistrationRepository()); | ||
$myService->myMethod(); | ||
``` |
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,33 @@ | ||
# Fetching OAuth2 Client through gRPC | ||
|
||
- Interface: [OAuth2ClientRepositoryInterface](../../src/Repository/OAuth2ClientRepositoryInterface.php) | ||
- gRPC implementation: [OAuth2ClientRepository](../../src/Grpc/OAuth2ClientRepository.php) | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Repository\OAuth2ClientRepositoryInterface; | ||
use OAT\Library\EnvironmentManagementClient\Grpc\OAuth2ClientRepository; | ||
|
||
class MyService { | ||
/** @var OAuth2ClientRepositoryInterface */ | ||
private $oAuth2ClientRepository; | ||
|
||
public function __construct(OAuth2ClientRepositoryInterface $oAuth2ClientRepository) | ||
{ | ||
$this->oAuth2ClientRepository = $oAuth2ClientRepository; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
$oAuth2Client = $this->oAuth2ClientRepository->find('client-1'); | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new OAuth2ClientRepository()); | ||
$myService->myMethod(); | ||
``` |
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,47 @@ | ||
# Tenant Id Extractor | ||
|
||
- Interface: [TenantIdExtractorInterface](../src/Http/TenantIdExtractorInterface.php) | ||
- Default implementation: [TenantIdHeaderExtractor](../src/Http/TenantIdHeaderExtractor.php) - extracts the Tenant Id from the headers | ||
of an HTTP Message | ||
|
||
```php | ||
<?php | ||
|
||
use OAT\Library\EnvironmentManagementClient\Http\TenantIdExtractorInterface; | ||
use OAT\Library\EnvironmentManagementClient\Http\TenantIdHeaderExtractor; | ||
use OAT\Library\EnvironmentManagementClient\Exception\TenantIdNotFoundException; | ||
use OAT\Library\EnvironmentManagementClient\Model\TenantId; | ||
use Psr\Http\Message\MessageInterface; | ||
|
||
class MyService { | ||
/** @var TenantIdExtractorInterface */ | ||
private $tenantIdExtractor; | ||
|
||
public function __construct(TenantIdExtractorInterface $tenantIdExtractor) | ||
{ | ||
$this->tenantIdExtractor = $tenantIdExtractor; | ||
} | ||
|
||
public function myMethod(): void | ||
{ | ||
//... | ||
|
||
/** @var MessageInterface $message */ | ||
$message = ... | ||
|
||
try { | ||
/** @var TenantId $tenantId */ | ||
$tenantId = $this->tenantIdExtractor->extract($message); | ||
|
||
//... | ||
} catch (TenantIdNotFoundException $exception) { | ||
//... | ||
} | ||
|
||
//... | ||
} | ||
} | ||
|
||
$myService = new MyService(new TenantIdHeaderExtractor()); | ||
$myService->myMethod(); | ||
``` |
Oops, something went wrong.