Spring组权限,如何使用默认查询激活
我一直在用Spring security尝试不同的东西来学习。我建立了一个具有基本结构的授权,它有“用户”表和“权限”表。因此,我的身份验证提供程序如下所示Spring组权限,如何使用默认查询激活,spring,login,spring-security,Spring,Login,Spring Security,我一直在用Spring security尝试不同的东西来学习。我建立了一个具有基本结构的授权,它有“用户”表和“权限”表。因此,我的身份验证提供程序如下所示 <authentication-provider> <password-encoder hash='md5'> <salt-source user-property="username"/> </password-encoder>
<authentication-provider>
<password-encoder hash='md5'>
<salt-source user-property="username"/>
</password-encoder>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
。因此,虽然我没有使用“authorities by username query”属性,但Spring使用的是默认查询(“select username,authority from authorities where username=?”和“select username,password,enabled from username=?”),所以一切正常
现在我想尝试一下权威团体。所以我根据模式创建表。我的问题是如何激活组权限?表示使用“enableGroups”属性启用“基于组的权限”。但“基于团体的权威机构”没有这样的属性。既然春天已经来临,我认为没有必要明确地给予它
有人能帮我启用基于组的权限和默认查询吗 不幸的是jdbc用户服务不提供对启用组属性的访问。因此,您必须使用spring的bean名称空间手动配置这个bean。
我想你可以试试这样的东西:
<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>
工作正常,谢谢。:)不过,如果jdbc用户服务有一个属性,那就太酷了,不是吗?