laravel maintained by sendity
Sendity Laravel Auth
Laravel host-application integration for Sendity.
composer require sendity/laravel-auth
This package is intentionally not the self-hosted Sendity server. It provides Laravel app glue for consuming hosted or self-hosted Sendity results:
- resolves the configured Sendity server URL;
- validates RS256 result JWTs issued by the Sendity server;
- exposes a stateless
sendityauth guard for Bearer-token requests.
Configuration
Publish the config:
php artisan vendor:publish --tag=sendity-config
Relevant environment variables:
SENDITY_SERVER_URL=https://sendity.io/api/sendity
SENDITY_ISSUER=https://sendity.io
SENDITY_AUDIENCE="${APP_URL}"
SENDITY_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----..."
SENDITY_AUDIENCE should match the public key / app id used when creating auth requests. SENDITY_PUBLIC_KEY accepts either a PEM public key string or a readable file path.
Guard
Register a Laravel guard in your app config:
'guards' => [
'sendity' => [
'driver' => 'sendity',
],
],
Then protect routes with auth:sendity or resolve the guard manually:
$user = Auth::guard('sendity')->user();
$user->identifier; // verified email/phone
$user->identifierType; // email|phone
$user->channel; // email|whatsapp|...
$user->authRequestId; // Sendity auth request id
Boundary
Use sendity/server/laravel / sendity/laravel-server for the self-hosted server package. This package stays on the host-app side and validates the JWT produced by that server.