Reputation: 261
I'm following this tutorial for Spring Security Authentication:
http://spring.io/blog/2010/08/11/simplified-spring-security-with-grails/ Video: https://www.youtube.com/watch?v=auwML_bsUEE
I can't follow the step in 4:50.
package org.example
import grails.plugins.springsecurity.Secured
class PostController {
...
@Secured(['ROLE_USER'])
def followAjax = { ... }
@Secured(['ROLE_USER', 'IS_AUTHENTICATED_FULLY'])
def addPostAjax = { ... }
def global = { ... }
@Secured(['ROLE_USER'])
def timeline = { ... }
@Secured(['IS_AUTHENTICATED_REMEMBERED'])
def personal = { ... }
}
import grails.plugins.springsecurity.Secured is not found.
I'm using Grails 2.4.4 and compile ':spring-security-core:2.0-RC4' in BuildConfig.groovy. Thanks.
Upvotes: 1
Views: 1096
Reputation: 75681
That tutorial is more than 4 years old, a lot has changed since then. Try reading the plugin docs - I'm sure that there are several other changes like this that will cause issues.
The import should be grails.plugin.springsecurity.Secured
. You can also use the Spring Security org.springframework.security.access.annotation.Secured
annotation, but the plugin's annotation supports all of the same features and a few additional ones, e.g. letting you define the rules with a Closure.
You can't use either annotation on an action defined as a Closure though. They are still supported in Grails 2.0+ but methods are now preferred, and although Grails lets you define actions with closures or actions, the plugin only supports methods.
Upvotes: 1