Spring Group authorities, how to activate with default query
authentication, spring, spring-security
Solution
Unfortunately jdbc-user-service do not provide access to enableGroups property. So you must configure this bean manually using spring's bean namespace. I think you can try something like this:
<authentication-provider user-service-ref="jdbcDaoImpl">
<password-encoder hash='md5'>
<salt-source user-property="username"/>
</password-encoder>
</authentication-provider>
<beans:bean id="jdbcDaoImpl" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
<property name="enableGroups" value="true" />
<property name="enableAuthorities" value="false" />
<property name="dataSource" ref="dataSource" />
</beans:bean>
Problem
I have been trying out different things with Spring security to learn. I set up a authorization with basic structure that have "users" table and "authorities" table. So my authentication-provider looks like following. ``` <authentication-provider> <password-encoder hash='md5'> <salt-source user-property="username"/> </password-encoder> <jdbc-user-service data-source-ref="dataSource"/> </authentication-provider> ``` In this way I don't specify query to fetch user details because I use default database schema. So though I'm not using a "authorities-by-username-query" attribute Spring is using default queries( "select username, authority from authorities where username = ?" and "select username, password, enabled from users where username = ?") So things working well. Now I want to try with authority groups. So I create tables according to schema. My question how to activate group authority? API documentation for JdbcDaoImpl says to use "enableGroups" property to enable "group-based authorities". but "group-based authorities" doesn't have such property. Since Spring has the default query I think no need of explicitly give it. So can someone help me here to enable group based authorities with default query.