PHPackages                             entegration/laravel-entra-id - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. entegration/laravel-entra-id

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

entegration/laravel-entra-id
============================

Laravel Entra ID Integration

v1.0.3(3mo ago)134MITPHPPHP ^8.2

Since Dec 31Pushed 3mo agoCompare

[ Source](https://github.com/emrahyldz93/laravel-entra-id)[ Packagist](https://packagist.org/packages/entegration/laravel-entra-id)[ RSS](/packages/entegration-laravel-entra-id/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Entra ID Integration
============================

[](#laravel-entra-id-integration)

A Laravel package for seamless Microsoft Entra ID (Azure AD) authentication integration using Laravel Socialite.

Features
--------

[](#features)

- Easy installation via Artisan command
- Configurable user model and database table
- Support for custom claims (e.g., samaccountname, student ID)
- Automatic user registration or restriction
- Flexible configuration through environment variables
- Standard and advanced installation modes

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.0, 11.0, or 12.0
- Laravel Socialite
- Microsoft Entra ID Application

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

[](#installation)

### 1. Install the Package

[](#1-install-the-package)

Add the package to your Laravel project:

```
composer require entegration/laravel-entra-id
```

### 2. Run the Installation Command

[](#2-run-the-installation-command)

Run the installation wizard:

```
php artisan entra:install
```

This command will:

- Publish configuration and migration files
- Guide you through the setup process
- Update your `.env` file with necessary settings
- Optionally run migrations

### 3. Configure Azure AD

[](#3-configure-azure-ad)

Add your Azure AD credentials to your `.env` file:

```
AZURE_CLIENT_ID=your-client-id
AZURE_CLIENT_SECRET=your-client-secret
AZURE_REDIRECT_URI=http://localhost/oauth/login
AZURE_TENANT_ID=your-tenant-id
```

### 4. Set Up Azure AD Application

[](#4-set-up-azure-ad-application)

1. Go to [Azure Portal](https://portal.azure.com)
2. Navigate to Azure Active Directory &gt; App registrations
3. Create a new registration or use an existing one
4. Add a redirect URI: `http://your-domain/oauth/login`
5. Note your Application (client) ID, Directory (tenant) ID, and create a client secret

Configuration
-------------

[](#configuration)

The package configuration is stored in `config/entra.php`. You can customize the following settings:

### Environment Variables

[](#environment-variables)

```
# Model and Table Configuration
ENTRA_MODEL=App\Models\User
ENTRA_TABLE=users
ENTRA_IDENTIFIER=email

# Column Names
ENTRA_COL_ID=entra_id
ENTRA_COL_TOKEN=entra_token
ENTRA_COL_EMAIL=email
ENTRA_CUSTOM_COLUMN=dir_username
ENTRA_CUSTOM_CLAIM=samaccountname

# Routes
ENTRA_ROUTES_MIDDLEWARE=web

# Auto Registration
ENTRA_AUTO_REGISTER=true
```

### Configuration Options

[](#configuration-options)

- `table_name`: Database table name (default: `users`)
- `model`: User model class (default: `App\Models\User`)
- `columns`: Column configuration for Azure ID, token, email, and custom fields
- `routes.middleware`: Middleware for authentication routes (default: `web`)
- `auto_register`: Allow automatic user registration (default: `true`)

Usage
-----

[](#usage)

### Routes

[](#routes)

The package automatically registers the following routes:

- `GET /login/microsoft` - Redirects to Microsoft login
- `GET /oauth/login` - Callback route for Azure AD

### Basic Authentication

[](#basic-authentication)

Add a login button to your view:

```

    Login with Microsoft

```

### Custom Redirect After Login

[](#custom-redirect-after-login)

You can customize the redirect URL in `EntraAuthController`:

```
// In callback method
return redirect('/dashboard'); // Change this to your desired route
```

### Custom Claims

[](#custom-claims)

To extract custom claims from Azure AD (e.g., student ID, employee number):

1. Configure the claim name and column in `.env`:

    ```
    ENTRA_CUSTOM_CLAIM=samaccountname
    ENTRA_CUSTOM_COLUMN=dir_username
    ```
2. Ensure the migration includes the custom column (this is handled automatically)
3. The custom data will be automatically saved to the specified column

### Disable Auto Registration

[](#disable-auto-registration)

To restrict login to existing users only:

```
ENTRA_AUTO_REGISTER=false
```

When disabled, users not found in the system will receive a 403 error.

Database Migration
------------------

[](#database-migration)

The package adds the following columns to your users table:

- `entra_id` - Azure AD Object ID (unique)
- `entra_token` - OAuth access token
- `avatar` - User profile picture URL
- `{custom_column}` - Custom data column (if configured)

Run migrations:

```
php artisan migrate
```

Advanced Configuration
----------------------

[](#advanced-configuration)

### Custom User Model

[](#custom-user-model)

If you're using a different user model:

1. Set `ENTRA_MODEL` in `.env`:

    ```
    ENTRA_MODEL=App\Models\Staff
    ```
2. Ensure your model extends `Illuminate\Foundation\Auth\User`

### Custom Table Name

[](#custom-table-name)

To use a different table:

```
ENTRA_TABLE=staff_users
```

### Multiple Custom Claims

[](#multiple-custom-claims)

Currently, the package supports one custom claim. For multiple claims, you may need to extend the `EntraIdService` class.

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

**Issue: "Login Failed" error**

- Verify your Azure AD credentials in `.env`
- Check that redirect URI matches Azure AD configuration
- Ensure the user has appropriate permissions in Azure AD

**Issue: "Your account was not found in the system"**

- Set `ENTRA_AUTO_REGISTER=true` if you want automatic registration
- Or manually create the user account first

**Issue: Custom claim not being saved**

- Verify the claim name exists in your Azure AD token
- Check that the column exists in your database table
- Review the migration file to ensure the column was created

Security Considerations
-----------------------

[](#security-considerations)

- Never commit your `.env` file to version control
- Keep your Azure AD client secret secure
- Use HTTPS in production
- Regularly rotate your Azure AD client secrets
- Review and limit OAuth scopes to minimum required

Support
-------

[](#support)

For issues, questions, or contributions, please open an issue on the package repository.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Author
------

[](#author)

**Emrah Yıldız**

- Email:

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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 ~7 days

Total

3

Last Release

118d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af7adb8afa3897fea6dfc30ecf4808190030b7b11617e82064d2079b7f1e6800?d=identicon)[emrahyldz93](/maintainers/emrahyldz93)

---

Top Contributors

[![emrahyildiz1](https://avatars.githubusercontent.com/u/144919661?v=4)](https://github.com/emrahyildiz1 "emrahyildiz1 (1 commits)")

---

Tags

composer-packagecomposer-packagesentraentra-identraidlaravellaravel-packagelaravel-packagesphp

### Embed Badge

![Health badge](/badges/entegration-laravel-entra-id/health.svg)

```
[![Health](https://phpackages.com/badges/entegration-laravel-entra-id/health.svg)](https://phpackages.com/packages/entegration-laravel-entra-id)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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