itk-dev / azure-ad-delta-sync
Composer package for Azure AD Delta Sync flow
Requires
- php: ^8.1
- ext-json: *
- nyholm/psr7: ^1.4
- psr/http-client: ^1.0
- symfony/options-resolver: ^5.4 || ^6.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-01-17 11:45:40 UTC
README
Composer package for the Azure AD Delta Sync flow.
Usage
If you are looking to use this in a Symfony or Drupal project you should use either:
- Symfony: itk-dev/azure-ad-delta-sync-symfony
- Drupal: itk-dev/azure-ad-delta-sync-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 } }
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 = [ 'uri' => 'https://aarhus.../RetrieveProvisioningData/...', // System provisioning uri 'security_key' => 'some_security_key', // Provisioning data security key 'client_secret' => 'some_client_secret', // System provisioning client secret ]; $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 has access to the system in question.
Should the configured system 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 8.2 image is included in this project.
To install the dependencies you can run
docker compose pull
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.
Coding Standard
PHP files (PHP_CodeSniffer)
Check PHP coding standards
docker compose run --rm phpfpm composer install docker compose run --rm phpfpm composer coding-standards-check
Apply coding standard changes
docker compose run --rm phpfpm composer coding-standards-apply
Markdown files
docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint '**/*.md' ```shell docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint '**/*.md' --fix
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
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