PHPackages                             james-machouk/azure-ad-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. james-machouk/azure-ad-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

james-machouk/azure-ad-auth
===========================

it's an easy and simple way to integrate azure active directory login with laravel auth

1.4.0(5y ago)72531MITPHP

Since Apr 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/James-Machouk/azure-ad-auth)[ Packagist](https://packagist.org/packages/james-machouk/azure-ad-auth)[ RSS](/packages/james-machouk-azure-ad-auth/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

Azure Active Directory Auth for Laravel
=======================================

[](#azure-active-directory-auth-for-laravel)

it's an easy and simple way to integrate azure active directory login with Laravel auth. this package replaces the default login/registration logic with OAuth2 and adds a user authenticity check with your Azure AD.

you can activate or deactivate this package without losing any Laravel Auth default functionality.

Installation
------------

[](#installation)

- This package uses Laravel default auth, if you don't have it, please refer to this [documentation](https://laravel.com/docs/7.x/authentication)
- you need to have "name, email, password" field on your "Users" database table

Use the package manager [composer](https://getcomposer.org/doc/00-intro.md/) to install azure-ad-auth.

```
composer require james-machouk/azure-ad-auth
```

Usage
-----

[](#usage)

publish the package with artisan

```
php artisan vendor:publish --provider="JamesMachouk\azureAdAuth\AzureAdAuthServiceProvider"
```

add this lines to you .env file

```
AZURE_AD_TENANT_ID="your ad tenant id"
OAUTH_APP_ID="your app id"
OAUTH_APP_PASSWORD="your app password"
OAUTH_REDIRECT_URI=https://[YOUR DOMAIN]/callback
OAUTH_SCOPES='openid profile offline_access user.read calendars.read'
OAUTH_AUTHORITY=https://login.microsoftonline.com/
OAUTH_AUTHORIZE_ENDPOINT=/oauth2/v2.0/authorize
OAUTH_TOKEN_ENDPOINT=/oauth2/v2.0/token
OAUTH_REDIRECT_AFTER_LOGOUT_URI=https://[YOUR DOMAIN]/anyroute
OVERRIDE_DEFAULT_LOGIN=true
```

- **AZURE\_AD\_TENANT\_ID** / **OAUTH\_APP\_ID** / **OAUTH\_APP\_PASSWORD** : you'll find all this params in you Azure AD dashboard.
- **OAUTH\_REDIRECT\_URI** : this is the callback uri set on your azure dashboard, if you are on dev envirenement with localhost, then your URI will be **.
- **OAUTH\_SCOPES** : refer to this [documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent).
- **OAUTH\_AUTHORITY** / **OAUTH\_AUTHORIZE\_ENDPOINT** / **OAUTH\_TOKEN\_ENDPOINT** : this paths are given by microsoft, do not change them unless microsoft changes them.
- **OAUTH\_REDIRECT\_AFTER\_LOGOUT\_URI** : The URL that the user is redirected to after successfully signing out. If the parameter isn't included, the user is shown a generic message that's generated by the Microsoft identity platform endpoint. This URL must match one of the redirect URIs registered for your application in the app registration portal.
- **OVERRIDE\_DEFAULT\_LOGIN** : this params is to activate or deactivate the package

after publishing, you'll find a new config file *azureAdAuth.php*

```
//set you User model correct path
  "user_model" => App\User::class,
//this is where to redirect users if theirs login succeed ( user route name only )
  "redirect_success" => "home",
//this is where to redirect users if theirs login fails
  "redirect_fail" => "/",
```

go to your *routes/web.php* and remove

```
Auth::routes();
```

don't forget to put it back if you deactivate the Aazure AD package, or you can just replace it with this simple condition

```
if(!env('OVERRIDE_DEFAULT_LOGIN')){
    Auth::routes();
}
```

\###Loggin out this package isn't overriding the laravel's logout function, this is why you need to logout from laravel first and then call the adLogout function shipped with this package. the function has a reserved route name ( 'adLogout' ) you can call it like this :

```
return redirect()->route('adLogout');
//if you are using your own logout method just add this line at the end or after your function.
```

If you are using the built-in laravel's logout method just override the "loggedOut" function in App\\Http\\Controllers\\Auth\\LoginController by adding this at the end of your class

```
public function loggedOut(Request $request)
{
    return redirect()->route('adLogout');
}
// this function is called by the default laraval's logout method
```

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~273 days

Total

2

Last Release

1937d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2028538?v=4)[James Machouk](/maintainers/James-Machouk)[@James-Machouk](https://github.com/James-Machouk)

---

Top Contributors

[![James-Machouk](https://avatars.githubusercontent.com/u/2028538?v=4)](https://github.com/James-Machouk "James-Machouk (10 commits)")

### Embed Badge

![Health badge](/badges/james-machouk-azure-ad-auth/health.svg)

```
[![Health](https://phpackages.com/badges/james-machouk-azure-ad-auth/health.svg)](https://phpackages.com/packages/james-machouk-azure-ad-auth)
```

###  Alternatives

[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
