diff --git a/src/main/java/com/fujieid/jap/demo/SimpleController.java b/src/main/java/com/fujieid/jap/demo/SimpleController.java index 6f8719d1777381a854e707727d9beef6e4403601..8ff5257ed0abe7ab193db6784aef7040f5fa944c 100644 --- a/src/main/java/com/fujieid/jap/demo/SimpleController.java +++ b/src/main/java/com/fujieid/jap/demo/SimpleController.java @@ -2,6 +2,7 @@ package com.fujieid.jap.demo; import com.fujieid.jap.core.JapConfig; import com.fujieid.jap.core.JapUserService; +import com.fujieid.jap.core.exception.JapUserException; import com.fujieid.jap.simple.SimpleConfig; import com.fujieid.jap.simple.SimpleStrategy; import com.fujieid.jap.sso.config.JapSsoConfig; @@ -39,7 +40,7 @@ public class SimpleController implements InitializingBean { @PostMapping("/login") public void renderAuth(HttpServletRequest request, HttpServletResponse response) { - simpleStrategy.authenticate(new SimpleConfig(), request, response); + simpleStrategy.authenticate(new SimpleConfig("%0PcjotQ8QvfHdB#"), request, response); } @Override @@ -47,14 +48,25 @@ public class SimpleController implements InitializingBean { simpleStrategy = new SimpleStrategy(japUserService, new JapConfig() .setSso(true) .setSsoConfig(new JapSsoConfig() - /* - 将 domain 设置为 .jap.com 报错: - java.lang.IllegalArgumentException: An invalid domain [.jap.com] was specified for this cookie - 参考解决方案: - https://gitee.com/baomidou/kisso/wikis/java.lang.IllegalArgumentException:-An-invalid-domain-%5B.x.com%5D-was-specified-for-this-cookie?sort_id=12454 - 高版本 8.5版本 + tomcat 对 cookie 处理机制变更,原来设置 .x.com 应该修改为 x.com - */ - .setCookieDomain("jap.com"))); + /* + 将 domain 设置为 .jap.com 报错: + java.lang.IllegalArgumentException: An invalid domain [.jap.com] was specified for this cookie + 参考解决方案: + https://gitee.com/baomidou/kisso/wikis/java.lang.IllegalArgumentException:-An-invalid-domain-%5B.x.com%5D-was-specified-for-this-cookie?sort_id=12454 + 高版本 8.5版本 + tomcat 对 cookie 处理机制变更,原来设置 .x.com 应该修改为 x.com + */ + .setCookieDomain("jap.com"))); } + + @GetMapping("/auth") + public void auth(HttpServletRequest request, HttpServletResponse response) { + simpleStrategy.authenticate(new SimpleConfig("%0PcjotQ8QvfHdB#"), request, response); + } + + @GetMapping("/logout") + public String logout(HttpServletRequest request, HttpServletResponse response) { + simpleStrategy.cancelRememberMeCookie(new SimpleConfig("%0PcjotQ8QvfHdB#"), request, response); + return "login"; + } } diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 31b9bf2ea391ed1555424bdbd2c148c7c733c59d..dabcb1e36afffe8359cab31b96adbee5f4e4be28 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -4,6 +4,11 @@