application.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. server:
  2. port: 7000
  3. spring:
  4. application:
  5. name: gateway
  6. security:
  7. oauth2:
  8. # 资源服务器配置
  9. resourceserver:
  10. jwt:
  11. # Jwt中claims的iss属性,也就是jwt的签发地址,即认证服务器的根路径
  12. # 资源服务器会进一步的配置,通过该地址获取公钥以解析jwt
  13. issuer-uri: http://www.test.com:8080
  14. client:
  15. provider:
  16. # 认证提供者,自定义名称
  17. custom-issuer:
  18. # Token签发地址(认证服务地址)
  19. issuer-uri: http://www.test.com:8080
  20. # 获取用户信息的地址,默认的/userinfo端点需要IdToken获取,为避免麻烦自定一个用户信息接口
  21. user-info-uri: ${spring.security.oauth2.client.provider.custom-issuer.issuer-uri}/user
  22. user-name-attribute: name
  23. registration:
  24. messaging-client-oidc:
  25. # oauth认证提供者配置,和上边配置的认证提供者关联起来
  26. provider: custom-issuer
  27. # 客户端名称,自定义
  28. client-name: gateway
  29. # 客户端id,从认证服务申请的客户端id
  30. client-id: messaging-client
  31. # 客户端秘钥
  32. client-secret: 123456
  33. # 客户端认证方式
  34. client-authentication-method: client_secret_basic
  35. # 获取Token使用的授权流程
  36. authorization-grant-type: authorization_code
  37. # 回调地址,这里设置为Spring Security Client默认实现使用code换取token的接口
  38. redirect-uri: http://127.0.0.1:7000/login/oauth2/code/messaging-client-oidc
  39. scope:
  40. - message.read
  41. - message.write
  42. - openid
  43. - profile
  44. cloud:
  45. gateway:
  46. default-filters:
  47. # 令牌中继
  48. - TokenRelay=
  49. # 代理路径,代理至服务后会去除第一个路径的内容
  50. - StripPrefix=1
  51. routes:
  52. # 资源服务代理配置
  53. - id: auth
  54. uri: http://localhost:8080
  55. predicates:
  56. - Path=/auth/**
  57. # 资源服务代理配置
  58. - id: webmvc
  59. uri: http://localhost:7200
  60. predicates:
  61. - Path=/webmvc/**
  62. # 资源服务代理配置
  63. - id: webflux
  64. uri: http://localhost:7100
  65. predicates:
  66. - Path=/webflux/**