Stu
Stu

Reputation: 33

Unable to import Spring Security @Secured Annotation into Grails 3

I am currently following the Spring Security 3.0.0.M1 plugin tutorial for Grails here and I appear to be stuck on Step 8. Using the statement import grails.plugin.springsecurity.annotation.Secured does not work because Grails cannot resolve the package name. I know that Spring Security for Grails 3 is in its infancy, but has anyone been able to get past this step yet? For reference, here is my SecureController class (with a another import that also does not work):

package ldaptest.controllers

import grails.plugin.springsecurity.annotation.Secured;
import org.springframework.security.access.annotation.Secured;

@Secured('ROLE_ADMIN')
class SecureController {

    def index() {
        render 'Secure access only'
    }
}

Upvotes: 1

Views: 1297

Answers (2)

I had:3,1,1 the save problem with my application. I solved it by adding as a library to my project. However I had to change import package to make it work.

import org.springframework.security.access.annotation.Secured

I am using IntelliJ IDEA, I just has to search the maven repo for the spring-security-core:3.1.1. In IntelliJ you do : File > Project Structure > Libraries > Add > From Maven Repository. Then do the search according to the version of "spring-security-core" you want to use.

Upvotes: 0

Mexx
Mexx

Reputation: 359

I may found a solution:

  1. Create a "lib" folder e.g. inside your "grails-app" directory.

  2. Download the SpringSecurityCore JAR from here and move it into the lib directory

  3. Add gradle dependency:

    compile files('lib/spring-security-core-3.0.0.M1.jar')

Hope this helps. Greetings

Upvotes: 2

Related Questions