简体   繁体   English

Spring Boot Security CAS 认证集成

[英]Spring Boot Security CAS Authentication Integration

I am in desperate need of help.我迫切需要帮助。 So as a prerequisite I am tasked with creating a simple web application.因此,作为先决条件,我的任务是创建一个简单的 Web 应用程序。 The application requirements are to create a simple web form that collects user data and then sends an email verification to the user that just provided information.应用程序要求创建一个简单的 Web 表单,用于收集用户数据,然后向刚刚提供信息的用户发送电子邮件验证。 The difficult aspect of this project is CAS Integration with the Marist College CAS authentication system.该项目的难点在于 CAS 与 Marist College CAS 认证系统的集成。 A requirement of this project was that I use Spring Boot to create the project.这个项目的一个要求是我使用 Spring Boot 创建项目。 At the moment I have already implemented Spring Security to authenticate users.目前我已经实现了 Spring Security 来验证用户。 I have been trying everything online to integrate CAS with my existing project.我一直在尝试将 CAS 与我现有的项目集成在一起的所有在线方法。 I was hoping that someone on StackOverflow may have more knowledge on how to integrate CAS with SpringSecurtiy.我希望 StackOverflow 上的某个人可能对如何将 CAS 与 SpringSecurtiy 集成有更多的了解。 Also please don't be harsh on me I have never used the spring framework before this project and this is all new to me.另外请不要对我太苛刻我在这个项目之前从未使用过 spring 框架,这对我来说是全新的。 The Url of the CAS server is "https://login.marist.edu/cas/". CAS 服务器的 URL 是“https://login.marist.edu/cas/”。 I have looked into https://github.com/apereo/java-cas-client spring support I just don't know how to integrate it with my current application.我查看了https://github.com/apereo/java-cas-client spring 支持我只是不知道如何将它与我当前的应用程序集成。 Thank you to anyone in advance that lends me a hand with this.提前感谢任何帮助我解决这个问题的人。

As I previously stated I would provide the solution to the problem that I experienced during the processes of integrating a spring application with the Marist CAS 2.0 Authentication System.正如我之前所说,我将为我在将 Spring 应用程序与 Marist CAS 2.0 身份验证系统集成的过程中遇到的问题提供解决方案。 As Stated above there is a Spring Boot AutoConfiguration that can be used.如上所述,有一个可以使用的 Spring Boot AutoConfiguration。 While this may not be the best method for securing your application it satisfied my needs for the project that I was working on.虽然这可能不是保护您的应用程序的最佳方法,但它满足了我对我正在从事的项目的需求。 The Steps to configure your spring application with CAS 2.0 are bellow.使用 CAS 2.0 配置 Spring 应用程序的步骤如下。

  1. Add Maven Dependency添加Maven依赖

Maven:马文:

<dependency>
   <groupId>org.jasig.cas.client</groupId>
   <artifactId>cas-client-support-springboot</artifactId>
   <version>${java.cas.client.version}</version>
</dependency>
  1. Add the following required properties in Spring Boot's application.properties or application.yml在 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)Annotate Spring Boot application (or any @Configuration class) with @EnableCasClient annotation 3) 使用 @EnableCasClient 注解注解 Spring Boot 应用程序(或任何 @Configuration 类)

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

4)For CAS3 protocol (authentication and validation filters) - which is default if nothing is specified 4) 对于 CAS3 协议(身份验证和验证过滤器)- 如果未指定任何内容,则为默认值

cas.validation-type=CAS3

For CAS2 protocol (authentication and validation filters)对于 CAS2 协议(身份验证和验证过滤器)

cas.validation-type=CAS

For SAML protocol (authentication and validation filters)对于 SAML 协议(身份验证和验证过滤器)

cas.validation-type=SAML 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM