Spring Group Powers on how to activate a default request

I tested various things using Spring to learn. I created an authorization with a basic structure in which there is a table "users" and a table of "permissions". Therefore, my authentication provider is as follows.

<authentication-provider> <password-encoder hash='md5'> <salt-source user-property="username"/> </password-encoder> <jdbc-user-service data-source-ref="dataSource"/> </authentication-provider> 

Thus, I am not specifying a query to retrieve user information because I am using the standard database schema . Thus, although I do not use the "person-by-username-query" Spring attribute, it uses default queries ("select username, authority from authorities, where username =?" And "select username, password included from users, where username =? ") So, everything works well.

Now I want to try with authority groups. Therefore, I create tables according to the scheme. My question is how to activate the group powers? The API documentation for JdbcDaoImpl says that the enableGroups property is used to use "group permissions". but “group-based bodies” do not possess such property. Since Spring has a default request , I think there is no need to explicitly give it.

So can anyone help me here to enable group-based credentials with the default request.

+4
source share
1 answer

Unfortunately jdbc-user-service does not provide access to the enableGroups property. Therefore, you must manually configure this bean using the spring 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> 
+5
source

All Articles