dv-team/ms-entra-auth

A entra id auth helper

dev-main 2025-08-20 14:42 UTC

This package is auto-updated.

Last update: 2025-08-20 14:42:39 UTC


README

Setup details

https://www.adminlabs.de/anmeldung-mit-microsoft-azuread-php-anwendung/

01 02 03
04 05 06

PHP-DI:

return [
    /* ... */
    EntraIDEndpoints::class => autowire()
        ->constructorParameter('authorizationEndpoint', 'https://login.microsoftonline.com/<id>/oauth2/v2.0/authorize')
        ->constructorParameter('tokenEndpoint', 'https://login.microsoftonline.com/<id>/oauth2/v2.0/token'),
    
    EntraIDAuthFactory::class => autowire(EntraIDAuthFactory::class)
        ->constructorParameter('landingPageUri', 'https://<host>/entra-id-login.html'),
    
    EntryIDAuthClient::class => factory(function (EntraIDAuthFactory $factory, Container $container) {
        /** @var string $clientId */
        $clientId = $container->get('microsoft.entra-id.client-id');
    
        /** @var string $clientSecret */
        $clientSecret = $container->get('microsoft.entra-id.client-secret');
    
        return $factory->createAuthClient($clientId, $clientSecret);
    }),
    /* ... */
];