如何使用Spring Eureka连接Spring OAuth? [英] How do I wire up spring oauth using spring eureka?
问题描述
我已经使用Spring教程创建了一个单页应用程序,用于使用AngularJS和OAuth编写一个应用程序,如下所示: https://spring.io/guides/tutorials/spring-安全和角度js/#_ multiple_ui_applications_and_a_gateway_single_page_application_with_spring_and_angular_js_part_vi
I have created a Single Page Application using the Spring Tutorial for making one with AngularJS and OAuth and such found here: https://spring.io/guides/tutorials/spring-security-and-angular-js/#_multiple_ui_applications_and_a_gateway_single_page_application_with_spring_and_angular_js_part_vi
这是SPA应用程序的application.yml文件:
This is the application.yml files for the SPA application:
security:
user:
password: none
oauth2:
client:
accessTokenUri: localhost:7777/uaa/oauth/token
userAuthorizationUri: localhost:7777/uaa/oauth/authorize
clientId: acme
clientSecret: acmesecret
resource:
user-info-uri: localhost:7777/uaa/user
zuul:
routes:
resource:
path: /resource/**
url: localhost:9000/resource
user:
path: /user/**
url: localhost:7777/uaa/user
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:127.0.0.1:8761}/eureka/
---
spring:
profiles: cloud
eureka:
instance:
hostname: ${APPLICATION_DOMAIN}
nonSecurePort: 80
我想知道如何更改zuul路由和user-info-uri,这样我就不必指定url,而所有这些都可以通过使用service-id来完成.我在这里查看了使用eureka的教程:
I want to know how I would change the zuul routes and the user-info-uri so that I don't have to specify the urls and all this can be done by using the service-id. I looked at the tutorial for using eureka here:
但是我不太了解如何在不将所有Java添加到代码中的情况下实现目标,因为基本的eureka服务器似乎已经注册了我的所有服务.
but I don't quite understand how I can achieve my goal without adding all the java to my code, because the basic eureka server already seems to register all my services.
推荐答案
如果我确实理解了您的问题,那么您可以按以下方式使用配置文件:
If I do understand your question correct you can just use the config file in this pattern:
zuul:
routes:
<service_id>:
path: /path/**
例如(如果您的oauth-service注册为auth
):
For example (if your oauth-service is registered as auth
):
zuul:
routes:
auth:
path: /user/**
Zuul将利用Eureka并找到服务的端点.除此之外,它将提供客户端负载平衡.
Zuul will leverage Eureka and find the endpoints for the services. In addition to that it will provide client-side load-balancing.
这篇关于如何使用Spring Eureka连接Spring OAuth?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!