简体   繁体   中英

Jhipster gateway Full authentication is required to access this resource

Hello all i am working on Jhipster on ubuntu os. my project set up was done sucessfully. but when trying to test apis it gives me error of authentication.

here is the error occurred while testing 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.
When we create app and entity using Jhipster then it also create user authentication as their functionality.
But in my case user was not created in database which i selected during creation.

Responsible Tables:-

  1. jhi_user
  2. jhi_user_authority
  3. jhi_authority

So, We just need to provide details of default user of Jhipster in these tables.

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. Then test the API from the gateway correctly, without authorization problems.

jh version 5.7.1

Looks like you execute your JHipster registry with authentication and your application without. In case you didn't change your JHipster jwt secret key you have to execute your application(microservice) with next parameters:

--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

For more details read JHipster documentation : 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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