grails spring security plugin authorization

669 views Asked by At

I were using spring security plugin for authorization. Now I wanted to use jasper plugin for generating reports. But, instead of generating the reports it shows Sorry, you're not authorized to view this page. error.

Config.groovy:

grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    '/'                  : ['permitAll'],
    '/index'             : ['permitAll'],
    '/index.gsp'         : ['permitAll'],
    '/assets/**'         : ['permitAll'],
    '/**/js/**'          : ['permitAll'],
    '/**/css/**'         : ['permitAll'],
    '/**/images/**'      : ['permitAll'],
    '/**/fonts/**'       : ['permitAll'],
    '/**/favicon.ico'    : ['permitAll'],
    '/**/font-awesome/**': ['permitAll'],
    '/**/reports/'       : ['permitAll']

]

environments {
development {
    jasper.dir.reports = '../src/reports'
}
production {
    jasper.dir.reports = '/home/Sample-Reports'
    // TODO: grails.serverURL = "http://www.changeme.com"
}

}

How can I solve this problem?

EDIT: grails version 2.4.4 spring security version 2.0

2

There are 2 answers

0
ionutab On

in Config.groovy try to add the following:

grails.plugins.springsecurity.interceptUrlMap = [

'/pathToActionThatGeneratesDocument/**': ['IS_AUTHENTICATED_ANONYMOUSLY'],

]

0
WILLIAM WOODMAN On

had a similar problem in dev with grails 3.2.6 and spring-security 3.1.1.

i was trying to accessing /debconsole and couldnt. even after updating the staticRules.

its not elegant nor right but whilst in dev what you can do is add this to your /init/application.groovy

//added to avoid login screens for dbconsole
grails.plugin.springsecurity.rejectIfNoRule = false
grails.plugin.springsecurity.fii.rejectPublicInvocations = false

when you do it effectively turns the checking off whilst your looking at the dbconsole or console to check stuff and you dont get bounced by spring security.

need to set back to true when you want the validation turned back on - but this was a quick fix that allowed me to get to the resource without getting bogged down on how to get to the h2 console when i needed it