This is the SSO (Single Sign-On) Server for Laravel applications. It manages user authentication and securely issues tokens for connected client applications.
📖 Step-by-step tutorial on Medium
Laravel provides solutions for SSO (Single Sign-On) authentication with Laravel Passport , enabling users to access multiple applications with a single set of credentials, making it easy to implement a robust and secure SSO solution.
I shared my solution at this code .
I created 2 Laravel projects and I used Laravel Passport for OAuth2 authorization .
The Auth project — is responsible to allows and centralize those users . The Supervisor project — it is the backend for the adminstrator area for supervisor users .
git clone https://github.com/yourusername/sso-server.git
cd sso-server
composer install
Copy .env.example
and configure:
cp .env.example .env
php artisan key:generate
Update the .env
file with your database and encryption key:
APP_URL=http://sso-server.test
DB_DATABASE=sso
DB_USERNAME=root
DB_PASSWORD=
SSO_ENCRYPTION_KEY=base64:YourGeneratedKeyHere
php artisan migrate --seed
- Provides login and logout endpoints
- Issues encrypted tokens to client apps
- Client apps call a
/user
endpoint with the token to retrieve user data
GET /login
: Login pagePOST /login
: Handles loginGET /logout
: Logs out userPOST /sso/token
: Returns user data based on encrypted token
- Tokens are encrypted using Laravel’s Crypt
- Always use HTTPS in production
- The encryption key must match across all apps
Murilo Livorato
🔗 Medium Article