SSO single sign-on client docking, separation of front and back ends

SSO single sign-on client docking, separation of front and back ends

When the front and back ends are separated, there will be a data forwarding situation if you want to connect to the single sign-on, and the browser needs to save the cookie information, the item encountered is that if the browser does not have the cookie information, it will jump to the login to log in again , So in order to avoid jumping to the login page after single sign-on, I drew this flow chart, which clearly shows the request process of single sign-on in a project separated from front and back ends.
requires attention:

  • http://cas.socmap.org is the address of the single sign-on service.
  • The URL without the /api path is regarded as direct access to the previous address
  • The front-end project can directly access the back-end interface because the path /api/ is added in front of the back-end access interface in the previous project. If the path at the beginning of the url is /api/, nginx will forward the request to the back-end project.
  • If you need a single sign-on system to directly access the back-end interface, you need to add /api to the address of the service callback
  • After logging in to the single sign-on system for the first time, the cas service will 302 jump to the callback address sent with the ticket information.
  • After the back-end project receives the callback request, it will take the data of the ticket in the callback and go to the cas server to verify the validity. If it is valid, you can generate the session and cookie information used in your own system, and visit a redirect page in your previous project to save the user's cookie information in the browser. In this way, the cookie information in your project exists in the browser, and normal page requests can be made.

The user logs into the system for the first time

  • The login verification process adds the process of separating the nginx proxy and the front and back ends, as shown in the following figure: (Please pay attention to the redirect URL)

    Single sign-on front-end separation user login process

  • Similarly, the user exit process is divided into two situations, as shown in the following figure:

    Single sign-on user logout situation


  • From: xaohuihui
  • Hand rubbing is not easy, remember to like it

Guess you like

Origin blog.51cto.com/14612701/2539303