jhipster monolith到微服务迁移:没有授权信息转发?

os8fio9y  于 2021-07-16  发布在  Java
关注(0)|答案(1)|浏览(249)

我开始将我的jhipster monolith迁移到微服务:gateway/ui/backend。但现在我已经卡住了-身份验证信息似乎没有被转发到微服务。或者说我不知道系统的哪个部分负责?打电话给 services/api 因此,后端会产生HTTP401响应。
这些应用程序是通过 jhipster ,还没有大的变化。通过提供的docker compose启动keydepot服务。
所以用户界面通过keydeap登录。收到 JSESSIONID ? 我确实看到网关在这一点上进行了oauth2令牌交换,所以我假设他应该在下游调用上附加这个?打电话 /services/api 网关接收:

Request received for GET '/services/api/projects?page=0&size=3&loadArchived=false&loadAll=false&sort=startTime,asc&sort=id':

HttpServletRequestImpl [ GET /services/api/projects ]

servletPath:/services/api/projects
pathInfo:null
headers: 
sec-fetch-mode: cors
referer: http://localhost:9000/
sec-fetch-site: same-origin
accept-language: en-US,en;q=0.5
cookie: io=u8lImSrLEEZI1wudAAAg; XSRF-TOKEN=0ee385f0-7035-455c-a62f-53e4fb920af3; JSESSIONID=-MJuDH_RKSEBKWa3fEudYqX1fQII_8FMdqec2gc1
host: localhost:9000
connection: close
dnt: 1
accept-encoding: gzip, deflate
accept: application/json, text/plain, */*
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
sec-fetch-dest: empty

Security filter chain: [
  WebAsyncManagerIntegrationFilter
  SecurityContextPersistenceFilter
  HeaderWriterFilter
  CorsFilter
  CsrfFilter
  LogoutFilter
  OAuth2AuthorizationRequestRedirectFilter
  OAuth2AuthorizationRequestRedirectFilter
  OAuth2LoginAuthenticationFilter
  BearerTokenAuthenticationFilter
  RequestCacheAwareFilter
  SecurityContextHolderAwareRequestFilter
  AnonymousAuthenticationFilter
  OAuth2AuthorizationCodeGrantFilter
  SessionManagementFilter
  ExceptionTranslationFilter
  FilterSecurityInterceptor
]

而微服务( api )没有任何敏感信息可用。或者我可能看不到?我记得一些关于SpringSecurity隐藏身份验证头的信息。

Request received for GET '/api/projects?page=0&size=3&loadArchived=true&loadAll=true&sort=startTime,asc&sort=id':

HttpServletRequestImpl [ GET /api/projects ]

servletPath:/api/projects
pathInfo:null
headers: 
sec-fetch-mode: cors
referer: http://localhost:9000/?showArchived=true&showAll=true
sec-fetch-site: same-origin
accept-language: en-US,en;q=0.5
x-forwarded-proto: http
Connection: Keep-Alive
x-forwarded-port: 9000
Host: localhost:8081
dnt: 1
x-forwarded-for: 127.0.0.1
accept: application/json, text/plain, */*
x-forwarded-host: localhost:9000
x-forwarded-prefix: /services
accept-encoding: gzip, deflate
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
sec-fetch-dest: empty

Security filter chain: [
  WebAsyncManagerIntegrationFilter
  SecurityContextPersistenceFilter
  HeaderWriterFilter
  LogoutFilter
  OAuth2AuthorizationRequestRedirectFilter
  BearerTokenAuthenticationFilter
  RequestCacheAwareFilter
  SecurityContextHolderAwareRequestFilter
  AnonymousAuthenticationFilter
  OAuth2AuthorizationCodeGrantFilter
  SessionManagementFilter
  ExceptionTranslationFilter
  FilterSecurityInterceptor
]

(也许)重要提示:我不使用Eureka 。我暂时“硬编码”了路线( application-dev.ymlgateway ). 这会改变你的行为吗?

zuul:
  routes:
    api:
      path: /**
      url: http://localhost:8081/

如果有人想检查某些内容,则可以公开该代码:https://github.com/bbortt/event-planner/tree/feature/split-into-oauth2-modules. 如果你需要更多的信息,请告诉我。

628mspwn

628mspwn1#

我想@gaëlmarziou给我指出了正确的方向,他说:非常感谢!因此,我以前使用jhipster generator 6.x.x生成了网关,并更新到7.something(到今天为止最新的稳定版本)。重新生成网关,现在就像一个魔咒。他完美地将授权头信息附加到下游请求上。
简单回答您的问题:
不包括用于生成应用程序的选项(.yo-rc.json或jdl)
好吧,我认为jhipster是一个很好的开始方式-但不是保持你的项目。因此,我喜欢用它来启动我的项目,但之后就要摆脱它。但是,我当然同意,在这种情况下,追查与jhipster有关的问题会有所帮助。
您的体系结构没有服务发现是令人惊讶的,不确定您的目标是什么。
我认为k8s可以很好地处理静态路由上的发现和负载平衡。这可能是一个偏好的问题,但如果我不一定需要它,我不喜欢再跟踪一个服务器;)

相关问题