Liferay Authentication with OAuth2 — Complete Guide
Modern applications rarely authenticate users directly.
They delegate authentication to trusted identity providers like Google, Azure AD, or Keycloak using OAuth2.
In Liferay, OAuth2 allows secure Single Sign-On (SSO) across microservices and external apps.
This guide explains how OAuth2 works in Liferay and how to configure it.
📌 What is OAuth2 in Liferay?
OAuth2 enables:
External login (Google / Azure / IdP)
Secure API access
Token-based authentication
Decoupled frontend & backend
Instead of sending passwords → apps exchange access tokens.
🖼️ OAuth2 Authentication Flow
🧠 OAuth2 Roles
| Role | Description |
|---|---|
| Resource Owner | User |
| Client | Liferay |
| Authorization Server | Identity Provider |
| Resource Server | APIs |
🛠 Step 1 — Enable OAuth2 in Liferay
Go to:
Create a new OAuth2 Application.
🛠 Step 2 — Configure Client
Fill:
Name
Client ID
Client Secret
Redirect URI
Example:
🖼️ OAuth2 Configuration
🛠 Step 3 — Configure Identity Provider
Example Keycloak:
Scopes:
🛠 Step 4 — Map User Attributes
Map IdP fields → Liferay user:
| IdP Field | Liferay |
|---|---|
| emailAddress | |
| given_name | firstName |
| family_name | lastName |
🧠 Step 5 — Access Token Usage
After login Liferay receives:
Use token in APIs:
🖼️ Token Example
⚠️ Common Issues
Invalid redirect URI
Must match exactly
User not created
Attribute mapping missing
Login loop
Clock difference between servers
Token rejected
Wrong audience / scope
🔐 Security Best Practices
✔ Use HTTPS only
✔ Short token expiry
✔ Use refresh tokens
✔ Restrict scopes
✔ Sync server time (NTP)
📚 Related Articles
These help build secure enterprise architectures.
🎯 Conclusion
OAuth2 integration makes Liferay enterprise-ready:
Centralized authentication
Secure APIs
Scalable microservices access
Once configured correctly, users can log in seamlessly across all connected applications.
💼 Professional Support Available
If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.
Technologies covered include Java, Spring Boot, PL/SQL, CMS, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).
📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 Website: IT Trainings | Digital metal podium
Comments
Post a Comment