我在带有 MySQL 数据库的 tomcat 7 上运行 CAS 3 Spring 3.2 和 Spring Security 3.2。
我们使用带有 CAS 的 MySQL 数据库对用户进行身份验证,然后在成功后传递属性,我们从名为 say"sso" 的数据库中获取这些详细信息
<bean id="attributeRepository" class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
<constructor-arg index="0" ref="dataSource"/>
<constructor-arg index="1" value="select * from user where {0}" />
<property name="queryAttributeMapping">
<map>
<entry key="username" value="user_name" />
</map>
</property>
<property name="resultAttributeMapping">
<map>
<entry key="user_name" value="username" />
<entry key="full_name" value="fullname" />
</map>
</property>
</bean>
之后我们要做的是从这些属性中获取用户名,然后转到一个名为“app”的特定于应用程序的数据库。
所以我们要做的就是在认证成功后从 CAS 中获取用户名,然后从数据库中获取其角色。
我们怎样才能正确地做到这一点?
更新
好的,现在我到目前为止所尝试的,我真的不知道这是否有效。
我已经实现UserDetailsService
并创建了一个UserEntityDetails
扩展我的UserEntity
和实现UserDetails
的,然后我用我UserDetailsService
来加载我的自定义创建的类。
然后在我的 XML 中我做了这个
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="casAuthProvider" user-service-ref="DBUserServiceDetails" />
</security:authentication-manager>
这是正确的方法吗?