【问题标题】:how do i transform a spring security configuration from application.groovy to application.yml我如何将 spring 安全配置从 application.groovy 转换为 application.yml
【发布时间】:2015-12-03 01:21:24
【问题描述】:

大家好,我需要将此配置从 application.groovy 转换为 application.yml

grails.plugin.springsecurity.controllerAnnotations.staticRules = 
[   '/':            ['permitAll'],  
'/error':           ['permitAll'],  
'/index':           ['permitAll'],  
'/index.gsp':       ['permitAll'],  
'/shutdown':        ['permitAll'],  
'/assets/**':       ['permitAll'],  
'/**/js/**':        ['permitAll'],  
'/**/css/**':       ['permitAll'],  
'/**/images/**':    ['permitAll'],  
'/**/favicon.ico':  ['permitAll'] ]

例如 grails.plugin.springsecurity.apf.postOnly = false 表示为

grails:
    plugin:
        springsecurity:
            apf:
                postOnly: false

【问题讨论】:

    标签: grails spring-security


    【解决方案1】:

    试试这个:

    grails:
        plugin:
            springsecurity:
                controllerAnnotations:
                    staticRules:
                        '/':                permitAll
                        '/error':           permitAll
                        '/index':           permitAll
                        '/index.gsp':       permitAll
                        '/shutdown':        permitAll
                        '/assets/**':       permitAll
                        '/**/js/**':        permitAll
                        '/**/css/**':       permitAll
                        '/**/images/**':    permitAll
                        '/**/favicon.ico':  permitAll
    

    它对我有用。 YAML 规范取自official YAML spec website

    【讨论】:

    • 这是一个包含更多迁移设置的示例:github.com/burtbeckwith/grailstwitter/blob/master/grails-app/…
    • 谢谢@RickyGo。像魔术一样工作。世界恢复正常。感谢 Burt Beckwith 的额外设置。我现在可以继续移植我的代码 Yii PHP 框架,顺便说一下,它似乎是在 Grails 之后构建的
    • 感谢@RickyGo!我正在使用 Grails 3.1.1,不知何故,由 /conf 文件夹下的插件生成的 application.groovy 已被我的应用程序忽略。
    【解决方案2】:

    这对于 Grails 3.X 的 Spring Security 插件的 3.0.1 版本有所改变。具有基于注释的安全性的 3.0.1 的 YML 格式如下所示:

    # Added for the Spring Security Core plugin:
    ---
    grails:
      plugin:
        springsecurity :
          userLookup.userDomainClassName: 'org....User'
          userLookup.authorityJoinClassName: 'org....UserRole'
          authority.className: 'org....Role'
          adh.errorPage: '/user/denied'
          controllerAnnotations.staticRules:
            - pattern: '/'
              access: ['permitAll']
            - pattern: '/index'
              access: ['permitAll']
            - pattern: '/index.gsp'
              access: ['permitAll']
            - pattern: '/error'
              access: ['permitAll']
            - pattern: '/user/denied'
              access: ['permitAll']
            - pattern: '/assets/**'
              access: ['permitAll']
            - pattern: '/**/js/**'
              access: ['permitAll']
            - pattern: '/**/css/**'
              access: ['permitAll']
            - pattern: '/**/images/**'
              access: ['permitAll']
            - pattern: '/**/favicon.ico'
              access: ['permitAll']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      • 2015-07-22
      • 2015-05-30
      • 2011-01-15
      • 2019-05-19
      • 1970-01-01
      相关资源
      最近更新 更多