Download the PHP package postiefs/laravel-sso without Composer
On this page you can find all versions of the php package postiefs/laravel-sso. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download postiefs/laravel-sso
More information about postiefs/laravel-sso
Files in postiefs/laravel-sso
Package laravel-sso
Short Description Sign in to a Laravel app through the Postiefs SSO portal (Microsoft Entra ID), with portal-controlled sessions.
License proprietary
Homepage https://github.com/postiefs/laravel-sso
Informations about the package laravel-sso
postiefs/laravel-sso
Sign in to a Laravel app through the Postiefs SSO portal (Microsoft Entra ID). The portal owns the session: this package trusts its launch token, mirrors its deadline, and signs the user out when an administrator ends the session or removes their access. Local logins keep working next to it.
For a Filament panel add postiefs/laravel-filament-sso on top.
Documentation
- Installation: requirements,
.env, the Callback URL, protecting routes, deploying - How it works: the launch token, the session, the check with the portal, fail open
- Configuration: every option
- Users and roles: finding and creating users, who may sign in, roles by event
- Reference: middleware, events, facade, contracts, exceptions, commands, Blade
- Testing: launch tokens and a fake portal in your tests
- Troubleshooting: a sign-in that does nothing, sessions that end too early or never
How it works
Launch token claims: iss=sso-portal, aud=<app id>, exp (about 60s, the token itself), sexp (the session's
absolute deadline, adopted as is and never extended), jti (the portal session id), email, name, sub, roles,
department, groups.
If the portal cannot be reached the user stays signed in (fail open): an outage never locks everyone out.
Install
sso:install publishes config/postiefs-sso.php, prints the .env keys and the Callback URL to register in the portal
(https://your-app.example.com/sso/callback, exactly). A Callback URL that points anywhere else is the usual reason a
sign-in "does nothing"; with postiefs-sso.stray_token.forward on (the default) the package forwards a token that landed on the
wrong page, and logs a warning that names the page.
Single sign-on is off until SSO_APP_ID and SSO_JWT_SECRET are set. Test the connection and the secret:
Use
Protect routes with the sso middleware group (sign in through the portal + the portal's session rules), or only
the session rules on routes that already have your own auth:
In a Blade layout (no Filament) add the browser guard and, on your login page, the button:
Read the portal session anywhere:
Users
postiefs-sso.user decides how the token's email becomes a local user. By default a user is found by email (case insensitive)
or created with a random password; an existing user is never changed, except the columns listed in postiefs-sso.user.sync.
| Setting | |
|---|---|
model, guard, match_on |
the user model, the auth guard, the column matched against the email |
create_missing |
create a user the first time someone signs in |
defaults |
extra attributes of a created user, for example ['status' => 'active'] |
attributes |
column => claim, written when a user is created (columns the table lacks are skipped) |
sync |
column => claim, refreshed on every sign-in |
The package ships no migration and adds no columns to users.
Who may sign in
Extend the resolver and point postiefs-sso.user.resolver at it:
Roles stay local (for example spatie/laravel-permission); the package never applies the portal's roles. Give a new user a starting role with an event:
Events: SsoUserCreated, SsoLoggedIn (with created), SsoSessionEnded (reason: expired, revoked,
unknown_session, a portal denial reason, logout).
Logging
Every line starts with [sso]. Warnings and errors are always written (token rejected, portal unreachable, secret
mismatch, stray token). Set SSO_DEBUG=true to log each step of a sign-in while connecting an app (callback reached,
token accepted, user resolved, redirect target), and SSO_LOG_CHANNEL to send them to their own channel.
Testing your app
Bind a fake Postiefs\Sso\Contracts\PortalClient to fake the portal.
Extending
| Contract | |
|---|---|
Contracts\PortalClient |
talks to the portal (verify the token, check a session) |
Contracts\UserResolver |
identity to local user |
Exceptions: InvalidSsoToken, SsoNotConfigured, and SignInFailed (an HttpException, so Laravel renders the error
page with the right status). Messages live in resources/lang/en/messages.php (php artisan vendor:publish --tag=postiefs-sso-lang).
Tests
All versions of laravel-sso with dependencies
firebase/php-jwt Version ^6.10|^7.0
illuminate/auth Version ^11.0|^12.0|^13.0
illuminate/cache Version ^11.0|^12.0|^13.0
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/routing Version ^11.0|^12.0|^13.0
illuminate/session Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0