huangxiao 1 month ago
commit
4ed8f5325f

+ 24 - 0
pom.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.hosea.cloud.template</groupId>
+    <artifactId>gateway</artifactId>
+    <version>1.0.0</version>
+    <name>Gateway Template ${version}</name>
+    <description>网关模板</description>
+
+    <properties>
+        <hosea-cloud.version>1.0.0</hosea-cloud.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.hosea.cloud</groupId>
+            <artifactId>cloud-gateway-maxkey</artifactId>
+            <version>${hosea-cloud.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 17 - 0
src/main/java/com/hosea/gateway/GatewaySpringApplication.java

@@ -0,0 +1,17 @@
+package com.hosea.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 启动类
+ *
+ * @author hosea
+ * @date 2025-07-16
+ */
+@SpringBootApplication(scanBasePackages = "com.hosea")
+public class GatewaySpringApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(GatewaySpringApplication.class, args);
+    }
+}

+ 61 - 0
src/main/resources/application.yml

@@ -0,0 +1,61 @@
+spring.config.import:
+  - classpath:gateway-maxkey.yml
+---
+#---表示‌文档分隔符‌,在Spring Boot中后续文档块的配置会覆盖前面文档块的同名配置
+
+server.port: 10000
+spring.profiles.active: dev
+spring.application.name: gateway
+
+gateway:
+  # 权限范围里的白名单
+  whiteList:
+    - /.well-known/.*
+  # 支持多种登录方式
+  login:
+    maxkey:
+      # Token的配置
+      token:
+        # URL权限范围,在这个范围下的URL,才会执行该登录方式
+        permissions-scope:
+          - /.*
+          - ${gateway.login.maxkey.local-url.login-call-back}
+          - ${gateway.login.maxkey.local-url.exit}
+          - ${gateway.login.maxkey.local-url.exit-call-back}
+        # jwt签名的密码
+        jwt-signer-password: sewlgioh4578ewrwe7rw68e7r
+      # 本地端的地址
+      local-url:
+        host: http://127.0.0.1:${server.port}
+        # 监听登录回调的接口地址
+        login-call-back: /ss/aa
+      # 服务端的地址
+      service-url.host: http://127.0.0.1
+      registration:
+        client-id: 1138207703596793856
+        client-secret: 8weDMDMwNzIwMjUxNzUyMDkwNDU9rT
+
+spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        namespace: 035dcaf6-f934-4a62-b5cf-83e6fe333fc8
+        # 是否注册,默认为true
+        # true:注册,可发现其它服务和被其它服务发现
+        # true:不注册,可发现其它服务但不被其它服务发现
+        register-enabled: true
+      config:
+        server-addr: 127.0.0.1:8848
+        namespace: 035dcaf6-f934-4a62-b5cf-83e6fe333fc8
+    # 多网络时,首选网络
+    inetutils.preferred-networks:
+      - 10.11
+#    gateway:
+#      routes:
+#        - id: test
+#          uri: lb://service-webmvc
+#          predicates:
+#            - Path=/mvc/**
+#          filters:
+#            - StripPrefix=1

+ 10 - 0
src/main/resources/static/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+test
+</body>
+</html>