The new Java project studies online notes -day17 (eight)

3 user exits 3.1 requirements analysis
procedure is as follows:
1, the user clicks the exit pop-up exit confirmation window, click OK to
The new Java project studies online notes -day17 (eight)
the user exits to the following actions:
1. Delete redis the token 2, delete the cookie token
3.2 API
certification services provide external exit interface.
[mw_shl_code = AppleScript, to true]
@ApiOperation ( "exit") public ResponseResult Zimbabwe Logout ();
[/ mw_shl_code]
3.3 server
certification service provider exit interface. 3.3.1 DAO
no.
-Service 3.3.2
[mw_shl_code = AppleScript, to true] // remove the token from redis Boolean delToken public (the access_token String) {
String = name "user_token:" + the access_token;
stringRedisTemplate.delete (name);
return to true;
} [/ mw_shl_code]
3.3.3 the Controller
[mw_shl_code = AppleScript, to true] // exit
@Override
@PostMapping ( "/ userLogout")
ResponseResult Zimbabwe Logout public () {
// remove the identity token
String UID = getTokenFormCookie ();
// delete the redis token
authService.delToken (UID);
// Clear Cookie
clearCookie (UID);
return new new ResponseResult (CommonCode.SUCCESS);
}
// Clear the cookie
Private void clearCookie (String token) {
CookieUtil.addCookie (the Response, cookieDomain, "/", "uid", token, 0, false);
}
[/ mw_shl_code]
3.3.4 release exit URL
certification services default must verify the user's identity information, here you need to withdraw url release.
Rewriting con fi gure (WebSecurity web) method WebSecurityCon fi g class, as follows:

[mw_shl_code=applescript,true]@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/userlogin","/userlogout");
} [/mw_shl_code]

Guess you like

Origin blog.51cto.com/13517854/2425674