-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fixes #12374: Protect user api #13048
Conversation
0e51e4b
to
705885f
Compare
What about?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should expose just login field by default, WDYT?
generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
Outdated
Show resolved
Hide resolved
generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
Outdated
Show resolved
Hide resolved
generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
Outdated
Show resolved
Hide resolved
generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
Outdated
Show resolved
Hide resolved
Yeah, I thought about separating the public and admin-only controller logic into two separate class, and also the tests, but it looked a bit bigger change... But after staring the code longer, I think, this is necessary, for cleanliness. |
Good question, I don't know, what would be a good default. My initial thought was that, if we send all the names, the frontend could format it freely, as 'FamilyName GivenName (login)' or 'FirstName LastName (login)' - etc. But this i18n requirement looks very corner case, so maybe a generic 'Name' field could be enough - so it will be easy to override in the server, how to format the name. |
d2bd710
to
4880ddc
Compare
@gzsombor : what's the state of this PR ? As it's a little breaking change, it would be cool to have it for v7. But I think we can go for v7 beta release without it, if it's not ready yet |
…nt and PublicUserDTO for public consumptions
Co-authored-by: Marcelo Shima <[email protected]>
React changes
Generate separate resources
…tyField name when the entity is a User
4880ddc
to
249ec3f
Compare
Sorry for the delays. The backend code works correctly, and React frontend works too. I haven't verified the Angular and Vue frontends yet.
|
Do relationships are using PublicUser or User? About |
Yes, you are totally right. I've just started thinking about today, that how come, that I haven't encountered the same problem in the backend, which I've faced on the frontend, and came the conclusion, that I haven't solved the problem totally. |
0af66b5
to
a06d481
Compare
a06d481
to
ddb83bf
Compare
I just remembered that maybe is better to call it JhiUser AdminUser, current database is JhiUser. And it's better to rename the component to don't confuse the developer.
user.model.ts:
What do you think? |
I'm not sure I like this. But then again, I'm against prefixes as a general
rule. 😉
…On Tue, Dec 15, 2020 at 18:38 Marcelo Shima ***@***.***> wrote:
I just remembered that maybe is better to call it JhiUser AdminUser,
current database is JhiUser.
And it's better to rename the component to don't confuse the developer.
- UserRepository.java -> JhiUserRepository.java
- UserService.java -> JhiUserService.java
- UserResource.java -> JhiUserResource.java
- UserMapper.java -> JhiUserMapper.java
- UserResourceIT.java -> JhiUserResourceIT.java
- PublicUserService.java -> UserService.java
- PublicUserResourceIT.java -> UserResourceIT.java.ejs
user.model.ts:
- PublicUser -> User
- User -> JhiUser
What do you think?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13048 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAELZEAU3PFHVPQIZRQL3DSVAFQNANCNFSM4TWRGFNQ>
.
|
Don’t like either just think |
I like this better than adding a prefix. Why can't we just create a |
I rather too not add a Jhi prefix, it won't help in the understanding, what's the difference between a JhiUserDTO and a UserDTO - (luckily, the jhi prefix is only used for the table names, so it's pretty easy to remove it).
Using UserDTO for the public view would have that advantage, that when other entities refer to a user, they could just use the general mapping that from Xyz entity, we get |
I'm sorry, I didn't follow closely the comments here. I didn't expect so much complexity about this feature.
|
In my opinion, we should not create another class. |
No, it's not separate API for separate user roles, but separate API for different functionality. One API for managing reference data/master data - in this case user data, and one API to consume this data in a tailored way. |
Thinking more about the DTO, maybe just 1 DTO is enough. |
generators/server/templates/src/test/java/package/web/rest/PublicUserResourceIT.java.ejs
Show resolved
Hide resolved
@gzsombor : very good job. If you feel confident, feel free to go ahead and merge it tomorrow plz (after my minor comment) |
in fact, it must be merged, as there are some breaking changes. So let's have it for v7 beta |
Move current '/api/users' to '/api/admin/users' and protect it with admin role.
Create a compatible '/api/users' with filtered data.
Currently, only the backend changes are implemented
Please make sure the below checklist is followed for Pull Requests.
When you are still working on the PR, consider converting it to Draft (bellow reviewers) and adding
skip-ci
label, you can still see CI build result at your branch.