feat: 初步完成调试

This commit is contained in:
wangyu 2024-10-12 16:20:48 +08:00
parent b978c776b5
commit 2f9404ebf7
5 changed files with 31 additions and 22 deletions

28
pom.xml
View File

@ -55,20 +55,20 @@
<artifactId>reactor-test</artifactId> <artifactId>reactor-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.jasig.cas</groupId> <!-- <groupId>org.jasig.cas</groupId>-->
<artifactId>cas-client-core</artifactId> <!-- <artifactId>cas-client-core</artifactId>-->
<version>3.1.12</version> <!-- <version>3.1.12</version>-->
<scope>system</scope> <!-- <scope>system</scope>-->
<systemPath>${project.basedir}/lib/cas-client-core-3.1.12.jar</systemPath> <!-- <systemPath>${project.basedir}/lib/cas-client-core-3.1.12.jar</systemPath>-->
</dependency> <!-- </dependency>-->
<dependency> <!-- <dependency>-->
<groupId>edu.yale.its</groupId> <!-- <groupId>edu.yale.its</groupId>-->
<artifactId>cas-client-java</artifactId> <!-- <artifactId>cas-client-java</artifactId>-->
<version>7.0.8</version> <!-- <version>7.0.8</version>-->
<scope>system</scope> <!-- <scope>system</scope>-->
<systemPath>${project.basedir}/lib/sso-client-java-7.0.8.jar</systemPath> <!-- <systemPath>${project.basedir}/lib/sso-client-java-7.0.8.jar</systemPath>-->
</dependency> <!-- </dependency>-->
</dependencies> </dependencies>

View File

@ -1,16 +1,20 @@
package dev.flyfish.boot.cas.controller; package dev.flyfish.boot.cas.controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.Map;
@RestController @RestController
public class IndexController { public class IndexController {
@GetMapping("/")
public String index() {
return "Hello World!";
}
@GetMapping("/hello") @GetMapping("/hello")
public Object index() { public Object hello() {
return new HashMap<>(); return Map.of("message", "Hello World!");
} }
} }

View File

@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse;
@ -66,7 +67,10 @@ public class CASContext {
} }
Mono<Void> redirect(String url) { Mono<Void> 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() { ServerHttpRequest getRequest() {

View File

@ -193,7 +193,7 @@ public class CASFilter implements WebFilter {
if (StringUtils.hasText(sessionId)) { if (StringUtils.hasText(sessionId)) {
String appId = parameter.casServerName + request.getPath().contextPath().value(); 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); .append("&sessionId=").append(sessionId);
} }

View File

@ -1,5 +1,5 @@
server: server:
port: 8080 port: 8888
spring: spring:
application: application:
@ -9,5 +9,6 @@ cas:
filter: filter:
cas-login: https://sdsfzt.sxu.edu.cn/authserver/login cas-login: https://sdsfzt.sxu.edu.cn/authserver/login
cas-validate: https://sdsfzt.sxu.edu.cn/authserver/serviceValidate 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 cas-init-context-class: dev.flyfish.boot.cas.filter.CASLoginFilter
debug: true