简体   繁体   English

用户在微服务中的语言环境 - JHipster

[英]User's locale in microservice - JHipster

In one of the microservices, in a JHipster microservice architecture, I want to generate a document, in the users' language. 在其中一个微服务中,在JHipster微服务架构中,我想用用户的语言生成一个文档。

In the gateway, the users' language is retrieved by a cookie (AngularCookieLocaleResolver). 在网关中,用户的语言由cookie(AngularCookieLocaleResolver)检索。 But when a request, routed through the gateway, arrives at the microservice, no cookies are found on the request. 但是,当通过网关路由的请求到达微服务时,请求中没有找到cookie。

I see a few options here: 我在这里看到几个选项:

  1. Add a locale claim to the JWT-token 将语言环境声明添加到JWT标记
  2. Contact the gateway with the username, to retrieve the locale 使用用户名联系网关,以检索区域设置
  3. Do not generate locale specific content at a microservice 不要在微服务中生成特定于语言环境的内容

I would prefer the first option, but maybe there are some better options... 我更喜欢第一种选择,但也许有更好的选择......

Can anyone help me choose or list up alternatives? 任何人都可以帮我选择或列出替代品吗​​?

First option using JWT claim makes sense and it could be proposed as an enhancement request to JHipster project. 使用JWT声明的第一个选项是有意义的,它可以作为对JHipster项目的增强请求提出。 I can see one minor drawback: any user changing her locale won't get correct localised content until token expires or she logs out and re-authenticates. 我可以看到一个小缺点:任何用户更改其语言环境都不会获得正确的本地化内容,直到令牌过期或她注销并重新进行身份验证。

An alternative would be to pass the locale as a parameter of your resources requests, this makes sense as client is supposed to know it and also in a broader scope client could a be a partner application using another kind of authentication like an API key. 另一种方法是将区域设置作为资源请求的参数传递,这是有意义的,因为客户端应该知道它,并且在更广泛的范围内,客户端可以使用其他类型的身份验证(如API密钥)作为合作伙伴应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM