Easily sign-in and poll users and groups in Microsoft Entra

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/networkrailbusinesssystems/entra

dev-main 2025-12-02 08:43 UTC

This package is auto-updated.

Last update: 2025-12-02 08:44:03 UTC


README

Composer status Coverage status Laravel version PHP version Tests status

Easily sign-in and poll users and groups in Microsoft Entra, built using Laravel Microsoft Graph.

Setup

  1. Install this library using Composer:
    composer require networkrailbusinesssystems/entra
  2. Publish the Entra configuration file using Artisan:
    php artisan vendor:publish --provider="NetworkRailBusinessSystems\Entra\EntraServiceProvider" --tag="entra"
  3. Adjust the entra.php configuration file to suit your needs.
    • sync_attributes will automatically create and update Models to match the details from Entra
    • user_model should be the fully qualified class name of the Model used for Laravel authentication
  4. Implement the EntraAuthenticatable interface on your chosen Model
  5. Add the AuthenticatesWithEntra trait on your chosen Model for a standard fetch and sync setup, or implement the methods yourself
  6. Add the Entra authentication routes to your routes/web.php using the macro:
    Route::entra();
    
    Route::middleware('MsGraphAuthenticated')->group(function () {
        // Your authenticated routes here...
    }
  7. Perform any additional configuration following the Laravel Microsoft Graph documentation

Usage

Users will automatically be redirected to the Microsoft Azure login page whenever they attempt to access an authenticated route as a guest.

The EntraServiceProvider automatically registers the relevant event listeners for authentication.

You can use the Laravel Microsoft Graph library as normal.

Entra helper

Entra::findUser()

Entra::findUsers()

Entra::importUser()

Rules

UserExistsInEntra

Emulator

Entra::emulate()

Manual sign-in and out

You can allow users to manually login by providing a link to the login route.

Users can logout by calling the logout route.

Entra responses

Sample responses are provided in the tests/Data directory.