Giter Club home page Giter Club logo

azure-ad-delta-sync's Introduction

Azure AD Delta Sync

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:

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

azure-ad-delta-sync's People

Contributors

jekuaitk avatar rimi-itk avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.