【发布时间】:2018-10-04 14:22:04
【问题描述】:
上下文:我们的应用使用 JHipster 生成的网关和 UAA 服务(微服务架构)。 在尝试失败次数过多后,我们正在实施阻止用户帐户。
当被阻止的用户尝试登录时,UAA 服务会返回 400 Bad Request,并在 error_description 字段中使用自定义 i18n 代码,前端可以使用该代码来显示正确的用户错误:
{
"error" : "invalid_grant",
"error_description" : "error.login.locked"
}
到目前为止一切顺利。
通过网关发出登录请求时会出现问题,因为答案是:
{
"type" : "http://www.jhipster.tech/problem/problem-with-message",
"title" : "Internal Server Error",
"status" : 500,
"detail" : "400 Bad Request",
"path" : "/auth/login",
"message" : "error.http.500"
}
这里有 2 个问题:
HTTP状态为500,同样是密码错误导致登录失败... 这是生成网关的正常预期行为吗?
前端必需的
error和error_description字段在通过网关时丢失了。
有没有比编辑网关authenticate 方法更好的方法,检查HttpClientErrorExceptionfor 并解析OAuth2Exception 以获取详细信息,引发自定义异常,然后由Exceptiontranslator 处理以保存所需的字段?这似乎有点多,只是为了能够保留服务发送的数据。
【问题讨论】:
-
你找到解决办法了吗?
标签: spring jhipster microservices