rolandshh / laravel-entra-login
Microsoft Entra ID login for Laravel 13: OpenID Connect Authorization Code Flow with PKCE for exactly one tenant, own login view, domain allowlist and optional user provisioning.
Requires
- php: ^8.5
- ext-json: *
- ext-openssl: *
- firebase/php-jwt: ^7.2
- guzzlehttp/guzzle: ^8.5.2
- illuminate/auth: ^13.43
- illuminate/contracts: ^13.43
- illuminate/database: ^13.43
- illuminate/http: ^13.43
- illuminate/routing: ^13.43
- illuminate/support: ^13.43
- illuminate/view: ^13.43
- league/oauth2-client: ^2.10
Requires (Dev)
- larastan/larastan: ^3.15
- laravel/pint: ^1.25
- orchestra/testbench: ^11.3
- phpunit/phpunit: ^12.5.8 || ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-12-04 08:49:42 UTC
README
Microsoft Entra ID login for Laravel 13 applications.
rolandshh/laravel-entra-login signs users in with the OpenID Connect Authorization Code Flow
with PKCE against exactly one configured Entra tenant. The package ships its own login view at
/entra-login, limits sign-ins to an allowlist of e-mail domains, can optionally create unknown
users and permanently links a local user to the Entra identity (tid/oid).
| Composer package | rolandshh/laravel-entra-login |
| Source repository | https://gitlab.com/rolandshh/laravel-entra-login (public) |
| Namespace | RolandShh\EntraLogin\ (PSR-4, src/) |
| Requirements | PHP ^8.5, Laravel ^13.43, PHP extensions json and openssl |
| License | MIT |
Status: under development. No version has been released yet, and the package is not yet listed on Packagist, so
composer requireworks only after the first release.
Requirements
- PHP
^8.5with the extensionsjsonandopenssl - Laravel
^13.43(league/oauth2-client 2.10 needs Guzzle 8, which Laravel allows from 13.26; Composer blocks earlier Laravel 13 releases because of security advisories) - A users table with a unique
emailcolumn and big integerid, and an Eloquent user model, as in a new Laravel application (other key types: see Theentra_identitiestable) - A Microsoft Entra tenant in which you can register an application
- Outgoing HTTPS from the server to
login.microsoftonline.com - A default cache store with atomic locks that all application instances share, for example
database(the Laravel default) orredis; see Replay protection
The package and its repository are public: installing it needs no access token or extra Composer repository.
Installation
Install the package. Laravel discovers the service provider automatically, and the defaults of the configuration are available right away:
composer require rolandshh/laravel-entra-loginCopy the configuration into your application to adjust it there. This copies
config/entra.phponce; running it again never overwrites your changes:php artisan vendor:publish --tag=entra-configCopy the migration for the table
entra_identitiesand run it. Publish it only once: publishing again adds a second copy with a new date.php artisan vendor:publish --tag=entra-migrations php artisan migrateRegister the application in Entra (next section) and set the environment variables (see Configuration).
Open
https://your-app.example/entra-loginand sign in.
Registering the application in Microsoft Entra
In the Microsoft Entra admin center, open App registrations and choose New registration:
- Name: any name your users may see on the consent screen, for example the name of your application.
- Supported account types: Accounts in this organizational directory only (single tenant). The package accepts only tokens of the one configured tenant.
- Redirect URI: platform Web, URL of the callback route, for example
https://your-app.example/entra-login/callback. It must matchENTRA_REDIRECT_URIexactly (scheme, host, port and path).httpis only possible forlocalhostduring development.
After registering:
- Overview: copy the Application (client) ID (
ENTRA_CLIENT_ID) and the Directory (tenant) ID (ENTRA_TENANT_ID). - Certificates & secrets → Client secrets → New client secret: copy the Value (not the
Secret ID) immediately; it is shown only once (
ENTRA_CLIENT_SECRET). Note the expiry date and create a new secret before it expires. - Authentication: the implicit grant and hybrid flow options (access tokens, ID tokens) are not needed; leave them off.
- API permissions: the package requests only the OpenID Connect scopes
openid,emailandprofileand calls no API; the Microsoft Graph permissionUser.Readthat Entra adds by default is not needed. If your tenant does not allow users to consent to applications, an administrator grants consent once (Grant admin consent). - Optional: to admit only selected people, open the application under Enterprise applications, set Properties → Assignment required? to Yes and assign users or groups.
The email claim is required. Entra includes it when the account has an e-mail address (the mail
attribute of the user); accounts without one cannot sign in (missing_email_claim). Check this with
a test account before going live. If an account has a mail attribute but its tokens still lack
the claim, add the optional claim email for the ID token under Token configuration.
Configuration
Set the required values in .env (placeholders, never commit real secrets):
# Directory (tenant) ID of your organization
ENTRA_TENANT_ID=00000000-0000-0000-0000-000000000000
# Application (client) ID of the app registration
ENTRA_CLIENT_ID=00000000-0000-0000-0000-000000000000
# Value of a client secret of the app registration
ENTRA_CLIENT_SECRET=replace-with-the-secret-value
# Absolute URL of the callback route, registered as redirect URI in Entra
ENTRA_REDIRECT_URI=https://your-app.example/entra-login/callback
# E-mail domains whose accounts may sign in (comma-separated)
ENTRA_ALLOWED_DOMAINS=example.com
If you cache the configuration (php artisan config:cache), run it again after changing .env.
All options of config/entra.php:
Key (entra.) | Environment variable | Default | Meaning |
|---|---|---|---|
routes.enabled | ENTRA_ROUTES_ENABLED | true | registers the three package routes; false registers none (see Registering the routes yourself) |
routes.login_path | – | /entra-login | path of the login view |
routes.redirect_path | – | /entra-login/redirect | path that starts the sign-in |
routes.callback_path | – | /entra-login/callback | path of the callback; must be the path of redirect_uri |
tenant_id | ENTRA_TENANT_ID | – (required) | directory (tenant) ID as a GUID; domain names and common, organizations or consumers are rejected |
client_id | ENTRA_CLIENT_ID | – (required) | application (client) ID, a GUID |
client_secret | ENTRA_CLIENT_SECRET | – (required) | client secret value |
redirect_uri | ENTRA_REDIRECT_URI | – (required) | absolute https URL of the callback (http only for localhost) |
allowed_domains | ENTRA_ALLOWED_DOMAINS | empty: nobody may sign in | comma-separated string or array of domains, compared exactly |
create_user_on_login | ENTRA_CREATE_USER_ON_LOGIN | false | creates unknown users of allowed domains |
auth.guard | ENTRA_AUTH_GUARD | web | session guard that signs the user in; its user provider must use the eloquent driver |
auth.redirect_after_login | ENTRA_REDIRECT_AFTER_LOGIN | / | target after sign-in, unless Laravel remembered an intended page |
ENTRA_ROUTES_ENABLED and ENTRA_CREATE_USER_ON_LOGIN accept only true or false; other values
such as 1 or yes are rejected with InvalidConfigurationException instead of being guessed.
Examples:
- Admit two domains:
ENTRA_ALLOWED_DOMAINS="example.com,example.org". Subdomains such assales.example.commust be listed separately. - Only users that an administrator created beforehand: keep
ENTRA_CREATE_USER_ON_LOGIN=false. Unknown accounts are rejected even if their domain is allowed. - Every account of the allowed domains gets access without manual steps:
ENTRA_CREATE_USER_ON_LOGIN=true. - Serve the login under
/login/microsoft: in the publishedconfig/entra.php, setroutes.login_pathto/login/microsoft,routes.redirect_pathto/login/microsoft/startandroutes.callback_pathto/login/microsoft/callback; then setENTRA_REDIRECT_URI=https://your-app.example/login/microsoft/callbackand register this URL in Entra.
Tenant, claims and identity
The package signs in members of exactly one tenant. It derives the endpoints of that tenant from
tenant_id and accepts only ID tokens whose issuer and tid claim belong to it, whose audience is
client_id alone, signed with RS256 by a current key of the tenant. A present azp claim must be
client_id; several audiences are rejected. A present at_hash must match the access token of the
same token response; the claim is optional. It requests the scopes openid email profile:
emailis required: it decides the domain admission, becomes the e-mail address of a created user and links an existing user once. A missing or emptyemailclaim rejects the sign-in; there is no fallback topreferred_username.nameis optional and only used as the display name of a created user.tidandoididentify the account permanently after the first sign-in.subis required and checked, but not stored: within this single-tenant package,tidandoidare the permanent key.
Signing in
Link to the login view from your application, for example on your existing login page:
<a href="{{ route('entra.login') }}">Sign in with Microsoft</a>
/entra-login shows a page with the button Sign in with Microsoft. It leads to Microsoft, where
the user signs in (and consents on first use, if required), and then back to the callback. On
success the user is signed in and lands on the intended page or on entra.auth.redirect_after_login.
On failure the login page shows a short message and the reason is logged (see
What happens on sign-in and Troubleshooting).
Routes, handlers and login view
Package routes
With entra.routes.enabled set to true (default) the package registers three routes in the web
middleware group:
| Method | Default path | Name | Handler | Purpose |
|---|---|---|---|---|
| GET | /entra-login | entra.login | ShowLoginPage | shows the login view |
| GET | /entra-login/redirect | entra.redirect | RedirectToEntra | starts the sign-in at Entra |
| GET | /entra-login/callback | entra.callback | HandleEntraCallback | completes the sign-in |
The handlers live in RolandShh\EntraLogin\Http\Controllers. Change the paths with
entra.routes.login_path, redirect_path and callback_path; the route names keep the prefix
entra.. The callback URL must match a redirect URI of the Entra app registration exactly, and
entra.redirect_uri must be that same absolute URL, for example
https://app.example.com/entra-login/callback. The package registers no logout route; signing out
stays with your application and does not sign the user out of Entra (see Signing out).
Registering the routes yourself
Set ENTRA_ROUTES_ENABLED=false (or entra.routes.enabled to false) and the package registers no
routes at all. Register the public handlers in your own route file instead, for example to add a
prefix or middleware. Keep the web middleware (the session binds the sign-in to the callback)
and the route names entra.login, entra.redirect and entra.callback, which the handlers and
the view use:
use RolandShh\EntraLogin\Http\Controllers\HandleEntraCallback;
use RolandShh\EntraLogin\Http\Controllers\RedirectToEntra;
use RolandShh\EntraLogin\Http\Controllers\ShowLoginPage;
Route::middleware('web')->prefix('sso')->name('entra.')->group(function () {
Route::get('/', ShowLoginPage::class)->name('login');
Route::get('/start', RedirectToEntra::class)->name('redirect');
Route::get('/callback', HandleEntraCallback::class)->name('callback');
});
Here the redirect URI is https://app.example.com/sso/callback.
What happens on sign-in
entra.redirectstores state, nonce and PKCE verifier together with the start time in the session and sends the browser to the authorization endpoint of the configured tenant. A new start replaces an unfinished one, so only the most recently started sign-in of a session can complete.entra.callbackremoves the stored values from the session, checks the state, rejects a sign-in started more than 10 minutes ago and claims the sign-in once in the cache store (see Replay protection and Security). Only then it redeems the code, validates the ID token and finds or creates the local user (see below).- On success the user is signed in with the configured guard (
entra.auth.guard, defaultweb), the session ID is regenerated and the browser goes to the page Laravel remembered as intended, otherwise toentra.auth.redirect_after_login(default/). On rejection nobody is signed in. The browser returns to
entra.login, which shows a generic message ("cancelled" if the user cancelled at Entra). The reason is reported through Laravel's exception handler as aRolandShh\EntraLogin\Exceptions\EntraLoginExceptionwhose log context containsentra_login_reason(for exampledomain_not_allowedornonce_mismatch). Neither the message nor the log contains the client secret, code, tokens, state, nonce or verifier. To change the log level, use Laravel's exception configuration, for example inbootstrap/app.php:->withExceptions(function (Exceptions $exceptions) { $exceptions->level(\RolandShh\EntraLogin\Exceptions\EntraLoginException::class, \Psr\Log\LogLevel::INFO); })
Missing or invalid settings never admit anyone: the request fails with
RolandShh\EntraLogin\Exceptions\InvalidConfigurationException (HTTP 500), whose message names the
setting but not its value. An invalid entra.routes.enabled stops the application while booting.
Login view and translations
/entra-login renders the package view entra-login::login; it does not change any login view of
your application. To customize it, create resources/views/vendor/entra-login/login.blade.php in
your application. Laravel prefers this file, and package updates never touch it. The view receives
$redirectUrl (the URL of entra.redirect that starts the sign-in), $error (null,
"cancelled" or "failed"), $texts (the translated title, heading, intro, button and
error, the latter null without error) and $locale.
The texts are available in English and German. Override them in
lang/vendor/entra-login/{locale}/login.php.
Security
The package implements one narrow case: the Authorization Code Flow with PKCE (S256) for one fixed Entra tenant. Its checks follow OpenID Connect Core 1.0, RFC 8725 (JWT best current practices), RFC 7517 (JWK) and RFC 9700 (OAuth 2.0 security best current practice). None of them can be turned off, and every failure rejects the sign-in (fail closed); nobody is signed in and the reason is logged without secrets.
| Area | Rule | Rejection |
|---|---|---|
| Sign-in transaction | state, nonce and PKCE verifier together in the session of the starting browser | missing_authorization_state, state_mismatch |
| valid for 10 minutes | authorization_expired | |
| completes once, also for parallel callbacks on several instances | authorization_replayed, state_store_unavailable | |
| Signature | algorithm allowlist IdTokenValidator::ALLOWED_ALGORITHMS = RS256; the header cannot add one | unsupported_algorithm |
critical header parameters (crit) are not supported | malformed_token | |
key only from the tenant's JWKS endpoint, never from the header (jwk, jku, x5u, x5c) | unknown_signing_key, invalid_signature | |
| key ID unique in the key set | ambiguous_signing_key | |
key suits the algorithm: kty RSA; use sig, key_ops with verify and alg RS256 when present; at least 2048 bits | unsuitable_signing_key | |
| Token binding | iss and tid of the configured tenant | issuer_mismatch, tenant_mismatch |
aud contains the client ID and no other audience; no additional audience is trusted | audience_mismatch | |
several audiences require azp; a present azp is the client ID | missing_claim, authorized_party_mismatch | |
nonce of the pending sign-in | nonce_mismatch | |
a present at_hash matches the access token of the same token response; the claim is optional | access_token_hash_mismatch | |
exp, nbf, iat with 60 seconds tolerance | token_expired, token_not_yet_valid | |
sub, oid and email present | missing_claim, missing_email_claim |
Replay protection
A sign-in is one short transaction. State, nonce and PKCE verifier belong together and live only in
the session of the browser that started it, so they cannot be exchanged between browser sessions or
sign-in attempts. A sign-in expires after 10 minutes
(AuthorizationCodeFlow::AUTHORIZATION_LIFETIME_SECONDS).
The first callback with the matching state claims the sign-in with an atomic lock in the application's default cache store; every other callback of the same sign-in is rejected, even if it arrives at the same moment at another application instance. The lock name contains only a SHA-256 hash of the state, and the lock expires with the sign-in. Therefore the store must offer atomic locks shared by all instances:
| Default cache store | Behavior |
|---|---|
database, redis, memcached, dynamodb | supported; use one store that all instances reach |
file | supported on a single server only |
array | only in unit tests (APP_ENV=testing); elsewhere every request fails with InvalidConfigurationException |
null or a store without locks | every request fails with InvalidConfigurationException |
If the store fails during the callback, the sign-in is rejected (state_store_unavailable); it never
proceeds without the claim.
Signing keys
The signing keys come from https://login.microsoftonline.com/{tenant}/discovery/v2.0/keys and are
cached for 24 hours in the default cache store. A token with an unknown key ID (key rotation) makes
the package load the key set once more, at most every 5 minutes; a key ID that is still unknown
afterwards rejects the sign-in. Keys that are ambiguous or do not suit the algorithm never trigger
a reload.
Outside the scope of this package
Role or group mapping, other identity providers, several tenants, MFA policies and every logout at Entra (RP-initiated, front-channel and back-channel logout; see Signing out) are not part of the package.
Users and Entra identities
Who may sign in
Every sign-in, including that of an already linked user, requires the domain of the validated
email claim to be on the allowlist (allowed_domains). Domains are compared exactly after
trimming and lower-casing: example.com admits jane@example.com, but not jane@sub.example.com
or jane@example.com.evil.test. List every domain, including subdomains, explicitly. An empty
allowlist admits nobody.
How a local user is found
- Linked account: the stored combination of tenant ID (
tid) and object ID (oid) inentra_identitiesidentifies the user. The user is loaded through the user provider of the configured guard; if the provider no longer returns it, the sign-in is rejected. - First link: without a stored link, a local user whose
emailequals the normalized address (ignoring upper and lower case) is linked once. The sign-in is rejected if that user is already linked to another Entra account or if several local users match the address. - New user: without a matching local user, a user is created only if
create_user_on_loginis enabled (default: disabled). Otherwise the sign-in is rejected.
No other claim (preferred_username, upn, name) is ever used to find or link a user.
Rejections are RolandShh\EntraLogin\Exceptions\LoginNotPermittedException with the reasons
DomainNotAllowed, UserNotProvisioned, IdentityConflict or LinkedUserUnavailable.
Created users
A new user is an instance of the user provider's model and receives only these attributes:
email: the normalized address (trimmed, lower case). Keep the unique index onusers.emailof the default users table: it ensures that two Entra accounts with the same address can never create two users, even when they sign in at the same moment;name: thenameclaim, only if the users table has anamecolumn and the token contains the claim (shortened to 255 characters);password: a random value hashed with Laravel's configured hasher; the plain value is never stored, returned or logged.
email_verified_at is not set: an Entra sign-in alone does not mark the address as verified.
Attributes are set directly, so $fillable and $guarded do not matter. Creating the user and
storing its Entra identity happen in one database transaction; two parallel first sign-ins of the
same account result in one user and one link.
The default Laravel users table declares name as non-nullable. Entra includes the name claim
when the profile scope is requested; if your tokens lack it, make the column nullable. Any other
required column without a default must be filled by your application, for example in a creating
model event, or the user cannot be created.
The entra_identities table
Publish the migration once and run it; the package never runs migrations itself. Publishing again adds a second copy with a new date, which would fail because the table exists; delete such a copy.
php artisan vendor:publish --tag=entra-migrations
php artisan migrate
| Column | Type | Meaning |
|---|---|---|
id | big integer | primary key |
user_id | big integer, unique | foreign key to users.id, deleted together with the user |
tenant_id | string(36) | tid claim (lower-case GUID) |
object_id | string(36) | oid claim (lower-case GUID) |
created_at, updated_at | timestamps |
A unique index on (tenant_id, object_id) links each Entra account to at most one user; the unique
user_id links each user to at most one Entra account. The users table itself is not changed. If
your users table is not named users or does not use the default big integer id (for example
UUID or ULID keys), adjust user_id in the published migration before running it.
E-mail changes and the limit of the first link
After the first link, only tid/oid identify the user. A changed address in Entra neither
creates a new user nor changes users.email; the package does not synchronize profile data. The
allowlist still applies to the current email claim, so moving an account to a domain that is not
allowed blocks its sign-in. Changing users.email locally does not affect an existing link. To
remove a link, delete the user's row in entra_identities; the next sign-in links again by e-mail
address.
The first link trusts that the Entra account with a given address belongs to the local user with
the same address. Whoever controls an Entra account in the configured tenant with an allowed domain
and the address of a not yet linked local user takes over that user on the first sign-in. Entra
does not guarantee that the email claim is verified (for example for guest accounts or addresses
set by administrators). Therefore allow only domains that your tenant owns, restrict who may set
e-mail addresses in the tenant, and consider requiring user assignment for the Entra application.
Troubleshooting
Errors at Microsoft appear on Microsoft's page before the user returns. Rejections after the return
show a short message on /entra-login; the log entry of the reported EntraLoginException
carries the reason in the context key entra_login_reason.
| What you see | Likely cause | What to do |
|---|---|---|
Microsoft: AADSTS50011 (redirect URI mismatch) | ENTRA_REDIRECT_URI differs from the redirect URI of the app registration | register exactly the same URL (scheme, host, port, path) or correct the variable |
Microsoft: AADSTS700016 (application not found) | wrong ENTRA_CLIENT_ID or ENTRA_TENANT_ID | copy both IDs from the overview of the app registration |
Microsoft: AADSTS50020 (account not in tenant) | the account belongs to another tenant | only members (and invited guests) of the configured tenant can sign in |
HTTP 500, InvalidConfigurationException | a setting is missing or invalid, or the default cache store cannot claim sign-ins | the message names the setting, for example "entra.client_secret", or the cache driver; see Replay protection |
provider_error with (OAuth error "invalid_client") | wrong or expired client secret, or the Secret ID was used instead of the Value | create a new client secret and set its value |
provider_error with another OAuth error, for example invalid_grant | the code was already used or has expired | start the sign-in again |
provider_unavailable | no outgoing HTTPS to login.microsoftonline.com, timeout (5 s connect, 10 s total) or Entra error | check firewall and proxy, try again |
missing_authorization_state or state_mismatch | the session of the start was not available at the callback | open the application on the same host as ENTRA_REDIRECT_URI (also www and https), do not set SESSION_SAME_SITE=strict, check SESSION_DOMAIN and the session driver; a second tab or the back button replaces or consumes the pending sign-in |
authorization_expired | more than 10 minutes passed between the start of the sign-in and the return from Microsoft | start the sign-in again |
authorization_replayed | the callback of this sign-in was already processed, for example by a double submit, a reload or a parallel request | none for the user who is already signed in; otherwise start again. Frequent occurrences without user action can point to an attack |
state_store_unavailable | the default cache store failed while claiming the sign-in | check the cache store (connection, cache_locks table for the database driver) |
authorization_cancelled (message "cancelled") | the user cancelled or declined consent at Microsoft | none, or grant admin consent |
domain_not_allowed | the domain of the e-mail address is not in ENTRA_ALLOWED_DOMAINS | add the domain exactly as used, including subdomains |
user_not_provisioned | no local user with this e-mail address and create_user_on_login is false | create the user or enable user creation |
identity_conflict | the local user is linked to another Entra account, or several users share the address | remove the wrong row in entra_identities or clean up duplicate users |
linked_user_unavailable | the linked user no longer passes the user provider (for example soft-deleted) | restore the user or remove the link |
missing_email_claim or invalid_email_claim | the account has no (valid) e-mail address in Entra | set the mail attribute of the user; if it is set, add the optional claim email (see Registering the application) |
token_expired or token_not_yet_valid | the server clock differs by more than 60 seconds | synchronize the server time (NTP) |
issuer_mismatch, tenant_mismatch, audience_mismatch or authorized_party_mismatch | ENTRA_TENANT_ID or ENTRA_CLIENT_ID does not belong to the app registration, or the token was issued for another application | correct the IDs |
nonce_mismatch, access_token_hash_mismatch, invalid_signature, unknown_signing_key, ambiguous_signing_key, unsuitable_signing_key, unsupported_algorithm, malformed_token, missing_claim, missing_authorization_code or invalid_provider_response | the response cannot be trusted: a manipulated or replayed callback, or an unexpected answer from Entra | start the sign-in again; if it keeps happening for everyone, check the tenant ID and the outgoing connection, and investigate the logs |
| database error while creating a user | a required column of the users table got no value, for example a non-nullable name without name claim | make the column nullable or fill it in a creating model event |
Signing out
Signing out is a matter of your application. Keep or add the logout of your application; the
package adds no logout route, no logout callback and no table for revoked sessions. A Laravel logout
signs the user out of the guard (entra.auth.guard, default web), invalidates the session, which
also gives it a new ID, and renews the CSRF token:
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
Route::post('/logout', function (Request $request) {
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
})->middleware('web')->name('logout');
There are two separate sessions:
| Session | Ended by your logout? |
|---|---|
| Your Laravel application (session cookie) | yes |
The browser's session at Microsoft Entra ID (sign-in at login.microsoftonline.com) | no |
Your logout therefore does not sign the user out of Microsoft 365 or any other application that uses
Entra ID. And while the Entra session is still valid, the next sign-in through /entra-login can
complete without asking for the password again: Microsoft can recognize the browser and send it
straight back to the callback. To end the Entra session as well, the user signs out at Microsoft, for example in
Microsoft 365; that signs them out of every Entra application in this browser.
The package does not support and does not contain any Entra or OpenID Connect logout protocol:
- no RP-initiated logout (the application sends the browser to the
end_session_endpointof Entra), - no front-channel logout (the identity provider loads a logout URL of the application in the browser),
- no back-channel logout (the identity provider notifies the application server directly).
E-mail verification
email_verified_at is never set. If your user model implements MustVerifyEmail and routes use the
verified middleware, users created by the package must still verify their address; whether Entra
users count as verified is a decision of your application.
Updating
composer update rolandshh/laravel-entra-login
Read CHANGELOG.md before updating. Minor and patch versions stay compatible; a new major version describes its upgrade path.
- Your published
config/entra.phpis never changed by an update. Laravel fills in missing top-level options with the package defaults, but not single keys insideroutesorauth: if a later version adds such a key, add it to your file as described in the changelog. - View overrides in
resources/views/vendor/entra-loginand translations inlang/vendor/entra-loginstay as they are. - A published migration is never changed. Schema changes come as new migrations; the changelog says how to publish them.
Using the package in the Account Portal
The Account Portal is the first application that uses this package. Its integration happens in the Account Portal repository once a version has been released; the steps are the same as for any application:
- Make sure the Account Portal runs Laravel 13.43 or newer.
composer require rolandshh/laravel-entra-login, then publish the configuration and the migration and runphp artisan migrate(see Installation).- Register
https://<account-portal-host>/entra-login/callbackas redirect URI in the app registration, one per environment (for example staging and production), and set theENTRA_*variables of each environment. - Set
ENTRA_ALLOWED_DOMAINSand decide onENTRA_CREATE_USER_ON_LOGIN. - Link to
route('entra.login')from the existing login page. The existing login view, login and logout stay unchanged. - Test with a test account: an existing user is linked on the first sign-in, an unknown account is rejected or created as configured, an account of another domain is rejected.
Versioning and releases
The package follows Semantic Versioning. The public contract consists of the
package name, the namespace, the configuration keys and their defaults, the publish tags
(entra-config, entra-migrations), the route names and default paths, the view name, the public
handlers, the entra_identities table schema and the public exception types. Incompatible changes to
this contract are only released in a new major version with a documented upgrade path.
Versions are Git tags in the form vMAJOR.MINOR.PATCH (for example v1.0.0) on main.
Packagist reads the tags from the public GitLab repository; there is no version field in
composer.json. All changes are recorded in CHANGELOG.md.
Publishing on Packagist (one-time setup)
- Make sure the GitLab project https://gitlab.com/rolandshh/laravel-entra-login is public.
- Sign in at https://packagist.org, choose Submit and enter the repository URL
https://gitlab.com/rolandshh/laravel-entra-login. Packagist reads the package namerolandshh/laravel-entra-loginfromcomposer.json. - Copy your API token from your Packagist profile (Show API Token).
- In GitLab open Settings → Integrations → Packagist, enter your Packagist username and the
API token, keep the server URL
https://packagist.org, enable the push and tag push triggers and save. Test settings sends a test event; the package page on Packagist then shows a recent update time.
After this setup Packagist updates the package automatically on every push and tag push.
Releasing a version
- Make sure the pipeline on
mainis green (composer checkruns the same gates locally). - Move the entries under
[Unreleased]inCHANGELOG.mdto a new section[X.Y.Z] - YYYY-MM-DDand commit the change onmain. Create and push an annotated tag:
git tag -a vX.Y.Z -m "vX.Y.Z" git push origin vX.Y.ZCheck that https://packagist.org/packages/rolandshh/laravel-entra-login lists
vX.Y.Z. A clean Laravel application can then install it without any registry or access configuration:composer require rolandshh/laravel-entra-login
A pushed tag is a public release that third parties can install immediately. It cannot be withdrawn reliably, so release only from a verified state.
Development
composer install
composer check # composer validate, Pint, PHPStan and PHPUnit
GitLab CI runs these gates on every push and fails on the first error: composer validate --strict
and composer audit, Pint, PHPStan with Larastan at level max, the architecture tests
(tests/Architecture: no dependency on the consumer application, dependency directions between
Oidc, Identity, Config and Http, declared runtime dependencies, no helpers of
laravel/framework) and all tests with the newest and with the lowest allowed dependency versions.
Tests use simulated Entra responses and generated keys only; they never contact a real tenant.
License
The MIT License (MIT). See LICENSE.