本项目使用了spring security5.x的新的oauth2包,参考: spring boot 2和spring cloud G版本Oauth2功能包依赖说明
开发者社区博客文档:Spring Cloud基于Oauth2的认证和鉴权
本项目支持okta和TDF-oauth-server
- 如果使用TDF-oauth-server作为认证服务器请参考http://tech.taiji.com.cn/community/blog/%E7%BB%9F%E4%B8%80%E8%AE%A4%E8%AF%81%E5%B9%B3%E5%8F%B0TDF-oauth-server
- 如果使用okta,需要申请okta的开发者账号https://developer.okta.com/signup/
- 运行eureka
- 运行zuul
- 运行resource
- 运行openfeign
浏览器输入:http://localhost:8080/openfeign/dc
浏览器显示字符串:Services: [zuul, resource, openfeign]
- eureka:是Eureka Server
- zuul: 是基于zuul的网关,代理resource和openfeign
- resource;普通微服务
- openfeign: 通过openfeign调用resource
服务发现中心
引用了spring-boot-starter-oauth2-client包,作为okta的client。自定义OAuth2TokenRelayFilter,做token relay操作
引用了pring-boot-starter-oauth2-resource-server作为资源服务器,配置:jwk-set-uri
引用了pring-boot-starter-oauth2-resource-server作为资源服务器。自定义了RequestInterceptor,做token relay操作
- zuul项目注释中的其他认证服务器同时存在时候,zuul项目启动会报错,目前只配置使用okta作为认证服务器