Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT Token Should bo Compatible with Jhipster (Java Version) #260

Open
pietromarrone opened this issue Jan 4, 2022 · 1 comment
Open
Labels
Feature New feature

Comments

@pietromarrone
Copy link

Describe the bug
In a microservices architecture it is possible that some services are written in Java (JHipster) while others in NodeJs (NHipster), it would be advisable to have a compatible JWT Token.
At the moment this does not happen, the token expected by NHipster is with HS256 encoding, even by changing this encoding to the token is not compatible as it differs in the authorities attribute name.

To Reproduce
Steps to reproduce the behavior:

  1. Create Gateway with Jhipster Blueprint
  2. Create Microservice Application using NHipster blue print
  3. Authenticate with Gateway
  4. Use Generated JWT calling (Microservice Application using NHipster) protected api

Expected behavior
Authentication/Authorizazion success

Screenshots

  • JWT by NHipster
    JWT_NHipster
  • JWT Token by JHipster
    JWT_JHipster

Desktop (please complete the following information):

  • OS: Indepentent
  • Browser Indepentent
  • Version NHipster 2.0.0

NHipster configuration

  • Version NHipster 2.0.0
@ghost ghost added the Feature New feature label Jan 4, 2022
@ghost
Copy link

ghost commented Jan 4, 2022

Thanks for the issue! It is a feature that it would be great to implement. If you want to contribute, is simple.

  • Try to specify algorithm property in signOptions (after expiresIn) for authModule as:
 signOptions: {
            expiresIn: '3h',
            algorithm: 'HS512'
 }
  • You can change the payload interface, changing username in sub, and authorities array in an auth string.
    Please attention because you have to change also the AuthService . So do some trials in your microservice, maybe replacing the authorities array in string could affect the authorization pattern.

You can do these changes on your microservice and after adding to the templates.

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant