diff --git a/pom.xml b/pom.xml index 5b0aae6..1034063 100644 --- a/pom.xml +++ b/pom.xml @@ -55,20 +55,20 @@ reactor-test test - - org.jasig.cas - cas-client-core - 3.1.12 - system - ${project.basedir}/lib/cas-client-core-3.1.12.jar - - - edu.yale.its - cas-client-java - 7.0.8 - system - ${project.basedir}/lib/sso-client-java-7.0.8.jar - + + + + + + + + + + + + + + diff --git a/src/main/java/dev/flyfish/boot/cas/controller/IndexController.java b/src/main/java/dev/flyfish/boot/cas/controller/IndexController.java index 3e0d3cf..2041f56 100644 --- a/src/main/java/dev/flyfish/boot/cas/controller/IndexController.java +++ b/src/main/java/dev/flyfish/boot/cas/controller/IndexController.java @@ -1,16 +1,20 @@ package dev.flyfish.boot.cas.controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; +import java.util.Map; @RestController public class IndexController { + @GetMapping("/") + public String index() { + return "Hello World!"; + } + @GetMapping("/hello") - public Object index() { - return new HashMap<>(); + public Object hello() { + return Map.of("message", "Hello World!"); } } diff --git a/src/main/java/dev/flyfish/boot/cas/filter/CASContext.java b/src/main/java/dev/flyfish/boot/cas/filter/CASContext.java index d3f61e3..22b13ee 100644 --- a/src/main/java/dev/flyfish/boot/cas/filter/CASContext.java +++ b/src/main/java/dev/flyfish/boot/cas/filter/CASContext.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; @@ -66,7 +67,10 @@ public class CASContext { } Mono redirect(String url) { - return chain.filter(exchange.mutate().request(builder -> builder.uri(URI.create(url))).build()); + ServerHttpResponse response = exchange.getResponse(); + response.setRawStatusCode(HttpStatus.FOUND.value()); + response.getHeaders().setLocation(URI.create(url)); + return chain.filter(exchange.mutate().response(response).build()); } ServerHttpRequest getRequest() { diff --git a/src/main/java/dev/flyfish/boot/cas/filter/CASFilter.java b/src/main/java/dev/flyfish/boot/cas/filter/CASFilter.java index 411a6a7..8f8b1ce 100644 --- a/src/main/java/dev/flyfish/boot/cas/filter/CASFilter.java +++ b/src/main/java/dev/flyfish/boot/cas/filter/CASFilter.java @@ -193,7 +193,7 @@ public class CASFilter implements WebFilter { if (StringUtils.hasText(sessionId)) { String appId = parameter.casServerName + request.getPath().contextPath().value(); - casLoginString.append("&appId=").append(appId) + casLoginString.append("&appId=").append(URLEncoder.encode(appId, StandardCharsets.UTF_8)) .append("&sessionId=").append(sessionId); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9530c01..abb42bc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8888 spring: application: @@ -9,5 +9,6 @@ cas: filter: cas-login: https://sdsfzt.sxu.edu.cn/authserver/login cas-validate: https://sdsfzt.sxu.edu.cn/authserver/serviceValidate - cas-server-name: 127.0.0.1:8080 + cas-server-name: aef8-218-26-163-214.ngrok-free.app cas-init-context-class: dev.flyfish.boot.cas.filter.CASLoginFilter +debug: true