Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Not A Bug
-
Affects Version/s: Grails-Spring-Security-Core 1.2
-
Fix Version/s: None
-
Labels:None
-
Environment:Windows 7
Grails 1.4.0.M1
-
Testcase included:yes
Description
I've created the simplest possible Grails app with the Spring Security plugin installed. I ran the following commands:
grails create-app test cd test grails install-plugin spring-security-core grails s2-quickstart com.yourapp User Role
Then I added the following to Bootstrap.groovy to create a single user and role on startup:
def init = { servletContext ->
def adminRole = Role.findByAuthority('ROLE_ADMIN') ?: new Role(authority: 'ROLE_ADMIN').save(failOnError: true)
def adminUser = User.findByUsername('admin') ?: new User(
username: 'admin',
password: springSecurityService.encodePassword('admin'),
enabled: true).save(failOnError: true)
if (!adminUser.authorities.contains(adminRole)) {
UserRole.create adminUser, adminRole
println "Added $adminUser.username to role $adminRole.authority"
}
}
Then when I go to the login form and enter username "admin" and password "admin" login fails. I'm confident that the user exists, because when the app starts I see the following message in the console
Added admin to role ROLE_ADMIN
When LoginController.authFail() is called back after the login failure, the exception is of type
org.springframework.security.authentication.BadCredentialsException
-
Hide
- test.zip
- 06/Aug/11 9:24 AM
- 116 kB
- Donal Murtagh
-
- test/.classpath 0.7 kB
- test/.project 0.5 kB
- test/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- test/application.properties 0.2 kB
- test/grails-app/conf/BootStrap.groovy 0.7 kB
- test/grails-app/conf/BuildConfig.groovy 1 kB
- test/grails-app/conf/Config.groovy 4 kB
- test/grails-app/conf/DataSource.groovy 0.7 kB
- test/grails-app/.../spring/resources.groovy 0.0 kB
- test/grails-app/conf/UrlMappings.groovy 0.2 kB
- test/grails-app/.../LoginController.groovy 4 kB
- test/grails-app/.../LogoutController.groovy 0.3 kB
- test/grails-app/.../yourapp/Role.groovy 0.2 kB
- test/grails-app/.../yourapp/User.groovy 0.6 kB
- test/grails-app/.../yourapp/UserRole.groovy 1 kB
- test/grails-app/i18n/messages.properties 3 kB
- test/grails-app/.../messages_da.properties 3 kB
- test/grails-app/.../messages_de.properties 4 kB
- test/grails-app/.../messages_es.properties 3 kB
- test/grails-app/.../messages_fr.properties 2 kB
- test/grails-app/.../messages_it.properties 2 kB
- test/grails-app/.../messages_ja.properties 2 kB
- test/grails-app/.../messages_nl.properties 3 kB
- test/.../messages_pt_BR.properties 3 kB
- test/.../messages_pt_PT.properties 3 kB
- test/grails-app/.../messages_ru.properties 4 kB
- test/grails-app/.../messages_sv.properties 3 kB
- test/grails-app/.../messages_th.properties 5 kB
- test/.../messages_zh_CN.properties 2 kB
- test/grails-app/views/error.gsp 2 kB
Activity
Thanks for that. I got this Bootstrap code from a Spring blog post which I presume was written for an earlier version of the plugin: http://jira.grails.org/browse/GPSPRINGSECURITYCORE-104?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#issue-tabs
I've left a comment there to highlight that it won't work with v.1.2
In 1.2 the password is encoded in the domain class, so you're double-encoding in BootStrap.