如何在Grails 3中配置Shiro插件?

时间:2017-11-13 13:24:50

标签: shiro grails3

Grails3是用于春天安全的Shiro,但不知道怎么用,感觉基本上都是用Spring安全核心。

我的配置如下:

package com.system

class Permission {

    Person person
    String permission

    Permission(Person person, String permission) {
        this.person = person
        this.permission = permission
    }

    static constraints = {
        authority nullable: true
        permission unique: ['person', 'authority']
    }
}

grails.plugin.springsecurity.userLookup.userDomainClassName = 
'com.system.Person'
grails.plugin.springsecurity.userLookup.authorityJoinClassName  = 
'com.system.PersonAuthority'
grails.plugin.springsecurity.authority.className = 'com.system.Authority'
grails.plugin.springsecurity.shiro.active = true
grails.plugin.springsecurity.logout.postOnly = false
grails.plugin.springsecurity.shiro.permissionDomainClassName = 
'com.system.Permission'
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    [pattern: '/',               access: ['permitAll']],
    [pattern: '/error',          access: ['permitAll']],
    [pattern: '/notFound',       access: ['permitAll']],
    [pattern: '/index',          access: ['permitAll']],
    [pattern: '/index.gsp',      access: ['permitAll']],
    [pattern: '/shutdown',       access: ['permitAll']],
    [pattern: '/assets/**',      access: ['permitAll']],
    [pattern: '/uploads/**',     access: ['permitAll']],
    [pattern: '/**/js/**',       access: ['permitAll']],
    [pattern: '/**/css/**',      access: ['permitAll']],
    [pattern: '/**/images/**',   access: ['permitAll']],
    [pattern: '/**/fonts/**',    access: ['permitAll']],
    [pattern: '/**/favicon.ico', access: ['permitAll']]
]

grails.plugin.springsecurity.filterChain.chainMap = [
    [pattern: '/assets/**',      filters: 'none'],
    [pattern: '/**/js/**',       filters: 'none'],
    [pattern: '/**/css/**',      filters: 'none'],
    [pattern: '/**/images/**',   filters: 'none'],
    [pattern: '/**/fonts',       filters: 'none'],
    [pattern: '/**/favicon.ico', filters: 'none'],
    [pattern: '/**',             filters: 'JOINED_FILTERS']
]

0 个答案:

没有答案