-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Microservice without user management shall not generate User and Authority entities as well as related resources #18755
Comments
Looking into the sources:
In my unterstanding authenticationTypeOauth2 means that authentication is outsourced to some external provider ( keycloak, okta , whatever ) . This there will be no real user data in the application - so there is no point to have this servince at all |
Another observation:
Activation email templates and user related exceptions are skipped when no user management |
Duplicate of #16074. |
Which is also mine but did not received attention. This one is more specific though. From my point of view it looks as if there were some mixed up boolean conditions. |
They exist so you can have relationships to the |
I know that I can make relationship to User entity. But I do not need to. In my opinion, when I do not have user management in the backend microservice ( "skipUserManagement": true set explicitely, oauth2 authentication selected ) there shall be no user entity in this microservice at all (and also authority and supporting classes) Current version generates user entities for all microservices in the application - which is kind of redundant anyway. Frontends do not generate user entitites just DTOs - which kind of makes sense to exract user data from auth tokens an deliver it to frontend code. |
@ko5tik can you provide a PR making user entities conditional on user relationship existence? |
Conditionality shall be on "skipUserManagement" option and there is definitely an issue that user entities are generated in all microservices in case there are more than one. Only scenario where relationship with to user entity makes sense for me is monolith with session or jwt authentication - in this case users are managed inside the app, emails are sent etc. Will work on pull request. |
If we follow the advice of both of you , thus only generating user in this cases:
We would be able to remove that 'skipusermanagement' in V8, WDYT? |
It will still be needed for public services with no user management. Unless it makes sense to create authenticationType no. |
User must be generated if User relationship exists at oauth2 authenticationType. IMO the best approach is to introduce a new configuration like |
In oauth2 real user / authority entity used for authentication resides somewhere else ( if it exists at all ) - what exactly is this generated user entity in context of microservice? At the moment it is just an entity ( actually 2 ) without any special meaning, which is neither populated not synched with anything and serves no real purpose. There are no relatioships over the microservice boundary - so it there is no user management ( and this option is generated by default for the microservice / 0auth ) there shall be no user - as this is done for the frontends |
I had the use case on one project: I made kind of a Project catalog for my company's InnerSource initiative. |
In a similar situation I used user principal as a field in "owned" object (which is available to the services via securoty utils) to check of accessibility of certain object for invocation / filtering lists. Of course I had to create separate methods. I surely could have extra entity and relationships for this purpose - but this entity would have nothing to do with real authentication, and will have to be synched with real database anyway. My proposal is not to generate those user entities if it is explicitly specified that they are not desired (skip user management = true - which is default for microservices anyway) |
So looking deeper into issue - actual sources skip generation of user entities for microservice or 0auth authentication - but only when called as "jhipster entitites" . when invoked as just "jhipster" those config settings are not honored. |
After some debugging I discovered strange thing:
( bootstrap/index.js @ 219 ) @Tcharl @mshima : can you comment of this? This line forces user entity generation for all microservices with 0auth And disableIUserManagemt is set to true for microservices by default anyway..... |
dono |
This is expected. |
It is already conditional ( skipUserManagement ) for everything but oauth2 - I do not grok this logic. Actual state is: all backend microservices get user/authority entities generates whether they need it or not when Oauth2 is activated ( not needed by default ) when "app" generator is invoked ( "jhipster" ) , but not when "jhipster entitites" is invoked. |
About the oauth2 + User relationship, ideally:
|
What about generating the User service when this statements are in jdl:
|
This issue is stale because it has been open for too long without any activity. |
We should implement this to simplify and reduce generated files. |
@DanielFran bug bounty claimed https://opencollective.com/generator-jhipster/expenses/211710. |
@mshima approved |
Overview of the feature request
When "skipUserManagement": true is set for microservice, User and Authority entities as well as supporting classes and services are generated even is there is no use for them at all. And when 0Auth is used as login option there is no management of user information at all in the application.
I suggest skipping generation of those classes unless they are explicitely requested ( say, when application uses JWT or session
and those artifact are going to be managed in one of the microservices which has this option enabled explicitely )
Motivation for or Use Case
Those unused entities pollute database schema and mapping files and namespaces , and this confuse developers and managers.
This leads to extra work to remove them form codebase upon each regeneration. And this clearly sucks and lowers acceptance of jHipster as tool.
Related issues or PR
none found yet
The text was updated successfully, but these errors were encountered: