Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Azure Active Directory from PHP web application

Seeking for guidance on the subject as I'm really stuck on this, I have a internal URL for an App made on PHP and I want to connect to Azure Active Directory.

So far I've reviewed an example from Microsoft using SimpleSAML but it's really outdated and I'm having troubles adapting it for the newer SimpleSAMl code.

Is there a better way to integrate a web application with Azure AD? I read somewhere that I may use Get started with Mobile Services but I would like to hear from previous experiences on what is the best/current method for using Azure AD for login on PHP?.

-- EDIT --

By integrate I mean to allow people authenticate and retrieve the email address or EmployeeID from the Azure AD to provide SSO support.

like image 642
Vladimir Hidalgo Avatar asked Nov 03 '15 21:11

Vladimir Hidalgo


People also ask

Can PHP be used with Azure?

PHP is frequently used on Azure App Services (aka Microsoft Azure, Windows Azure, Azure Web Apps). Azure App Services manages pools of Windows Web Servers to host your web application, as an alternative to managing your own web server on your own Azure Compute VMs or other servers.

Does Azure AD use SAML or OAuth?

Azure Active Directory (Azure AD) supports all OAuth 2.0 flows.


1 Answers

There are several scenarios Azure AD supports, depend on what you use Azure AD for. Basically, to access the resources via Azure AD from PHP web application, you can refer to Web Application to Web API section to understand this scenario and get started.

To integrate Azure AD in PHP web applications, we need to follow authorization code grant flow steps to build several custom HTTP requests. E.G. To get access token via OAuth 2.0 protocol, we should refer to the steps on Authorization Code Grant Flow, generally, we will build 2 HTTP requests to get access token:

1,Request an authorization code enter image description here

The build-up URL will redirect to the sso page, after login we can get the code value which will be used in next step.

2,Use the Authorization Code to Request an Access Token: enter image description here

Then we can use the access token to add the JWT string with a “Bearer” designation in the Authorization header of the request to the resource web API.

Here is a PHP test project provided by Azure for your reference.

like image 172
Gary Liu Avatar answered Sep 23 '22 18:09

Gary Liu