Dear Ben Alex,
We were just extending the org.acegisecurity.userdetails.jdbc.JdbcDaoImpl
when we come to a point that may also be interesting for you to take into consideration in next releases.
There is a couple of lines in the method "loadUserByUsername" which is worth more in-depth thought:
In our usage, we came to this conclusion that if any user is defined in the database so it can be deduced the user has certainly the role of "ROLE_USER".Code:if (dbAuths.size() == 0) { throw new UsernameNotFoundException("User has no GrantedAuthority"); }
This lead us to change the code as the following. We commented those lines and instead used the method which had been defined before as "addCustomAuthorities":
And at last we change the code for the method "addCustomAuthorities" as follows:Code:addCustomAuthorities(user.getUsername(), dbAuths); // if (dbAuths.size() == 0) { // throw new UsernameNotFoundException("User has no GrantedAuthority"); // }
This would make it so that each defined user has at least the role "ROLE_USER" and there is no need to throw the exception of not having any "GrantedAuthority" and actually it should not.Code:protected void addCustomAuthorities(String username, List authorities) { authorities.add(new GrantedAuthorityImpl("ROLE_USER")); }
We hope we can contribute more in future.
I hope this was an idea which you agree with too.
Regards,
Behrooz Nobakht
Seyyed Jamal Pishvayi


