起源
作为SDUOJ开发组的一员,承担自己的责任与义务,为sduoj添枝加叶。
了解原理
腾哥给我讲了原理,

上面这个图生动形象。
理解了原理,腾哥又发了一些对应的接口,我就开始试着写一写,写这个比gateway限流轻松了很多,不需要查阅很多的文档和看一坨坨的源码(尽管他们写的很好)。
最开始的一版业务基本都写到了Controller层,非常的不健康和不友好,也体现了我菜狗一般的业务逻辑。
后来腾哥跟我说最好抽离一下,为之后接入QQ和微信做准备,然后我就把很多代码都抽离到了server层。
cas验证没什么原理好讲的,就是一条线写下来。
@GetMapping("/xxx")
@ResponseBody
public ResponseResult<UserSessionDTO> sduCasLogin(HttpServletResponse response,
@RequestParam(value = "ticket",required = true) String ticket,
@RealIp String ipv4,
@RequestHeader("user-agent") String userAgent) throws IOException {
//获得学号
HashMap<String,String> map = new HashMap<>();
map.put("service","xxx");
map.put("ticket",ticket);
String id = userService.getDataByMap("对应cas验证网站",map).
split("<cas:ID_NUMBER>")[1].substring(0,12);
return userService.WeatherBinding(id,"cas",response,ipv4,userAgent);
}
@PostMapping("/CasBinding")
@ResponseBody
public ResponseResult<UserSessionDTO> CasBinding(HttpServletResponse response,
@RequestBody @NotNull Map<String, String> json,
@RealIp String ipv4,
@RequestHeader("user-agent") String userAgent) throws ApiException {
return userService.BindingAcount(response,json,ipv4,userAgent);
}
@GetMapping("/CasUnbinding")
@ApiResponseBody
public boolean CasUnbinding(@UserSession UserSessionDTO userSessionDTO) {
return userService
SDUOJ CAS认证集成实践

最低0.47元/天 解锁文章
5264

被折叠的 条评论
为什么被折叠?



