弹簧安全+ 404错误

时间:2013-12-08 13:44:48

标签: grails spring-security

在生产环境中,应用程序无法映射404错误页面,Spring安全插件总是重定向到登录页面'并返回302错误 - 临时移动 - 在tomcat日志访问中):

1)错误控制器

@Secured(['permitAll'])
class ErrorsController {

    def error401() {
        render view: '401'
    }

    def error403() {
        render view:'403'
    }

    def error404() {
        render view:'404'
    }

    def error500() {
        render view:'error'
    }

    def error503() {
        render view:'503'
    }
}

2)网址映射

static mappings = {
        "/" {
            controller = "dashboard"
            action      = { 'index' }
            view        = { 'index' }
        }

        "/$controller/$action?/$id?"{
            constraints { controller(matches:/^((?!(api|mobile|web)).*)$/) }
        }



        "401"(controller: "errors", action: "error401") // session timeout
        "403"(controller: "errors", action: "error403")
        "404"(controller: "errors", action: "error404")
        "500"(controller: "errors", action: "error500")
        "500"(controller: "errors", action: "error403", exception: AccessDeniedException)
        "500"(controller: "errors", action: "error403", exception: NotFoundException)
    }

因此,当仅处于生产模式时,我正在生成错误的网址模式,无法解析重定向到“404”。有什么想法吗?

1 个答案:

答案 0 :(得分:-4)

好吧它没有禁用安全性,我只是省略发布我的整个配置

'/': ['IS_AUTHENTICATED_ANONYMOUSLY'],
        '/**': ['IS_AUTHENTICATED_ANONYMOUSLY'],
        '/login/auth': ['IS_AUTHENTICATED_ANONYMOUSLY'],
        '/index': ['permitAll'],
        '/index.gsp': ['permitAll'],
        '/**/_common/**/': ['permitAll'],
        '/**/_menu/**/': ['permitAll'],
        '/console/**/': ['permitAll'],
        '/contact/**/': ['permitAll'],
        '/dashboard/**/': ['permitAll'],
        '/jcaptcha/**': ['permitAll'],
        '/demo/**/': ['permitAll'],
        '/errors/**/': ['permitAll'],
        '/features/**/': ['permitAll'],
        '/layouts/**/': ['permitAll'],
        '/service/**/': ['permitAll'],
        '/siteinfo/**/': ['permitAll'],
        '/store/**/': ['permitAll'],
        '/support/**/': ['permitAll'],
        '/**/js/**': ['permitAll'],
        '/**/css/**': ['permitAll'],
        '/**/less/**': ['permitAll'],
        '/**/images/**': ['permitAll'],
        '/admin/**': ['ROLE_SUPERADMIN'],
        '/affiliates/**': ['ROLE_SUPERADMIN'],
        '/billing/**': ['ROLE_SUPERADMIN'],
        '/dataStore/**': ['ROLE_SUPERADMIN'],
        '/requestmap/**': ['ROLE_SUPERADMIN'],
        '/user/**': ['ROLE_SUPERADMIN'],
        '/userRole/**': ['ROLE_SUPERADMIN'],
        '/role/**': ['ROLE_SUPERADMIN'],
        '/quartz/**': ['ROLE_SUPERADMIN'],
        '/invoice/**': ['ROLE_SUPERADMIN'],
        '/billing/**': ['ROLE_SUPERADMIN'],
        '/orders/**': ['ROLE_SUPERADMIN'],
        '/profile/**': ['ROLE_SUPERADMIN'],
        '/pack/**': ['ROLE_SUPERADMIN'],
        '/statistics/**': ['ROLE_SUPERADMIN'],
        '/uploadedItems/**': ['ROLE_SUPERADMIN'],

        '/secure/**': [
                'ROLE_ADMIN',
                'ROLE_CUSTOMER'
        ],

        '/contacts/**': [
                'ROLE_ADMIN',
                'ROLE_USER',
                'ROLE_GROUP_OWNER'
        ],

        '/files/**': [
                'ROLE_ADMIN',
                'ROLE_USER',
                'ROLE_GROUP_OWNER',
                'ROLE_EDITOR',
                'ROLE_UPLOADER',
                'ROLE_READER'
        ],

        '/notes/**': [
                'ROLE_ADMIN',
                'ROLE_USER',
                'ROLE_GROUP_OWNER',
                'ROLE_EDITOR',
                'ROLE_UPLOADER',
                'ROLE_READER'
        ],

        '/toolbox/**': [
                'ROLE_ADMIN',
                'ROLE_USER',
                'ROLE_GROUP_OWNER',
                'ROLE_EDITOR',
                'ROLE_UPLOADER',
                'ROLE_READER']