kingsoft / azure-oauth2
Handler to authenticate with AzureAD
1.3.2
2025-02-20 13:51 UTC
Requires
- php: >=8.2
- kingsoft/http: ^3.8
README
Sample
Where config.php sets the global SETTINGS and logger LOG
<?php declare(strict_types=1); define( 'ROOT', dirname( __DIR__ ) ); require ROOT . '/config/config.php'; require ROOT . '/vendor/autoload.php'; require ROOT . '/inc/logger.inc.php'; if( array_key_exists( 'action', $_GET ) ) { handleAction(); } else { // handle the callback from Azure AD (new AzureAuthenticator( SETTINGS['aad']['client-id'], SETTINGS['aad']['client-secret'], 'https://' . $_SERVER['SERVER_NAME'] . '/' . basename( $_SERVER['SCRIPT_FILENAME'], // LOG, ) )) ->setTenantId( SETTINGS['aad']['tennant-id'] ) ->setLogonCallback( 'findUser' ) ->setGetStateCallback( 'getState' ) ->setCheckStateCallback( 'checkState' ) ->handleAuthorizationCode(); }