【问题标题】:Spring security - GWT redirect after AuthenticationSpring security - 身份验证后的 GWT 重定向
【发布时间】:2019-03-22 13:57:11
【问题描述】:

我有一个 GWT 应用程序,我正在尝试使用 Spring Security 登录。目前,成功登录后,我被重定向回登录页面。我猜这是因为我的 spring 配置和我缺乏 spring 安全知识。

在我的 spring-security.xml 中,我这样定义我的拦截:

 <security:http auto-config="true">

    <security:intercept-url pattern="/login" access="permitAll" />
    <security:intercept-url pattern="/**" access="isAuthenticated()" />

    </security:http>

我猜测问题出在 access=isAuthenticated() 上,但我不确定。我希望它重定向到 gwt 页面/应用程序,它将根据返回的角色处理视图。我用这种方法制作了一个非常简单的 gwt 应用程序,并且成功了。

我使用的是 Spring 生成的登录页面,而不是 JSP。

spring-security.xml

<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:b="http://www.springframework.org/schema/beans"
       xmlns:security="http://www.springframework.org/schema/security"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">


    <!-- This is where we configure Spring-Security  -->
    <security:http auto-config="true">

    <security:intercept-url pattern="/login" access="permitAll" />
    <security:intercept-url pattern="/**" access="isAuthenticated()" />

    </security:http>

    <b:bean id="graplAuthentication" class="com.foo.rim.security.GraplAuthentication"/>

    <security:authentication-manager alias="authenticationManager">
        <security:authentication-provider ref="graplAuthentication" />
    </security:authentication-manager>

</b:beans>

【问题讨论】:

    标签: gwt spring-security


    【解决方案1】:

    事实证明这是两件事。

    1) 我需要添加 user-expressions="true" 以便获取访问权限=

    <security:http auto-config="true" use-expressions="true">
    

    2) 我有一个自定义用户身份验证类,但忘记将 Authenticated 布尔值设置为 true。这两个都让它正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-30
      • 2013-12-04
      • 1970-01-01
      • 2016-05-04
      • 2017-01-02
      • 2015-12-18
      • 2014-04-20
      • 2014-12-13
      相关资源
      最近更新 更多