Download the PHP package entegration/laravel-entra-id without Composer
On this page you can find all versions of the php package entegration/laravel-entra-id. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download entegration/laravel-entra-id
More information about entegration/laravel-entra-id
Files in entegration/laravel-entra-id
Package laravel-entra-id
Short Description Laravel Entra ID Integration
License MIT
Informations about the package laravel-entra-id
Laravel Entra ID Integration
A Laravel package for seamless Microsoft Entra ID (Azure AD) authentication integration using Laravel Socialite.
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
- PHP 8.2 or higher
- Laravel 10.0, 11.0, or 12.0
- Laravel Socialite
- Microsoft Entra ID Application
Installation
1. Install the Package
Add the package to your Laravel project:
2. Run the Installation Command
Run the installation wizard:
This command will:
- Publish configuration and migration files
- Guide you through the setup process
- Update your
.envfile with necessary settings - Optionally run migrations
3. Configure Azure AD
Add your Azure AD credentials to your .env file:
4. Set Up Azure AD Application
- Go to Azure Portal
- Navigate to Azure Active Directory > App registrations
- Create a new registration or use an existing one
- Add a redirect URI:
http://your-domain/oauth/login - Note your Application (client) ID, Directory (tenant) ID, and create a client secret
Configuration
The package configuration is stored in config/entra.php. You can customize the following settings:
Environment Variables
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 fieldsroutes.middleware: Middleware for authentication routes (default:web)auto_register: Allow automatic user registration (default:true)
Usage
Routes
The package automatically registers the following routes:
GET /login/microsoft- Redirects to Microsoft loginGET /oauth/login- Callback route for Azure AD
Basic Authentication
Add a login button to your view:
Custom Redirect After Login
You can customize the redirect URL in EntraAuthController:
Custom Claims
To extract custom claims from Azure AD (e.g., student ID, employee number):
-
Configure the claim name and column in
.env: -
Ensure the migration includes the custom column (this is handled automatically)
- The custom data will be automatically saved to the specified column
Disable Auto Registration
To restrict login to existing users only:
When disabled, users not found in the system will receive a 403 error.
Database Migration
The package adds the following columns to your users table:
entra_id- Azure AD Object ID (unique)entra_token- OAuth access tokenavatar- User profile picture URL{custom_column}- Custom data column (if configured)
Run migrations:
Advanced Configuration
Custom User Model
If you're using a different user model:
-
Set
ENTRA_MODELin.env: - Ensure your model extends
Illuminate\Foundation\Auth\User
Custom Table Name
To use a different table:
Multiple Custom Claims
Currently, the package supports one custom claim. For multiple claims, you may need to extend the EntraIdService class.
Troubleshooting
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=trueif 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
- Never commit your
.envfile 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
For issues, questions, or contributions, please open an issue on the package repository.
License
This package is open-sourced software licensed under the MIT license.
Author
Emrah Yıldız
- Email: [email protected]
All versions of laravel-entra-id with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
laravel/socialite Version ^5.0
socialiteproviders/microsoft-azure Version ^5.0