We present yet another PHP integration package with ESIA - ekapusta/oauth2-esia
. Implemented as an adapter to the popular league/oauth2-client
.
Integration with the ESIA involves government agencies, financial and insurance companies, credit institutions (banks, microfinance), organizations with public wi-fi and others whom the government will do well in the future. The main organizing documents are described on Habré at the request of " ESIA ", the current versions of the documents are available at the office. site , and support can be obtained in a relatively reasonable time frame through esia@minsvyaz.ru .
embeds
available in the ESIA. Those. to receive contacts / addresses you will not need to make more N separate requests.league/oauth2-client
covered with tests, to which it is an adapter, without inventing bicycles and is itself covered with tests for 100%.ramsey/uuid
and lcobucci/jwt
.^ 5.6 || ^ 7.0
^ 5.6 || ^ 7.0
. use Ekapusta\OAuth2Esia\Provider\EsiaProvider; use Ekapusta\OAuth2Esia\Security\Signer\OpensslPkcs7; $provider = new EsiaProvider([ 'clientId' => 'XXXXXX', // "" 'redirectUri' => 'https://your-system.domain/auth/finish/', 'defaultScopes' => ['openid', 'fullname', '...'], // // // 'remoteUrl' => 'https://esia-portal1.test.gosuslugi.ru', // 'remoteCertificatePath' => EsiaProvider::RESOURCES.'esia.test.cer', ], [ 'signer' => new OpensslPkcs7('/path/to/public/certificate.cer', '/path/to/private.key') ]);
OpensslPkcs7
sufficient.OpensslPkcs7
enough.OpensslCli
. It has a “toolpath” parameter.OpensslCli
with the parameter 'toolpath' => 'docker run --rm -i -v $(pwd):$(pwd) -w $(pwd) rnix/openssl-gost openssl'
.At the same time saving the state for subsequent verification.
// - https://your-system.domain/auth/start/ $authUrl = $provider->getAuthorizationUrl(); $_SESSION['oauth2.esia.state'] = $provider->getState(); header('Location: '.$authUrl); exit;
Checking the state and changing the code to an authentication token.
// - https://your-system.domain/auth/finish/?state=...&code=... if ($_SESSION['oauth2.esia.state'] !== $_GET['state']) { exit('The guard unravels the crossword.'); } $token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]); $esiaPersonData = $provider->getResourceOwner($accessToken); var_export($esiaPersonData->toArray());
Standard as described in the oauth2-client documentation
Package zaopersorsen finteh-company in which I work. Not tested on animals.
The symfony-bundle ekapusta/oauth2-esia-bundle
:
^5.6 || ^7.0
^5.6 || ^7.0
^2.8 || ^3 || ^4
^2.8 || ^3 || ^4
^2.8 || ^3 || ^4
.Source: https://habr.com/ru/post/358834/
All Articles