Single Sign On For Spring Boot With JWT
Single Sign On
Single Sign On, as known as SSO, means if user success login in one application, then he/she is able to access other applications without login again.
Flow
Assume there are 3 applications : app1
, app2
and authentication
.
Authentication
This application consist of :
- login page
- login controller, if username matches password, generate a
jwt
, create cookie with cookie name and jwt, set cookiedomain
andpath
, eventually add this cookie tohttp servlet response
- redirect to original request
App1
- set authentication login url
- logout function to clear cookie with specified cookie name
- a filter to check the user has login or not, if exist, proceed original request, otherwise redirect login page
App2
For simplicity, App2
is the same as App1
Code
Please refer this for detail
Written on April 14, 2019