jincor / auth-php-client
A PHP library which encapsulates interaction with Jincor Auth
Installs: 255
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 2
Open Issues: 1
pkg:composer/jincor/auth-php-client
Requires
- php: >=7
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- codeception/codeception: ^2.3
- phpunit/phpunit: ~5.7
- squizlabs/php_codesniffer: 2.*
This package is not auto-updated.
Last update: 2025-10-26 10:14:42 UTC
README
This is a client library which encapsulates interaction with Jincor Auth. With its help you can:
- Register users and tenants.
- Get tokens for users and tenants after authorization.
- Perform verification of tokens for users and tenants.
- Deactivate tokens for users and tenants.
- Remove users.
The user can be attached to several tenants through the field tenant. It is filled from the tenant's token in the Jincor Auth service.
Usage
Initialize Auth client
To interact with the HTTP protocol use Guzzle. Headers Accept: application/json and Content-Type: application/json are mandatory.
$authClient = new AuthClient(new Client([ 'base_uri' => 'auth:3000', 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', ] ]));
Work with Tenant
$tenant = $authClient->registerTenant('tenant@example.com', 'Passwpord'); echo $tenant->getId(); // 'af8b13ea-02a9-4e73-b8d9-58c8215757b9' $tenantToken = $authClient->loginTenant('tenant@example.com', 'Passwpord'); $result = $authClient->verifyTenantToken($tenantToken); echo $result->getAud(); // 'jincor.com' $authClient->logoutTenant($tenantToken);
Work with User
To work with users you need a tenant token. Field scope is optional.
$userData = [ 'email' => 'user@example.com', 'password' => 'Password1', 'login' => 'emp_dev', 'sub' => '123', 'scope' => [ 'admin', 'settings' => 'setting', ] ]; $user = $authClient->createUser($userData, $tenantToken); echo $user->getId(); // '55096b7d-0f14-446a-b50d-ee6bc8431e39' $userData = [ 'login' => 'emp_dev', 'password' => 'Password1', 'deviceId' => '123', ]; $userToken = $authClient->loginUser($userData, $tenantToken); $result = $authClient->verifyUserToken($userToken, $tenantToken); $authClient->logoutUser($userToken, $tenantToken); $authClient->deleteUser($userData['login'], $tenantToken);
More details can be received in the tests.
Project setup
- Clone the repo
cd /path/to/repodocker-compose build- build development containersdocker-compose up -d- run container
Local testing
To run all tests just type docker-compose exec workspace ./vendor/bin/codecept run