[英]Jhipster gateway Full authentication is required to access this resource
Hello all i am working on Jhipster on ubuntu os.大家好,我正在 ubuntu os 上开发 Jhipster。 my project set up was done sucessfully.
我的项目设置已成功完成。 but when trying to test apis it gives me error of authentication.
但是在尝试测试 api 时,它给了我身份验证错误。
here is the error occurred while testing API.这是测试 API 时发生的错误。 it will be pleasure if someone help me out.
如果有人帮助我,我会很高兴。
Error:错误:
rExceptionResolver : Resolved exception caused by Handler execution: org.springframework.security.authentication.InsufficientAuthenticationException: Full authentication is required to access this resource
Web Browser网页浏览器
{
"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"
}
Solution:解决方案:
Here i got the solution.在这里我得到了解决方案。
The problem with the default configuration of Jhipster user creation. Jhipster 用户创建默认配置的问题。
When we create app and entity using Jhipster then it also create user authentication as their functionality.当我们使用 Jhipster 创建应用程序和实体时,它还会创建用户身份验证作为其功能。
But in my case user was not created in database which i selected during creation.但在我的情况下,用户不是在我在创建过程中选择的数据库中创建的。
Responsible Tables:-负责表:-
So, We just need to provide details of default user of Jhipster in these tables.因此,我们只需要在这些表中提供 Jhipster 默认用户的详细信息。
Username: admin用户名:管理员
Password: admin密码:管理员
make sure password is in encrypted form.确保密码是加密形式。
In my case (in dev profile) , i update the JWT token , changing to base64 in all the applications (microservice, gateway and registry), additionally, comment the old property "secret" and use the same key in all.在我的情况下(在开发配置文件中) ,我更新了JWT 令牌,在所有应用程序(微服务、网关和注册表)中更改为 base64,另外,注释旧属性“秘密”并全部使用相同的密钥。 Then test the API from the gateway correctly, without authorization problems.
然后从网关正确测试API,没有授权问题。
jh version 5.7.1 jh 版本 5.7.1
Looks like you execute your JHipster registry with authentication and your application without.看起来您使用身份验证执行 JHipster 注册表,而没有执行您的应用程序。 In case you didn't change your JHipster jwt secret key you have to execute your application(microservice) with next parameters:
如果您没有更改 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
You secret JWT key you could find in central-config package in application.yml file
您可以在 application.yml 文件的 central-config 包中找到您的秘密 JWT 密钥
For more details read JHipster documentation : https://www.jhipster.tech/security/#-json-web-tokens-jwt https://www.jhipster.tech/jhipster-registry/有关更多详细信息,请阅读 JHipster 文档: https : //www.jhipster.tech/security/#-json-web-tokens-jwt https://www.jhipster.tech/jhipster-registry/
Just adding this in the hope it saves somebody some time: I had this error when trying to login after I generated the app.只是添加这个希望它可以节省一些时间:我在生成应用程序后尝试登录时遇到了这个错误。 The tests ran fine.
测试运行良好。 For me deleting the target folder and rebuilding the whole project seemed to solve it.
对我来说,删除目标文件夹并重建整个项目似乎可以解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.