Spring Boot安全性CAS认证集成

huangapple go评论66阅读模式
英文:

Spring Boot Security CAS Authentication Integration

问题

我急需帮助。因此,作为先决条件,我被要求创建一个简单的网络应用程序。应用程序的要求是创建一个简单的网络表单,用于收集用户数据,然后向刚刚提供信息的用户发送电子邮件验证。这个项目的困难之处在于与马里斯特学院CAS认证系统的CAS集成。项目的一个要求是我要使用Spring Boot来创建这个项目。目前,我已经实现了Spring Security来对用户进行认证。我一直在尝试在线上的一切方法来将CAS与我的现有项目集成。我希望StackOverflow上的某个人可能对如何将CAS与Spring Security集成有更多的了解。还请不要对我太苛刻,我之前从未使用过Spring框架,这对我来说都是新的。CAS服务器的URL是"https://login.marist.edu/cas/"。我已经研究过https://github.com/apereo/java-cas-client的Spring支持,我只是不知道如何将其与我当前的应用程序集成。提前感谢任何能帮助我的人。

英文:

I am in desperate need of help. So as a prerequisite I am tasked with creating a simple web application. 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. The difficult aspect of this project is CAS Integration with the Marist College CAS authentication system. A requirement of this project was that I use Spring Boot to create the project. At the moment I have already implemented Spring Security to authenticate users. I have been trying everything online to integrate CAS with my existing project. I was hoping that someone on StackOverflow may have more knowledge on how to integrate CAS with 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. The Url of the CAS server is "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. Thank you to anyone in advance that lends me a hand with this.

答案1

得分: 1

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

  1. 添加Maven依赖

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
  1. 使用@EnableCasClient注解注释Spring Boot应用程序(或任何@Configuration类)

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

  2. 对于CAS3协议(认证和验证过滤器)- 如果未指定,默认情况下为CAS3协议

    cas.validation-type=CAS3

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

cas.validation-type=CAS

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

cas.validation-type=SAML
英文:

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. As Stated above there is a Spring Boot AutoConfiguration that can be used. 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.

  1. Add Maven Dependency

Maven:

&lt;dependency&gt;
   &lt;groupId&gt;org.jasig.cas.client&lt;/groupId&gt;
   &lt;artifactId&gt;cas-client-support-springboot&lt;/artifactId&gt;
   &lt;version&gt;${java.cas.client.version}&lt;/version&gt;
&lt;/dependency&gt;
  1. Add the following required properties in Spring Boot's application.properties or 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

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

4)For CAS3 protocol (authentication and validation filters) - which is default if nothing is specified

cas.validation-type=CAS3

For CAS2 protocol (authentication and validation filters)

cas.validation-type=CAS

For SAML protocol (authentication and validation filters)

cas.validation-type=SAML 

huangapple
  • 本文由 发表于 2020年10月2日 03:34:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/64162105.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定