itk-dev / azure-ad-delta-sync
Composer package for Azure AD Delta Sync flow
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- nyholm/psr7: ^1.4
- psr/http-client: ^1.0
- symfony/options-resolver: ^4.4 || ^5.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-11 10:08:06 UTC
README
Composer package for the Azure AD Delta Sync flow.
References
Usage
If you are looking to use this in a Symfony or Drupal project you should use either:
- Symfony: itk-dev/adgangsstyring-bundle
- Drupal: itk-dev/adgangsstyring_drupal
Direct installation
To install this package directly run
composer require itk-dev/azure-ad-delta-sync
Flow
To start the flow one needs to call the
Controller
run(HandlerInterface $handler)
command.
Therefore, you must create your own handler that implements
HandlerInterface
.
Example Usage
<?php use ItkDev\AzureAdDeltaSync\Handler\HandlerInterface; class SomeHandler implements HandlerInterface { public function collectUsersForDeletionList(): void { // Some start logic } public function removeUsersFromDeletionList(array $users): void { // Some user logic } public function commitDeletionList(): void { // Some commit logic } }
Be aware that removeUsersFromDeletionList()
may be called multiple times,
as we are limited to 100 users per request.
To start the flow provide a HTTP Client that implements
PSR-18 CLientInterface
,
and the required options seen in the example beneath.
Note that this example uses Guzzle HTTP Client. For a list of PSR-18 implementing libraries click here.
use GuzzleHttp\Client; use ItkDev\AzureAdDeltaSync\Controller; $options = [ 'tenant_id' => 'something.onmicrosoft.com', // Tenant id 'client_id' => 'some_client_id', // Client id assigned by authorizer 'client_secret' => 'some_client_secret', // Client password assigned by authorizer 'group_id' => 'some_group_id', // Group id provided by authorizer ]; $handler = new SomeHandler(); $client = new Client(); $controller = new Controller($client, $this->options); $controller->run($handler);
General comments
Note that this package does not do the synchronization of users, instead it provides a list of all users that currently are assigned to the group in question.
Should the specified group contain no users an exception will be thrown. This is to avoid using systems to be under the impression that every single user should be deleted.
Development Setup
A docker-compose.yml
file with a PHP 7.4 image is included in this project.
To install the dependencies you can run
docker compose up -d
docker compose exec phpfpm composer install
Unit Testing
We use PHPUnit for unit testing. To run the tests:
docker compose exec phpfpm composer install docker compose exec phpfpm ./vendor/bin/phpunit tests
The test suite uses Mocks for generation of test doubles.
Check Coding Standard
-
PHP files (PHP_CodeSniffer)
docker compose exec phpfpm composer check-coding-standards
-
Markdown files (markdownlint standard rules)
docker run -v ${PWD}:/app itkdev/yarn:latest install docker run -v ${PWD}:/app itkdev/yarn:latest check-coding-standards
GitHub Actions
All code checks mentioned above are automatically run by GitHub Actions when a pull request is created.
To run the actions locally, install act and run
act -P ubuntu-latest=shivammathur/node:focal pull_request
Use act -P ubuntu-latest=shivammathur/node:focal pull_request --list
to see
individual workflow jobs that can be run, e.g.
act -P ubuntu-latest=shivammathur/node:focal pull_request --job phpcsfixer
Apply Coding Standards
-
PHP files (PHP_CodeSniffer)
docker compose exec phpfpm composer apply-coding-standards
-
Markdown files (markdownlint standard rules)
docker run -v ${PWD}:/app itkdev/yarn:latest install docker run -v ${PWD}:/app itkdev/yarn:latest apply-coding-standards
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MIT License - see the LICENSE.md file for details