Skip to content

Laravel project demonstrating a Single Sign-On (SSO) implementation across multiple applications using Laravel Passport or custom tokens.

Notifications You must be signed in to change notification settings

murilolivorato/laravel_sso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel SSO Server (Auth Provider)

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

Login Page

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 .

What I did

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 .

Login Page


🚀 Setup

1. Clone the repo

git clone https://github.com/yourusername/sso-server.git
cd sso-server

2. Install dependencies

composer install

3. Set up environment

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

4. Run migrations

php artisan migrate --seed

📌 How it Works

  • Provides login and logout endpoints
  • Issues encrypted tokens to client apps
  • Client apps call a /user endpoint with the token to retrieve user data

📂 Key Endpoints

  • GET /login: Login page
  • POST /login: Handles login
  • GET /logout: Logs out user
  • POST /sso/token: Returns user data based on encrypted token

🛡 Security

  • Tokens are encrypted using Laravel’s Crypt
  • Always use HTTPS in production
  • The encryption key must match across all apps

👨‍💻 Author

Murilo Livorato
🔗 Medium Article

📸 Screenshots

Login Page

Login Page

Admin Area

Admin Area

Access Area

Access Area

⭐ Star This Repository ⭐

Your support helps us improve and maintain this project!

GitHub Stars

About

Laravel project demonstrating a Single Sign-On (SSO) implementation across multiple applications using Laravel Passport or custom tokens.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published