无法从JHipster UAA获取OAUTH2令牌

时间:2018-07-23 10:01:38

标签: jhipster

我用JHipster 5.1.0生成了UAA服务器。我选择PostgreSQL作为数据库类型。

它连接到我的jhipster注册表,然后生成了一个微服务和一个网关,如下所示:

$ mkdir coherence-uaa && cd coherence-uaa
$ yo jhipster
? Which *type* of application would you like to create? Microservice UAA service
? As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 9999
? What is your default Java package name? de.stytex.foobar
? Which *type* of database would you like to use? SQL (H2, MySQL, PostgreSQL, Oracle)
? Which *production* database would you like to use? PostgreSQL
? Which *development* database would you like to use? H2 with disk-based persistence
? Do you want to use Hibernate 2nd level cache? Hazelcast
? Do you want to use a search engine in your application? No
? Would you like to use Maven or Gradle for building the backend? Maven
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application? English
? Please choose additional languages to install
? Which testing frameworks would you like to use?
[...]
$ ./mvnw

$ mkdir coherence-gateway && cd coherence-gateway
$ yo jhipster
? Which *type* of application would you like to create? Microservice gateway
? What is the base name of your application? gateway
? As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 8080
? What is your default Java package name? de.stytex.foobar
? Which service discovery server do you want to use? JHipster Registry (uses Eureka, provides Spring Cloud Config support and monitoring dashboards)
? Which *type* of authentication would you like to use? Authentication with JHipster UAA server (the server must be generated separately)
? What is the folder path of your UAA application? ../coherence-uaa
? Which *type* of database would you like to use? SQL (H2, MySQL, PostgreSQL, Oracle)
? Which *production* database would you like to use? PostgreSQL
? Which *development* database would you like to use? H2 with disk-based persistence
? Do you want to use Hibernate 2nd level cache? Hazelcast
? Do you want to use a search engine in your application? No
? Do you want to use clustered HTTP sessions? No
? Do you want to use WebSockets? No
? Would you like to use Maven or Gradle for building the backend? Gradle
? Would you like to use the LibSass stylesheet preprocessor for your CSS? No
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application? English
? Please choose additional languages to install
? Which testing frameworks would you like to use?
[...]
./mvnw

启动用于用户登录的网关后,它无法获取访问令牌并引发错误:

2018-07-23 17:32:53.378调试7228--[XNIO-2任务10] cccagaAccessControlFilter:访问控制:允许访问/ coherence_uaa / api / account,因为未设置访问控制策略服务:coherence_uaa

2018-07-23 17:32:54.599 DEBUG 7228 --- [XNIO-2 task-12] cccagaAccessControlFilter:访问控制:允许访问/ coherence_uaa / api / account,因为未设置访问控制策略服务: coherence_uaa

2018-07-23 17:33:00.566调试7228--[XNIO-2任务14] cccadmin.aop.logging.LoggingAspect:输入:com.crimsonlogic.coherence.admin.web.rest.AuthResource .authenticate(),带有参数[s] = [SecurityContextHolderAwareRequestWrapper [FirewalledRequest [HttpServletRequestImpl [POST / auth / login]]]],com.codahale.metrics.servlet.AbstractInstrumentedFilter$StatusExposedServletResponse@7101e809,{用户名= admin,密码= admin}]

2018-07-23 17:33:00.576调试7228--[XNIO-2任务14] c.a.s.o.OAuth2TokenEndpointClientAdapter:联系OAuth2令牌端点以登录用户:admin

2018-07-23 17:33:00.588错误7228 --- [XNIO-2任务14] c.c.c.a.s.o.OAuth2AuthenticationService:无法从UAA获取OAuth2令牌

java.lang.IllegalStateException:请求URI不包含有效的主机名:http:// coherence_uaa / oauth / token         在org.springframework.util.Assert.state(Assert.java:73)         在org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor.intercept(RetryLoadBalancerInterceptor.java:63)         在org.springframework.http.client.InterceptingClientHttpRequest $ InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:92)         在org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:76)         在org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)         在org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)         在org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:723)         在org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680)         在org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:466)         在com.crimsonlogic.coherence.admin.security.oauth2.OAuth2TokenEndpointClientAdapter.sendPasswordGrant(OAuth2TokenEndpointClientAdapter.java:54)         在com.crimsonlogic.coherence.admin.security.oauth2.OAuth2AuthenticationService.authenticate(OAuth2AuthenticationService.java:65)         在com.crimsonlogic.coherence.admin.web.rest.AuthResource.authenticate(AuthResource.java:51)

1 个答案:

答案 0 :(得分:2)

Feign Client的URI中的主机名不能包含下划线(例如coherence_uaa)。

有一个related JHipster issue,其中_受微服务基本名称的限制,在UAA中也应受限制。 Pull Request fixing that is available here

相关问题