Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails spring-security-rest authentication denied: Dynamic method get<Artefact>Class(artefactName)

I've been working with Grails for around a month now, and we're currently working with angular, as such we've decided to take the REST approach with token based authentication.

Unfortunately whilst working with the plugin, I'm getting an issue that I've so far been unable to fix, the error I'm receiving whilst attempting to authenticate via a POST:

Object {email: "[email protected]", password: "TEST"} 

The exception:

2014-11-17 15:25:29,509 [http-bio-8080-exec-8] DEBUG credentials.DefaultJsonPayloadCredentialsExtractor  - Extracted credentials from JSON payload. Username: [email protected], password: [PROTECTED]
2014-11-17 15:25:29,518 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter  - Trying to authenticate the request
2014-11-17 15:25:29,524 [http-bio-8080-exec-8] DEBUG authentication.ProviderManager  - Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2014-11-17 15:25:29,563 [http-bio-8080-exec-8] DEBUG rest.RestAuthenticationFilter  - Authentication failed: Dynamic method get<Artefact>Class(artefactName) requires a single String parameter

I'd like to note that I'm not using the default 'username' to login, but instead have changed it to 'email'. This is reflected in my config below:

Spring security part of Config.groovy:

grails.plugin.springsecurity.active = true
grails.plugin.springsecurity.rejectIfNoRule = true
grails.plugin.springsecurity.fii.rejectPublicInvocations = false
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
   '/**':               ['permitAll'],
]
grails.plugin.springsecurity.rememberMe.persistent = false
grails.plugin.springsecurity.rest.token.rendering.usernamePropertyName = 'email'
grails.plugin.springsecurity.rest.token.rendering.authoritiesPropertyName = 'roles'
grails.plugin.springsecurity.userLookup.usernamePropertyName='email'

grails.plugin.springsecurity.rest.login.useJsonCredentials = true
grails.plugin.springsecurity.rest.login.failureStatusCode = 401
grails.plugin.springsecurity.rest.token.storage.useGorm = true
grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName = 'AuthenticationToken'
grails.plugin.springsecurity.rest.token.storage.gorm.tokenValuePropertyName = 'token'
grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName = 'email'
grails.plugin.springsecurity.rest.login.active = true
grails.plugin.springsecurity.rest.login.usernamePropertyName = 'email'
grails.plugin.springsecurity.rest.login.passwordPropertyName = 'password'
grails.plugin.springsecurity.rest.login.endpointUrl = "/webapi/user/login"
grails.plugin.springsecurity.rest.logout.endpointUrl = "/webapi/user/logout"

This line suggests that the issue is due to the REST plugin calling the wrong function, or am I wrong? I've checked all the versions - I'm using the exact same Grails, Spring-Core and Spring-Rest versions:

Dynamic method get<Artefact>Class(artefactName) requires a single String parameter

Thanks!

like image 718
Thomas Nairn Avatar asked Nov 17 '14 15:11

Thomas Nairn


1 Answers

Is that your complete Config for Spring Security stuff? You're not defining a grails.plugin.springsecurity.userLookup.userDomainClassName which could result in a call to DefaultGrailsApplication.getDomainClass(null) which would result in the error you are seeing

  • Poundex
like image 159
Thomas Nairn Avatar answered Oct 18 '22 17:10

Thomas Nairn