当前位置: 首页 > 知识库问答 >
问题:

无法从JHipster UAA获取OAUTH2令牌

赵晨
2023-03-14

我用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 task-10]c.c.c.a.g.a.AccessControlFilter:访问控制:允许访问/coherence\uaa/api/account,因为尚未为服务设置访问控制策略:coherence\uaa

2018-07-23 17:32:54.599调试7228---[XNIO-2 task-12]c.c.a.g.a.AccessControlFilter:访问控制:允许访问/coherence\uaa/api/account,因为尚未为服务设置访问控制策略:coherence\uaa

2018-07-23 17:33:00.566DEBUG 7228 --- [ XNIO-2 Task-14]c.c.c.admin.aop.logging.LoggingAspect:输入com.crimsonlogic.coherence.admin.web.rest.AuthResource.authenticate()参数[s]=[SecurityContextHolderAware Request estWrapper[FirewalledRequest[HttpServletRequest estImpl[POST /auth/login]]],com.codahale.metrics.servlet.AbstractInstrumentedFilter$StatusExposingServletResponse@7101e809,{username=admin,密码=admin}]

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

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

JAVAlang.IllegalStateException:请求URI不包含有效的主机名:http://coherence_uaa/oauth/token位于组织。springframework。util。明确肯定组织中的状态(Assert.java:73)。springframework。云客户负载平衡器。RetryLoadBalancer侦听器。拦截(RetryLoadBalancerInterceptor.java:63)。springframework。http。客户侦听ClientHttPrequest$侦听请求执行。在org上执行(截取clienthttprequest.java:92)。springframework。http。客户拦截ClientHttPrequest。org上的executeInternal(InterceptingClientHttpRequest.java:76)。springframework。http。客户AbstractBufferingClientHttpRequest。org上的executeInternal(AbstractBufferingClientHttpRequest.java:48)。springframework。http。客户AbstractClientHttpRequest。在org上执行(AbstractClientHttpRequest.java:53)。springframework。网状物客户RestTemplate。doExecute(RestTemplate.java:723)位于org。springframework。网状物客户RestTemplate。在org上执行(restemplate.java:680)。springframework。网状物客户RestTemplate。postForEntity(RestTemplate.java:466)位于com。犯罪逻辑。连贯性。管理安全oauth2。OAuth2TokenEndpointClientAdapter。sendPasswordGrant(OAuth2TokenEndpointClientAdapter.java:54)。犯罪逻辑。连贯性。管理安全oauth2。OAuth2AuthenticationService。在com上进行身份验证(OAuth2AuthenticationService.java:65)。犯罪逻辑。连贯性。管理网状物RestAuthResource。身份验证(AuthResource.java:51)

共有1个答案

贡英华
2023-03-14

假冒客户端的URI中的主机名不能包含下划线(与coherence_uaa的情况一样)。

有一个相关的JHipster问题,其中_被限制在微服务的基名称之外,它也应该在UAA中受到限制。这里提供的拉取请求修复

 类似资料:
  • 我在网上搜索这个问题的解决方案,但没有找到任何有效的解决方案。我正在尝试设置基本的Spring Boot OAuth2授权提供程序和客户端。 我按照官方的Spring Boot指令,创建了Facebook和GitHub的单点登录。然后按照说明创建安全的Spring Boot Web应用程序。 以下是记录的内容: 信息2800---[nio-9999-exec-3]O.S.B.A.S.O.R.Use

  • 用户授权Google Calendar后,NodeJS服务将代码、AccessToken和RefreshToken保存到存储中。 我也尝试将代码交换为新的令牌,但没有帮助 400错误的请求响应:{“error”:“invalid_grant”,“error_description”:“auth代码格式错误”} 尝试使用Calendar.NewService访问 }

  • 我正在一个项目,其中有要求的Gmail认证,也可以扩展。我在这里遵循这个教程,其中有关于Facebook和GitHub身份验证的示例。所以我尝试了Gmail,我得到了这个错误,我无法解决,并得到了新的异常时,试图解决。请帮助我,因为我相信这是代码受我添加的影响最小的地方。有了这么多的配置和代码,它只适用于github和fb,但不适用于Google。 socialapplication.java b

  • 我正在尝试使用Web服务。我需要获取令牌并在授权标头中发送此令牌,我正在获取令牌,但在服务器中存在问题,因为令牌是v1并且他们正在使用v2。 这是我用来获取代码的网址 https://login.microsoftonline.com/tenant/oauth2/v2.0/authorize?response_type=code 这是获取令牌的url https://login.microsoft

  • 我试图使用请求模块向https://accounts.spotify.com/api/token发出POST请求,以便获得访问令牌。我已经用我的Spotify开发帐户注册了重定向URI。这是我的快速<代码>/重定向 路由。 有人能看到这里可能出了什么问题吗?每次我得到的都是一个不伦不类的“哎呀!出了问题”错误页面。

  • 我试图通过一个到Spring(基本身份验证)安全RESTAPI的绝对URL发出POST请求 读到Angular没有为绝对URL自动将X-XSRF-TOKEN插入请求头之后,我尝试实现一个HttpInterceptor来添加TOKEN。 在我最初的 /signinPOST请求中,我创建了必要的授权:基本标头,以确保Spring验证请求。 返回的响应标头包含预期的set-cookie令牌: 但是,在我