Search by

rolandshh / laravel-entra-login

rolandshh

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.

Package info

gitlab.com/rolandshh/laravel-entra-login

Issues

pkg:composer/rolandshh/laravel-entra-login

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-12-03 14:49 UTC

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 packagerolandshh/laravel-entra-login
Source repositoryhttps://gitlab.com/rolandshh/laravel-entra-login (public)
NamespaceRolandShh\EntraLogin\ (PSR-4, src/)
RequirementsPHP ^8.5, Laravel ^13.43, PHP extensions json and openssl
LicenseMIT

Status: under development. No version has been released yet, and the package is not yet listed on Packagist, so composer require works only after the first release.

Requirements

  • PHP ^8.5 with the extensions json and openssl
  • 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 email column and big integer id, and an Eloquent user model, as in a new Laravel application (other key types: see The entra_identities table)
  • 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) or redis; see Replay protection

The package and its repository are public: installing it needs no access token or extra Composer repository.

Installation

  1. Install the package. Laravel discovers the service provider automatically, and the defaults of the configuration are available right away:

    composer require rolandshh/laravel-entra-login
    
  2. Copy the configuration into your application to adjust it there. This copies config/entra.php once; running it again never overwrites your changes:

    php artisan vendor:publish --tag=entra-config
    
  3. Copy the migration for the table entra_identities and 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 migrate
    
  4. Register the application in Entra (next section) and set the environment variables (see Configuration).

  5. Open https://your-app.example/entra-login and sign in.

Registering the application in Microsoft Entra

In the Microsoft Entra admin center, open App registrations and choose New registration:

  1. Name: any name your users may see on the consent screen, for example the name of your application.
  2. Supported account types: Accounts in this organizational directory only (single tenant). The package accepts only tokens of the one configured tenant.
  3. Redirect URI: platform Web, URL of the callback route, for example https://your-app.example/entra-login/callback. It must match ENTRA_REDIRECT_URI exactly (scheme, host, port and path). http is only possible for localhost during 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, email and profile and calls no API; the Microsoft Graph permission User.Read that 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 variableDefaultMeaning
routes.enabledENTRA_ROUTES_ENABLEDtrueregisters the three package routes; false registers none (see Registering the routes yourself)
routes.login_path–/entra-loginpath of the login view
routes.redirect_path–/entra-login/redirectpath that starts the sign-in
routes.callback_path–/entra-login/callbackpath of the callback; must be the path of redirect_uri
tenant_idENTRA_TENANT_ID– (required)directory (tenant) ID as a GUID; domain names and common, organizations or consumers are rejected
client_idENTRA_CLIENT_ID– (required)application (client) ID, a GUID
client_secretENTRA_CLIENT_SECRET– (required)client secret value
redirect_uriENTRA_REDIRECT_URI– (required)absolute https URL of the callback (http only for localhost)
allowed_domainsENTRA_ALLOWED_DOMAINSempty: nobody may sign incomma-separated string or array of domains, compared exactly
create_user_on_loginENTRA_CREATE_USER_ON_LOGINfalsecreates unknown users of allowed domains
auth.guardENTRA_AUTH_GUARDwebsession guard that signs the user in; its user provider must use the eloquent driver
auth.redirect_after_loginENTRA_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 as sales.example.com must 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 published config/entra.php, set routes.login_path to /login/microsoft, routes.redirect_path to /login/microsoft/start and routes.callback_path to /login/microsoft/callback; then set ENTRA_REDIRECT_URI=https://your-app.example/login/microsoft/callback and 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:

  • email is required: it decides the domain admission, becomes the e-mail address of a created user and links an existing user once. A missing or empty email claim rejects the sign-in; there is no fallback to preferred_username.
  • name is optional and only used as the display name of a created user.
  • tid and oid identify the account permanently after the first sign-in.
  • sub is required and checked, but not stored: within this single-tenant package, tid and oid are 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:

MethodDefault pathNameHandlerPurpose
GET/entra-loginentra.loginShowLoginPageshows the login view
GET/entra-login/redirectentra.redirectRedirectToEntrastarts the sign-in at Entra
GET/entra-login/callbackentra.callbackHandleEntraCallbackcompletes 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

  1. entra.redirect stores 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.
  2. entra.callback removes 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).
  3. On success the user is signed in with the configured guard (entra.auth.guard, default web), the session ID is regenerated and the browser goes to the page Laravel remembered as intended, otherwise to entra.auth.redirect_after_login (default /).
  4. 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 a RolandShh\EntraLogin\Exceptions\EntraLoginException whose log context contains entra_login_reason (for example domain_not_allowed or nonce_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 in bootstrap/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.

AreaRuleRejection
Sign-in transactionstate, nonce and PKCE verifier together in the session of the starting browsermissing_authorization_state, state_mismatch
valid for 10 minutesauthorization_expired
completes once, also for parallel callbacks on several instancesauthorization_replayed, state_store_unavailable
Signaturealgorithm allowlist IdTokenValidator::ALLOWED_ALGORITHMS = RS256; the header cannot add oneunsupported_algorithm
critical header parameters (crit) are not supportedmalformed_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 setambiguous_signing_key
key suits the algorithm: kty RSA; use sig, key_ops with verify and alg RS256 when present; at least 2048 bitsunsuitable_signing_key
Token bindingiss and tid of the configured tenantissuer_mismatch, tenant_mismatch
aud contains the client ID and no other audience; no additional audience is trustedaudience_mismatch
several audiences require azp; a present azp is the client IDmissing_claim, authorized_party_mismatch
nonce of the pending sign-innonce_mismatch
a present at_hash matches the access token of the same token response; the claim is optionalaccess_token_hash_mismatch
exp, nbf, iat with 60 seconds tolerancetoken_expired, token_not_yet_valid
sub, oid and email presentmissing_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 storeBehavior
database, redis, memcached, dynamodbsupported; use one store that all instances reach
filesupported on a single server only
arrayonly in unit tests (APP_ENV=testing); elsewhere every request fails with InvalidConfigurationException
null or a store without locksevery 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

  1. Linked account: the stored combination of tenant ID (tid) and object ID (oid) in entra_identities identifies 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.
  2. First link: without a stored link, a local user whose email equals 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.
  3. New user: without a matching local user, a user is created only if create_user_on_login is 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 on users.email of 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: the name claim, only if the users table has a name column 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
ColumnTypeMeaning
idbig integerprimary key
user_idbig integer, uniqueforeign key to users.id, deleted together with the user
tenant_idstring(36)tid claim (lower-case GUID)
object_idstring(36)oid claim (lower-case GUID)
created_at, updated_attimestamps

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 seeLikely causeWhat to do
Microsoft: AADSTS50011 (redirect URI mismatch)ENTRA_REDIRECT_URI differs from the redirect URI of the app registrationregister exactly the same URL (scheme, host, port, path) or correct the variable
Microsoft: AADSTS700016 (application not found)wrong ENTRA_CLIENT_ID or ENTRA_TENANT_IDcopy both IDs from the overview of the app registration
Microsoft: AADSTS50020 (account not in tenant)the account belongs to another tenantonly members (and invited guests) of the configured tenant can sign in
HTTP 500, InvalidConfigurationExceptiona setting is missing or invalid, or the default cache store cannot claim sign-insthe 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 Valuecreate a new client secret and set its value
provider_error with another OAuth error, for example invalid_grantthe code was already used or has expiredstart the sign-in again
provider_unavailableno outgoing HTTPS to login.microsoftonline.com, timeout (5 s connect, 10 s total) or Entra errorcheck firewall and proxy, try again
missing_authorization_state or state_mismatchthe session of the start was not available at the callbackopen 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_expiredmore than 10 minutes passed between the start of the sign-in and the return from Microsoftstart the sign-in again
authorization_replayedthe callback of this sign-in was already processed, for example by a double submit, a reload or a parallel requestnone for the user who is already signed in; otherwise start again. Frequent occurrences without user action can point to an attack
state_store_unavailablethe default cache store failed while claiming the sign-incheck the cache store (connection, cache_locks table for the database driver)
authorization_cancelled (message "cancelled")the user cancelled or declined consent at Microsoftnone, or grant admin consent
domain_not_allowedthe domain of the e-mail address is not in ENTRA_ALLOWED_DOMAINSadd the domain exactly as used, including subdomains
user_not_provisionedno local user with this e-mail address and create_user_on_login is falsecreate the user or enable user creation
identity_conflictthe local user is linked to another Entra account, or several users share the addressremove the wrong row in entra_identities or clean up duplicate users
linked_user_unavailablethe 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_claimthe account has no (valid) e-mail address in Entraset 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_validthe server clock differs by more than 60 secondssynchronize the server time (NTP)
issuer_mismatch, tenant_mismatch, audience_mismatch or authorized_party_mismatchENTRA_TENANT_ID or ENTRA_CLIENT_ID does not belong to the app registration, or the token was issued for another applicationcorrect 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_responsethe response cannot be trusted: a manipulated or replayed callback, or an unexpected answer from Entrastart 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 usera required column of the users table got no value, for example a non-nullable name without name claimmake 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:

SessionEnded 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_endpoint of 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.php is never changed by an update. Laravel fills in missing top-level options with the package defaults, but not single keys inside routes or auth: 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-login and translations in lang/vendor/entra-login stay 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:

  1. Make sure the Account Portal runs Laravel 13.43 or newer.
  2. composer require rolandshh/laravel-entra-login, then publish the configuration and the migration and run php artisan migrate (see Installation).
  3. Register https://<account-portal-host>/entra-login/callback as redirect URI in the app registration, one per environment (for example staging and production), and set the ENTRA_* variables of each environment.
  4. Set ENTRA_ALLOWED_DOMAINS and decide on ENTRA_CREATE_USER_ON_LOGIN.
  5. Link to route('entra.login') from the existing login page. The existing login view, login and logout stay unchanged.
  6. 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)

  1. Make sure the GitLab project https://gitlab.com/rolandshh/laravel-entra-login is public.
  2. Sign in at https://packagist.org, choose Submit and enter the repository URL https://gitlab.com/rolandshh/laravel-entra-login. Packagist reads the package name rolandshh/laravel-entra-login from composer.json.
  3. Copy your API token from your Packagist profile (Show API Token).
  4. 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

  1. Make sure the pipeline on main is green (composer check runs the same gates locally).
  2. Move the entries under [Unreleased] in CHANGELOG.md to a new section [X.Y.Z] - YYYY-MM-DD and commit the change on main.
  3. Create and push an annotated tag:

    git tag -a vX.Y.Z -m "vX.Y.Z"
    git push origin vX.Y.Z
    
  4. Check 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.