Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Upgrade from 2.2.1 to 2.3.4 @Secured Annotation

I just upgraded my grails application from 2.2.1 to 2.3.4 with mostly success and upgraded spring security plugin from 1.2.7.3 to 2.0-RC2. However, I'm getting an error regarding the spring security plugin (spring-security-core:2.0-RC2).

    Annotation @grails.plugin.springsecurity.annotation.Secured is not allowed on element FIELD

I thought it might have something to do with the new restriction of only being able to annotate methods instead of actions but I am annotating the method not an action... so...

Here's annotated controller (although the message appears for all annotations):

    @Secured(['IS_AUTHENTICATED_FULLY', 'ROLE_SHOW'])
        def history = {
            def instanceList = super.history(Perm.get(params.id))
            [instanceList: impInstanceList]
        }
like image 974
Brandon Wagner Avatar asked Dec 16 '22 02:12

Brandon Wagner


1 Answers

I believe you need to change that to

    @Secured(['IS_AUTHENTICATED_FULLY', 'ROLE_SHOW'])
    def history() {
        def instanceList = super.history(Perm.get(params.id))
        [instanceList: impInstanceList]
    }

I.e. change it to a method from a closure definition

like image 82
tim_yates Avatar answered Jan 20 '23 15:01

tim_yates