gids-open-standaarden / open-pgo-medmij-implementatie-bouwstenen-php
PHP implementation of the MedMij OpenPGO building blocks.
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 0
Open Issues: 0
pkg:composer/gids-open-standaarden/open-pgo-medmij-implementatie-bouwstenen-php
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.0
- jms/serializer: ^1.13
- league/oauth2-client: ^2.3
- psr/http-message: ^1.0
- webmozart/assert: ^1.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
- phpstan/phpstan: ^0.10.6
- phpunit/phpunit: ^7.2
This package is auto-updated.
Last update: 2021-06-20 15:38:14 UTC
README
Dear reader, The decision has been made to archive this repository. The reason is that the OpenPGO-Medmij-ImplementatieBouwstenen-PHP isn’t being used and has deferred maintenance including security vulnerabilities. If you desire to use this adapter, please contact GIDS: info@gidsopenstandaarden.org.
gids-open-standaarden/open-pgo-medmij-implementatie-bouwstenen-php
PHP implementation of the MedMij OpenPGO building blocks.
Version Guidance
This library follows Semantic Versioning. The versions of the Afspraken set are mapped to the versions of the library as follows:
| Version Afsprakenset | Status | Version library |
|---|---|---|
| Afsprakenset release 1.1 | Latest | 0.2.* |
| Afsprakenset release 1.0 | EOL | 0.1.* |
Installation
The OpenPGO PHP adapter can be installed using Composer:
$ composer require gids-open-standaarden/open-pgo-medmij-implementatie-bouwstenen-php ~0.2
Configuration
The building blocks use a HTTP client (Guzzle) to connect.
For example the Whitelist client can be constructed like this:
$whitelistClient = new \MedMij\OpenPGO\Whitelist\WhitelistClient( new \GuzzleHttp\Client(), 'whitelist endpoint' );
Use cases
Retrieve Whitelist
see https://github.com/GidsOpenStandaarden/OpenPGO/blob/master/Resources/UCI%20Opvragen%20Whitelist.pdf
The WhitelistClient can be used to retrieve the Whitelist.
$whitelist = $whitelistClient->getWhitelist();
The WhitelistService provides a convenience method isMedMijNodeWhitelisted to check if a given node is whitelisted.
$service = new \MedMij\OpenPGO\Whitelist\WhitelistService($whitelistClient); $service->isMedMijNodeWhitelisted('specimen-stelselnode.medmij.nl');
Retrieve OCL
see https://github.com/GidsOpenStandaarden/OpenPGO/blob/master/Resources/UCI%20Opvragen%20OCL.pdf
The OAuthClientListClient can be used to retrieve the OAuthclientlist.
$client = new \MedMij\OpenPGO\OCL\OAuthClientListClient( new \GuzzleHttp\Client(), 'OAuth Client List endpoint' ); $client->getOAuthClientList();
The OAuthClientService provides a convenience method getOAuthClientByHostname to get an OAuthClient
by its unique hostname.
$service = new \MedMij\OpenPGO\OCL\OAuthClientService($client); $service->getOAuthClientByHostname('medmij.deenigeechtepgo.nl');
Retrieve ZAL
see https://github.com/GidsOpenStandaarden/OpenPGO/blob/master/Resources/UCI%20Opvragen%20ZAL.pdf
The ZALClient can be used to retrieve the Zorgaanbiederslijst.
$client = new \MedMij\OpenPGO\ZAL\ZALClient( new \GuzzleHttp\Client(), 'ZAL endpoint' ); $client->getZAL();
The ZorgaanbiederService provides a convenience method getZorgaanbiederByName to get a Zorgaanbieder
by its unique name.
$service = new \MedMij\OpenPGO\ZAL\ZorgaanbiederService($client); $service->getZorgaanbiederByName('umcharderwijk@medmij');
Retrieve Gegevensdienstnamenlijst
The GegevensdienstnamenlijstClient can be used to retrieve the Gegevensdienstnamenlijst.
$client = new \MedMij\OpenPGO\GNL\GegevensdienstnamenlijstClient( new \GuzzleHttp\Client(), 'gegevensdienstnamenlijst endpoint' ); $client->getGegevensdienstnamenlijst();
The GegevensdienstnamenlijstService provides a convenience method getGegevensdienstById to get a Gegevensdienst
by its unique identifier.
$service = new \MedMij\OpenPGO\GNL\GegevensdienstnamenlijstService($client); $service->getGegevensdienstById(42);
OAuth
This library provides the building blocks for Three Legged OAuth 2 authentication.
A PGO GW can authenticate with a ZA GW using a ZorgaanbiederProvider which is configured with
- an OAuthclient as listed in the OAuthClientList
- a Gegevensdienst as listed in the Zorgaanbiederslijst.
$oAuthClient = new OAuthClient('medmij.deenigeechtepgo.nl', 'De Enige Echte PGO'); $gegevensdienst = new Gegevensdienst( '4', new AuthorizationEndpoint('https://medmij.nl/dialog/oauth'), new TokenEndpoint('https://medmij.nl/token'), [] ); $zorgaanbieder = (new ZorgaanbiederProviderFactory())->create($oAuthClient, $gegevensdienst);
Step 1. Application redirects User to Service for Authorization
header('Location: ' . $provider->getAuthorizationUrl(); exit;
Note: store the state ($provider->getState()) to prevent replay attacks.
Step 2. User logs into the Service and grants Application access.
Step 3. Service redirects User back to the redirect_url.
Step 4. Application takes the code and exchanges it for an Access Token
$provider->getAccessToken('authorization_code', [ 'code' => '1234' ]);
Development
Clone this repository and run composer install to install the dependencies.
Testing
This library is tested using PHPUnit.
The tests can be executed with this command:
vendor/bin/phpunit