Any reason you're not using on of the Azure AD packages? For example?
https://github.com/metrogistics/laravel-azure-ad-oauth -- Extension of Socialite https://github.com/rootinc/laravel-azure-middleware -- Based on middleware
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey guys,
I am trying to add Authentication with Azure AD to my Laravel Web Application, hosted on IIS. I followed the instructions in the following Link as precise as possible: https://github.com/Azure-Samples/active-directory-b2c-php-webapp-openidconnect I don't have acces to the policys so i had to remove the policy_name in the getMetadata Function in the Endpointhandler
public function getMetadata($policy_name) {
require "settings.php";
$metadata_endpoint = $metadata_endpoint_begin; // . $policy_name;
$this->metadata = $this->getEndpointData($metadata_endpoint);
}
After i did everything in the instructions in the Link above and placed a Login-Button, which calls this function...
public function login()
{
require app_path()."/Http/Controllers/settings.php";
require app_path()."/Http/Controllers/EndpointHandler.php";
// Set cookie for state
$state = rand();
setcookie("state", $state);
// Redirect to sign up/sign in page
$endpoint_handler = new EndpointHandler($generic_policy);
$authorization_endpoint = $endpoint_handler->getAuthorizationEndpoint()."&state=generic"."+". $state;
return redirect($authorization_endpoint);
}
...I am getting this error when clicking the Button
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) Cannot redeclare getClaim() (previously declared in C:\inetpub\wwwroot\bcompetent\fleet_booking_test\app\Http\Controllers\EndpointHandler.php:6)
when i place "namespace App\Http\Controllers"; on top of the EndpointHandler.php and the TokenChecker.php i don't get this Error anymore and i get directed to this Link:
where i can enter my Login-credentials, but after i did this i am getting the Error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'App\Http\Controllers\Crypt_RSA' not found
Does anyone here have a Solution for my Problem? I have a feeling that it could have something to do with composer or with the providers in my config/app.php but i am just guessing, because i am very new to Laravel.
I am thankful for every kind of assistance
Please or to participate in this conversation.