Grails 3 - 没有插件的安全性

时间:2018-04-09 17:51:36

标签: spring grails spring-security

我在不使用插件的情况下在Grails 3.x应用程序上使用SAML实现Spring Security。

我添加了必要的罐子如下:

     compile group: 'ca.juliusdavies', name: 'not-yet-commons-ssl', version: '0.3.17'
     compile 'org.opensaml:opensaml:2.6.0'
     compile 'org.opensaml:openws:1.4.1'
     compile 'org.opensaml:xmltooling:1.3.1'
     compile group: 'org.springframework.security', name: 'spring-security-core', version: '3.2.5.RELEASE'
     compile group: 'org.springframework.security', name: 'spring-security-config', version: '3.2.5.RELEASE'
     compile group: 'org.springframework.security.extensions', name: 'spring-security-saml2-core', version: '1.0.5.BUILD-SNAPSHOT'

我将securitycontext.xml文件集成在resources.groovy中。

beans = {
        importBeans('classpath:security/springSecuritySamlBeans.xml')
}

我需要在我的web.xml中添加以下安全过滤器,但在Grails 3中这是不可能的。任何人都可以建议需要添加这些过滤器以及如何添加它们。

<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>

从我读到的这些过滤器需要在resources.groovy中定义,但我不确定如何完成。

2 个答案:

答案 0 :(得分:2)

  

我需要在我的web.xml中添加以下安全过滤器,但是在   Grails 3这是不可能的。

您可能不需要在web.xml中添加它们。您可能只需要将它们应用到您的应用中。在Grails 3中实现这一点的方法是FilterRegistrationBean。有关几个示例,请参阅https://github.com/grails/grails-core/blob/6b30c22ac9a3758bde53844f807ea781ca7e3c9d/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy#L93-L112。您可能希望在应用的resources.groovy中执行类似操作。

答案 1 :(得分:0)

在我看来它仍然听起来很麻烦。您可以将用户注册工作流程委派给第三方服务(例如Firebase),而不是让这项工作无法清楚地了解正在发生的事情。

使用拦截器来编写它。