How to solve shiro unable to authenticate applet request

Shiro cannot authenticate the applet

It’s the first time to do a small program, and the shiro permission problem is stuck. Here is a record of the solution.
On the web page shiro will store a cookie on the page. The cookie stores a JSESSIONID. This JSESSIONID is sent to the page by shiro to authenticate the user but is doing it. I found that other methods were still blocked after the login method was executed in the applet. Later, I found that the applet could not store the cookie, so the JSESSIONID was not stored. So when requesting the method from the background interface, the JSESSIONID could not be brought along. Will be intercepted.
How to solve this problem and solve it in five minutes . First
look at the solution steps.
The applet requests the background login interface. The first time you log in to Shiro, it will return.
Insert picture description hereWe need to get the header and store it in the applet. After each interface call, we will request it. Add this header to the header, then shiro can authenticate the applet

The first step is to write the login interface, the
Insert picture description herenormal shrio login method, here is not how to implement the back-end login

The applet login js
process is to request the login interface shiro to log in and return a login information by itself
console.log(res); print it and you can see it and
then get the header in it and save it in the applet to
Insert picture description here
get this. To get all of it, I only got the set at the beginning The cookie is here to get all of the
Insert picture description herestorage is completed, look at the
Insert picture description hereend of the requested interface .
If you don’t understand, you can add me to WeChat 1485782174

Guess you like

Origin blog.csdn.net/qq_44664329/article/details/108868198