From eef233644cc489f30ce1b1bec1a5279ff5c6316f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 29 Sep 2022 21:26:31 +0800 Subject: [PATCH] 1. 增加 yudao-sso-demo-by-code 项目,实现基于授权码模式的单点登录 2. 完成 yudao-sso-demo-by-code 的跳转 SSO 流程 --- pom.xml | 1 + yudao-example/pom.xml | 21 +++++++++++++++++++++ yudao-example/yudao-sso-demo-by-code/pom.xml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java | 13 +++++++++++++ yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java | 14 ++++++++++++++ yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/SecurityConfiguration.java | 20 ++++++++++++++++++++ yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml | 2 ++ yudao-example/yudao-sso-demo-by-code/src/main/resources/static/login.html | 34 ++++++++++++++++++++++++++++++++++ yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java | 2 +- 9 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 yudao-example/pom.xml create mode 100644 yudao-example/yudao-sso-demo-by-code/pom.xml create mode 100644 yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java create mode 100644 yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java create mode 100644 yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/SecurityConfiguration.java create mode 100644 yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml create mode 100644 yudao-example/yudao-sso-demo-by-code/src/main/resources/static/login.html diff --git a/pom.xml b/pom.xml index 63aa70e..29f18bf 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,7 @@ yudao-module-pay yudao-module-mall yudao-module-visualization + yudao-example ${project.artifactId} diff --git a/yudao-example/pom.xml b/yudao-example/pom.xml new file mode 100644 index 0000000..588b863 --- /dev/null +++ b/yudao-example/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + + cn.iocoder.boot + yudao-example + 1.0.0-snapshot + pom + + yudao-sso-demo-by-code + + + ${project.artifactId} + 提供各种示例,例如说:SSO 单点登录 + https://github.com/YunaiV/ruoyi-vue-pro + + diff --git a/yudao-example/yudao-sso-demo-by-code/pom.xml b/yudao-example/yudao-sso-demo-by-code/pom.xml new file mode 100644 index 0000000..0227d37 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + + + cn.iocoder.boot + yudao-sso-demo-by-code + 1.0.0-snapshot + jar + + ${project.artifactId} + 基于授权码模式,如何实现 SSO 单点登录? + https://github.com/YunaiV/ruoyi-vue-pro + + + + 8 + 8 + UTF-8 + + 2.6.10 + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-security + + + + diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java new file mode 100644 index 0000000..f6b1607 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.ssodemo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SSODemoApplication { + + public static void main(String[] args) { + SpringApplication.run(SSODemoApplication.class, args); + } + +} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java new file mode 100644 index 0000000..8445ff2 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.ssodemo.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; + +@Controller("/auth") +public class AuthController { + + @PostMapping("/login-by-code") + public void loginByCode() { + + } + +} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/SecurityConfiguration.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/SecurityConfiguration.java new file mode 100644 index 0000000..9e92591 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/SecurityConfiguration.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.ssodemo.framework; + +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity httpSecurity) throws Exception { + httpSecurity.authorizeRequests() + // 1. 静态资源,可匿名访问 + .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() + // last. 兜底规则,必须认证 + .and().authorizeRequests() + .anyRequest().authenticated(); + } +} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml b/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml new file mode 100644 index 0000000..a62cf97 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml @@ -0,0 +1,2 @@ +server: + port: 18080 diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/login.html b/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/login.html new file mode 100644 index 0000000..b468d84 --- /dev/null +++ b/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/login.html @@ -0,0 +1,34 @@ + + + + + 首页 + + + + + + + + + +
+ 您未登录,点击 跳转 SSO 单点登录 +
+ + + + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java index 430c3a0..dba7569 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java @@ -34,7 +34,7 @@ public class TenantPackageDO extends BaseDO { */ private String name; /** - * 租户状态 + * 租户套餐状态 * * 枚举 {@link CommonStatusEnum} */ -- libgit2 0.21.4