【问题标题】:How to integrate CAS authentication with spring security?如何将 CAS 认证与 Spring Security 集成?
【发布时间】:2020-12-06 12:02:05
【问题描述】:

我已将 Spring Security 集成到我的项目中,并且我之前使用 hibernate 验证用户详细信息。现在我必须使用 CAS 来完成。 这是我当前的 Spring security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security-3.1.xsd
        ">



    <global-method-security pre-post-annotations="enabled" />

    <http pattern="/css/**" security="none"/>
    <http pattern="/images/**" security="none"/>
    <http pattern="/js/**" security="none"/>
    <http pattern="/index.jsp" security="none"/>
    <http pattern="/app/addNewUser.json" security="none"/>
    <http pattern="/dbcomplogin.jsp" security="none"/>
    <http pattern="/loggedout.jsp" security="none"/>

    <http use-expressions="true">
        <!--
             Allow all other requests. In a real application you should
             adopt a whitelisting approach where access is not allowed by default
          -->
        <intercept-url pattern="/**" access="isAuthenticated()" />
        <form-login login-page='/dbcomplogin.jsp'
          authentication-failure-url="/dbcomplogin.jsp?login_error=1"
          default-target-url="/index.jsp" />
        <logout logout-success-url="/loggedout.jsp" delete-cookies="JSESSIONID"/>
        <remember-me />

    </http>

    <beans:bean id="myUserService" class="com.tcs.ceg.services.impl.UserServiceImpl" />
    <authentication-manager>
    <authentication-provider user-service-ref="myUserService" />
    </authentication-manager>

</beans:beans>

在 UserServiceImpl 类“loadUserByUsername”方法中,我使用 Hibernate 调用从数据库中获取用户详细信息,如果数据库中存在用户名、密码,则返回它们。

但现在我必须使用 CAS server 来完成。请告诉我我需要在 spring-security.xml 中更改的所有内容,这样,如果用户未通过身份验证,则将打开 CAS 服务器的登录页面,并在单击注销时进行单次注销和 CAS 的注销页面服务器将打开。 我是 CAS 和 Spring Security 的新手,请帮助我。

【问题讨论】:

  • 请停止多次发布同一个问题。

标签: java spring-security cas


【解决方案1】:

查看您用于导入 beans 命名空间的别名。如果您的 xml 配置为 xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 将其与别名为 beans:bean

【讨论】:

  • Ya using beans:bean 我在
猜你喜欢
  • 2012-04-06
  • 1970-01-01
  • 2012-04-07
  • 2021-01-17
  • 2010-09-18
  • 1970-01-01
  • 2014-05-16
  • 1970-01-01
  • 2019-06-03
相关资源
最近更新 更多