spring-oauth-server 数据扩展实现思路

spring-oauth-server 默认使用数据库MySql实现数据存储, 使用MyBatis, JDBC实现数据库连接与处理.

但在实际项目使用过程中, 有的项目需要使用其他的数据存储解决方案, 如 LDAP, 文件, ACCESS, REDIS, MongoDB等等. 这时如何办, 如何去扩展呢? 在此给一些步骤与建议.具体如下

 

1. 在项目中加入必要的MAVEN dependencies; 如 redis的, LDAP的.(建议使用基于spring-data 系列的, 方便与Spring 整合);  并去掉不需要的dependencies, (如当前的 mybatis, mysql);

2. 用你需要的存储技术 实现spring-security-oauth2提供的以下3个接口:

  • AuthorizationCodeServices
  • TokenStore
  • ClientDetailsService

3.修改security.xml中的对应的3个接口的默认配置, 分别为 JdbcTokenStore, CustomJdbcClientDetailsService, JdbcAuthorizationCodeServices;  用自己实现的替换默认的.

4.测试修改. 保证oauth_test.txt(位于others目录)中的示例能够正常运行, 或使用spring-oauth-client测试

 

扩展

若需要完全替换掉MYSQL, 则还需要提供 OauthRepository 与 UserRepository 的实现并配置.

 

——————————————————————————

若需要提供商业化的技术支持 或 提供整套的技术方案, 请联系 sz@monkeyk.com

 

http://git.oschina.net/shengzhao/spring-oauth-server

Leave a Comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.