Closed sdelamo closed 4 years ago
Grails Spring security core 4.x versions use DelegatingPasswordEncoder. See What's new in Version 4.0.
Spring Security suggested workaround:
Troubleshooting
The following error occurs when one of the passwords that are stored has no id as described in Password Storage Format.
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" at org.springframework.security.crypto.password.DelegatingPasswordEncoder$UnmappedIdPasswordEncoder.matches(DelegatingPasswordEncoder.java:233) at org.springframework.security.crypto.password.DelegatingPasswordEncoder.matches(DelegatingPasswordEncoder.java:196) The easiest way to resolve the error is to switch to explicitly provide the PasswordEncoder that you passwords are encoded with. The easiest way to resolve it is to figure out how your passwords are currently being stored and explicitly provide the correct PasswordEncoder.
If you were using the default Bcrypt password encoder in a Grails 3 app you could setup:
grails-app/spring/resources.groovy
...
beans = {
...
..
ConfigObject springSecurityConf = SpringSecurityUtils.securityConfig
int strength = springSecurityConf.password.bcrypt.logrounds as int
passwordEncoder(BCryptPasswordEncoder, [strength] as Object[])
daoAuthenticationProvider(DaoAuthenticationProvider) {
userDetailsService = ref('userDetailsService')
passwordEncoder = ref('passwordEncoder')
userCache = ref('userCache')
preAuthenticationChecks = ref('preAuthenticationChecks')
postAuthenticationChecks = ref('postAuthenticationChecks')
authoritiesMapper = ref('authoritiesMapper')
hideUserNotFoundExceptions = true
}
}
In a a Grails 4 app with multiple authentication providers:
if I try to authenticate with a username/password set, which matches a LDAP username but not the LDAP password I get: