generator-jhipster
generator-jhipster copied to clipboard
Microservice application fails to login with 401 unauthorized
Overview of the issue
No error in the stack trace only in the dev tools of the browser
Motivation for or Use Case
I'm trying to use a microservice architecture and cannot because of this error
Reproduce the error
launch jhipster >> select microservice >> maven >> and any configuration you want
Related issues
could not find one that relates to this
JHipster Version(s)
version 8.0.0
JHipster configuration
jhipster info
Welcome to JHipster v8.0.0
Welcome to the JHipster Information Sub-Generator
[email protected] /home/afcn/code/tmp
└── [email protected]
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"applicationType": "microservice",
"authenticationType": "oauth2",
"baseName": "tmp",
"buildTool": "maven",
"cacheProvider": "redis",
"clientFramework": "react",
"clientTestFrameworks": [],
"clientTheme": "cerulean",
"clientThemeVariant": "dark",
"creationTimestamp": 1701573616424,
"databaseType": "mongodb",
"devDatabaseType": "mongodb",
"devServerPort": 9060,
"enableGradleEnterprise": null,
"enableHibernateCache": false,
"enableSwaggerCodegen": false,
"enableTranslation": true,
"entities": [],
"gradleEnterpriseHost": null,
"jhipsterVersion": "8.0.0",
"languages": [
"en",
"fr"
],
"messageBroker": false,
"microfrontend": null,
"microfrontends": [],
"nativeLanguage": "en",
"packageName": "com.mycompany.myapp",
"prodDatabaseType": "mongodb",
"reactive": false,
"searchEngine": "elasticsearch",
"serverPort": 8081,
"serverSideOptions": [
"searchEngine:elasticsearch"
],
"serviceDiscoveryType": "consul",
"skipUserManagement": true,
"testFrameworks": [],
"websocket": "no",
"withAdminUi": true
}
}
</pre>
</details>
##### **Environment and Tools**
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)
git version 2.34.1
node: v20.10.0
npm: 10.2.3
Docker version 24.0.6, build ed223bc
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
<details>
<summary>JDL entity definitions</summary>
<pre>
</pre>
</details>
Congratulations, JHipster execution is complete!
If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/
Thanks for using JHipster!
Browsers and Operating System
windows running on wsl2
- [x] Checking this box is mandatory (this is just to show you read everything)
Do you have gateway generated?
Im quite new to jhipster so pardon my questons if they sound silly , but when you say gateway you talking about the microservice gateway option during the yeoman setup?
I have been trying to find documention for v8.0.0 buts its quite difficult.
The probelm is im not doing any custom code at this time just launching what comes pre buillt and it does not work ou f the box.
I have to change the test class becauyse its missing a import , but after that i can compile but once i try to login with JWT or OAuth2 both fail
Yes. You need a gateway application to access the microservices (if I remember correctly). You can have a look at Matt's blog post about microservices/frontends with jhipster https://developer.okta.com/blog/2022/10/10/micro-frontends-java-microservices
Microservice is only supported with a gateway. Request headers are customized by gateways. If you want a standalone microservice, you may want to create a monolith without client.
Hi @AffiTheCreator ,
you should still be able to authenticate yourself and access the microservices api directly without gateway in generated microservices. (i have not enabled service discovery for this scenario, it can always be added later
you'll need to create a client called internal in keycloak and add it's credentials to your application.yml
src/main/docker/realm-config/jhipster-realm.json # it seems to have internal client config, but it didn't get created in keycloak 23 (my local setup)
I'll attach a postman collection and yo-rc.json which you can use to generate microservice and test the scenario.
Jhipster.postman_collection.json ) .yo-rc.json
cc: @atomfrede @mshima
@jainhitesh9998 thanks for the info.
We actually mean that we only support our microservices architecture using our own gateway and have CI tests for this use case. Of course it's possible to customize the application to do anything using spring, but it's not supported by JHipster.