Download the PHP package ssofy/laravel without Composer
On this page you can find all versions of the php package ssofy/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ssofy/laravel
More information about ssofy/laravel
Files in ssofy/laravel
Package laravel
Short Description Sign users in to Laravel with 9in: OpenID Connect login with PKCE, a `nine` auth guard with local JWT verification for APIs, and verified webhooks.
License MIT
Homepage https://9in.io
Informations about the package laravel
9in for Laravel
Sign users in to your Laravel app with 9in, protect your API with 9in access tokens, and receive verified webhooks.
- Browser sign-in: OpenID Connect authorization code flow with PKCE (
/nine/login,/nine/callback,/nine/logout). The ID token is verified, tokens are kept in the Laravel session and refreshed (with rotation) when they expire. - API tokens:
Authorization: Bearer …is verified locally against your tenant's signing keys (cached in Laravel's cache): no call to 9in per request. nineguard and middleware, scope checks, and aNinefacade.- Webhooks at
/nine/webhook, dispatched as Laravel events.
Requires PHP 8.1+ and Laravel 10, 11, 12 or 13 (Laravel 13 itself needs PHP 8.3+).
Setup
Create an application in the 9in console (Applications → New → Regular web app) with the
redirect URL https://your-app.com/nine/callback and the logout URL
https://your-app.com/, then:
The issuer must use https://; plain http is accepted for
localhost and *.localhost (set NINE_ALLOW_INSECURE_ISSUER=true for other development
hosts). Publish the config with
php artisan vendor:publish --tag=nine:config to change routes, scopes or caching.
Protect pages
| Middleware | Signed out |
|---|---|
nine |
401 JSON |
nine:redirect |
Browsers go to the 9in login and come back; API requests get 401 |
nine:passive |
Continue; auth('nine')->user() is null |
nine.scope:orders:read,orders:write |
403 unless the bearer token has every scope (after nine) |
The nine guard is registered automatically (auth('nine')); nine middleware also makes
it the default guard for the request.
Using your own users table
Add a column holding the 9in user id (nine_id) and point the guard at your provider in
config/auth.php:
auth()->user() is then your Eloquent user (null until you link one, e.g. in a
UserCreated webhook listener or on first sign-in using auth('nine')->claims()).
Protect your API
Tokens must be issued for nine.api.audience (NINE_API_AUDIENCE, defaults to
NINE_AUDIENCE). Nine::verifyAccessToken($token, ['scope' => …]) does the same by hand.
- Every key-library algorithm is accepted: RS256/384/512, PS256/384/512, ES256, ES384,
EdDSA, and HS256/384/512 with the API's shared secret in
NINE_API_SECRET. Only access tokens (typ: at+jwt) are accepted, never ID tokens. - Revocations take effect at once. With client credentials configured (
NINE_CLIENT_ID/NINE_CLIENT_SECRET, or theNINE_MANAGEMENT_*pair), the guard runs in hybrid mode. Each token is checked locally, introspected once, and the answer is cached innine.cache.store(NINE_TOKEN_CACHE_TTL, default 300 s). When/nine/webhookreceivestoken.revoked,session.revokedor auser.*event, it drops the matching answers, so the next request is refused. Subscribe the webhook endpoint to those events. - Opaque access tokens (
9in_at_…) are introspected. - Choosing the mode:
NINE_TOKEN_VERIFICATION=localskips introspection (a revoked token works until it expires);introspectasks 9in on every request. Without client credentials the guard useslocal.
Webhooks
Create an endpoint in the console (Advanced → Webhooks) for
https://your-app.com/nine/webhook and set its signing secret:
Verified events (signature over the raw body and path, at most five minutes old) are
dispatched as 9in/laravel-events classes:
The raw payload ($event->event) is {id, event_type, created_at, tenant, environment, data}, and
data.user is the user the event is about.
Each event is dispatched once: retries and redeliveries of a processed event id are
answered 204 without dispatching again, and a retry that arrives while the first delivery is
still running gets 409 (9in tries again later). If a listener throws, the id is released
and 9in retries. Ids are kept for 3 days in the nine.cache.store cache; use a shared store
(redis, database) when you run several servers. Turn it off with nine.webhook.dedupe.
To receive webhooks on a different route, use the nine.webhook middleware there and read
$request->attributes->get('nine.webhook').
Management API
The application needs management scopes. Set NINE_MANAGEMENT_CLIENT_ID /
NINE_MANAGEMENT_CLIENT_SECRET to use a separate machine-to-machine application.
Keeping users in your own database instead? Add
9in/laravel-server.
Tests
License
The MIT License (MIT). See Cubelet Ltd.
All versions of laravel with dependencies
laravel/framework Version ^10.0 || ^11.0 || ^12.0 || ^13.0
9in/php-sdk Version ^4.0
9in/laravel-events Version ^3.0