【问题标题】:Spring Boot Security CAS Authentication IntegrationSpring Boot 安全 CAS 认证集成
【发布时间】:2021-01-17 13:45:43
【问题描述】:

我急需帮助。因此,作为先决条件,我的任务是创建一个简单的 Web 应用程序。应用程序要求是创建一个简单的 Web 表单,用于收集用户数据,然后向刚刚提供信息的用户发送电子邮件验证。该项目的难点在于 CAS 与 Marist College CAS 认证系统的集成。这个项目的一个要求是我使用 Spring Boot 来创建项目。目前我已经实现了 Spring Security 来对用户进行身份验证。我一直在尝试在线将 CAS 与我现有的项目集成。我希望 StackOverflow 上的人可能对如何将 CAS 与 SpringSecurtiy 集成有更多的知识。另外请不要对我苛刻,在这个项目之前我从未使用过 spring 框架,这对我来说是全新的。 CAS 服务器的 URL 是“https://login.marist.edu/cas/”。我研究了https://github.com/apereo/java-cas-client spring 支持我只是不知道如何将它与我当前的应用程序集成。提前感谢任何帮助我的人。

【问题讨论】:

  • 我认为this section 非常简单。您添加 maven 或 gradle 依赖项,使用 @EnableCasClient annotation 注释 Spring Boot 应用程序(或任何 @Configuration 类)并提供与 cas 相关的应用程序属性。如果您提供您的努力及其结果,会更容易为您提供帮助。
  • @leopal 这正是我所缺少的。感谢您的帮助,一旦我完成配置,我将使用我的代码发布此问题的详细答案。

标签: java spring spring-boot spring-security cas


【解决方案1】:

正如我之前所说,我将为我在将 Spring 应用程序与 Marist CAS 2.0 身份验证系统集成的过程中遇到的问题提供解决方案。如上所述,有一个可以使用的 Spring Boot AutoConfiguration。虽然这可能不是保护您的应用程序的最佳方法,但它满足了我对我正在从事的项目的需求。使用 CAS 2.0 配置 Spring 应用程序的步骤如下。

  1. 添加 Maven 依赖项

马文:

<dependency>
   <groupId>org.jasig.cas.client</groupId>
   <artifactId>cas-client-support-springboot</artifactId>
   <version>${java.cas.client.version}</version>
</dependency>
  1. 在 Spring Boot 的 application.properties 或 application.yml 中添加以下所需属性
cas.server-url-prefix=https://cashost.com/cas
cas.server-login-url=https://cashost.com/cas/login
cas.client-host-url=https://casclient.com

3)用@EnableCasClient注解注解Spring Boot应用程序(或任何@Configuration类)

@SpringBootApplication
@Controller
@EnableCasClient
public class MyApplication { .. }

4)对于 CAS3 协议(身份验证和验证过滤器) - 如果未指定,则为默认值

cas.validation-type=CAS3

对于 CAS2 协议(身份验证和验证过滤器)

cas.validation-type=CAS

对于 SAML 协议(身份验证和验证过滤器)

cas.validation-type=SAML 

【讨论】:

  • 在spring boot中是否需要spring验证过滤器?
猜你喜欢
  • 1970-01-01
  • 2018-09-07
  • 2018-05-19
  • 2021-01-12
  • 2014-09-11
  • 1970-01-01
  • 1970-01-01
  • 2020-11-28
  • 2019-03-10
相关资源
最近更新 更多