From 2f9404ebf71b1328857f581008d50fe022377fe4 Mon Sep 17 00:00:00 2001
From: wangyu <727842003@qq.com>
Date: Sat, 12 Oct 2024 16:20:48 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?=
=?UTF-8?q?=E8=B0=83=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 28 +++++++++----------
.../boot/cas/controller/IndexController.java | 12 +++++---
.../flyfish/boot/cas/filter/CASContext.java | 6 +++-
.../flyfish/boot/cas/filter/CASFilter.java | 2 +-
src/main/resources/application.yml | 5 ++--
5 files changed, 31 insertions(+), 22 deletions(-)
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