There are three ways of single sign-on.

1. Login of the parent project and separate verification of the sub-project

First go to the parent project login, get cookies. And then when you access the subproject, you bring a cookie, and the subproject parses and validates against the cookie. Check whether to log in. No cross-domain free boarding. Cookies are not secure. It can be solved by encryption.Copy the code

2. The parent project logs in and the sub-project forwards.

First go to the parent project login, get cookies. Then take cookies with you when you access subprojects. The child project accesses the parent project interface. Bring cookie there. Let the parent project decide whether to log in.Copy the code

3. The parent project logs in and the child project redirects.

First go to the parent project login, get token. Then access the subprojects. Subprojects redirect requests to parent projects with tokens. The parent project determines whether the token is logged in.Copy the code

Simply implement the first way:

Use kisSO middleware. Check it out on Github. Address: https://gitee.com/baomidou/kissoCopy the code

Multiple projects reference the entire middleware.

Multiple projects are configured with the same key and name.

Sso intercepts are added to multiple items.

The parent project has a login interface and a logout interface.

Data cannot be obtained without login

You have logged in to obtain data