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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With