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>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-client-core</artifactId>
<version>3.1.12</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/cas-client-core-3.1.12.jar</systemPath>
</dependency>
<dependency>
<groupId>edu.yale.its</groupId>
<artifactId>cas-client-java</artifactId>
<version>7.0.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/sso-client-java-7.0.8.jar</systemPath>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.jasig.cas</groupId>-->
<!-- <artifactId>cas-client-core</artifactId>-->
<!-- <version>3.1.12</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/cas-client-core-3.1.12.jar</systemPath>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>edu.yale.its</groupId>-->
<!-- <artifactId>cas-client-java</artifactId>-->
<!-- <version>7.0.8</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/sso-client-java-7.0.8.jar</systemPath>-->
<!-- </dependency>-->
</dependencies>

View File

@ -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!");
}
}

View File

@ -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<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() {

View File

@ -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);
}

View File

@ -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