Web Services 访问此资源需要完全身份验证

qzwqbdag  于 2022-11-15  发布在  其他
关注(0)|答案(4)|浏览(215)

大家好,我正在Ubuntu OS上的Jhipster上工作。我的项目设置是成功完成的。但是当试图测试API时,它给了我身份验证错误。
这是测试API时发生的错误。2如果有人能帮我解决这个问题,我会很高兴的。
错误:

rExceptionResolver : Resolved exception caused by Handler execution: org.springframework.security.authentication.InsufficientAuthenticationException: Full authentication is required to access this resource

网页浏览器

{
"type" : "https://www.jhipster.tech/problem/problem-with-message",
"title" : "Unauthorized",
"status" : 401,
"detail" : "Full authentication is required to access this resource",
"path" : "/api/account",
"message" : "error.http.401"
}
e1xvtsh3

e1xvtsh31#

在我的例子中 (在开发配置文件中),我更新了JWT标记,在所有应用程序(微服务,网关和注册表)中更改为base64,另外,注解旧属性 “secret” 并在所有应用程序中使用相同的密钥。然后从网关正确测试API,没有授权问题。

  • 真贤5.7.1版 *
zysjyyx4

zysjyyx42#

Jhipster用户创建的默认配置的问题。
当我们使用Jhipster创建应用程序和实体时,它也会创建用户身份验证作为其功能。
但在我的情况下,用户不是在我在创建过程中选择的数据库中创建的。
负责表:

  1. jhi用户
  2. jhi用户权限
  3. jhi_权限
    所以,我们只需要在这些表中提供Jhipster默认用户的详细信息。

**用户名:admin

密码:admin**
请确保密码是加密形式。

anauzrmj

anauzrmj3#

看起来您执行JHipster注册表时需要身份验证,而您的应用程序没有身份验证。如果您没有更改JHipster jwt密钥,则必须使用以下参数执行您的应用程序(微服务):

--spring.security.user.password=admin --jhipster.security.authentication.jwt.secret=my-secret-key-which-should-be-changed-in-production-and-be-base64-encoded --spring.cloud.config.server.composite.0.type=native --spring.cloud.config.server.composite.0.search-locations=file:./central-config

您可以在应用程序.yml文件的中央配置包中找到JWT密钥
有关详细信息,请参阅JHipster文档:https://www.jhipster.tech/security/#-json-web-tokens-jwt:

yeotifhr

yeotifhr4#

我在生成应用程序后尝试登录时遇到了这个错误。测试运行良好。
删除目标文件夹并重建整个项目似乎解决了这个问题。

相关问题