【问题标题】:[Spring-Flex][ACEGI] Error or no security[Spring-Flex][ACEGI] 错误或没有安全性
【发布时间】:2011-01-19 12:48:18
【问题描述】:

正如我在问题标题中所说,我没有成功配置 Spring Security ...... 我已经关注了 James Ward 或 Jettro Coenradie 写的两篇文章,但我仍然没有!

首先,我尝试让所有这些都在一个假项目中运行,并且效果很好,而不是我在“真实”项目中尝试过。 Spring Security的配置文件完全一样,但是实际项目失败了。

我的配置 在 web.xml 中:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/applicationContext.xml</param-value>
</context-param>

...

<filter>  
    <filter-name>springSecurityFilterChain</filter-name>  
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>  
    <filter-name>springSecurityFilterChain</filter-name>  
    <url-pattern>/*</url-pattern>
</filter-mapping>

    ...

<servlet>
    <servlet-name>Spring MVC Servlet Dispatcher</servlet-name>
    <display-name>Spring MVC Servlet Dispatcher</display-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/config/webApplicationContext.xml</param-  value>
        </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

在 applicationContext.xml 中:

<security:global-method-security secured-annotations="enabled" jsr250-annotations="enabled" />

<security:http entry-point-ref="preAuthenticatedEntryPoint">
    <security:anonymous enabled="false"/>
</security:http>

<bean id="preAuthenticatedEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>

<security:authentication-manager>
    <security:authentication-provider>
        <security:user-service>
            <security:user name="arnaud" password="arnaud" authorities="ROLE_USER"/>
        </security:user-service>
    </security:authentication-provider>
</security:authentication-manager>

在 webApplicationContext.xml 中 ceci :

<flex:message-broker>
    <flex:secured />
</flex:message-broker>

在每个 bean 服务中:

<security:intercept-methods>
    <security:protect method="*" access="ROLE_USER" />
</security:intercept-methods>

首先我尝试用注解 @Secured("ROLE_USER") 替换最后一段代码,但没有成功,这就是我使用 security:intercept-methods 和 security:protect 标签的原因。

在我的第一个假项目中,当我启动我的 flex 应用程序(一个检索产品列表的简单数据网格)时,产品没有加载,我调度了一个 FaultEvent,所以 Spring Security 可以工作。

在第二个项目中,真正的项目中,我在部署时出错,告诉我“*”(或尝试时的“findAll”)不是有效的方法名称。

<security:protect method="com.blablabla.UserService.findAll" access="ROLE_USER" />

我不再有这个错误,我可以启动我的 flex 应用程序了。

但是当我启动它时,我的所有用户(是的,在第二个应用程序中我检索的是用户,而不是产品)都加载到了数据网格中!这意味着安全性根本不起作用。

快把我逼疯了!

【问题讨论】:

  • 你使用的是什么版本的 spring/spring-security?

标签: apache-flex security spring spring-security


【解决方案1】:

我本来希望在 &lt;security:http&gt; 元素中看到一些 &lt;security:intercept-url&gt; 元素。

【讨论】:

    猜你喜欢
    • 2011-01-15
    • 2011-07-20
    • 2011-09-06
    • 2013-08-21
    • 2018-02-15
    • 1970-01-01
    • 2017-07-25
    • 2012-08-06
    • 2011-05-30
    相关资源
    最近更新 更多