-
Notifications
You must be signed in to change notification settings - Fork 21
Add user profile model #292
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
Conversation
06d5a55
to
e258859
Compare
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.
Let's get the basic user functionality merged and available first, then we can see how to deal with this as a follow-up.
@JenySadadia I think we can have the functionality in place to create user accounts and have node owners without an implementation for a user profile, which can be added later. So I would suggest to draw the line there, to have all the basic things implemented and completely done with just User and a user name, groups, password field and the corresponding API and CLI and documentation bits all aligned first. Then once we have this stable base, users can already start using it, and we can add support for profiles as an incremental step. How does that sound? |
Yes, we can do that. However, since we already have a few PRs for user profile support, it won't be that much time-consuming to tweak them and merge them. If we add the profile later after the early access, we would need to migrate all the existing users and also revisit the changes from these PRs. |
My fear is that there might still be a couple of weeks of tweaks before this gets merged, which would delay the early access rollout. Avoiding this seems to me like a smaller impact than a migration later on. |
Create a separate model to store user information that will be accessible publicly and can be updated by user. Store private information along with profile to `User` model and only admins will be allowed to access/update it. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
How about I tweak all the related PRs today itself or latest by tomorrow? I don't think it would take up much time. |
Alright let's try that. |
e258859
to
7ff3445
Compare
`User` model has been restructured to have a user public profile in `User.profile` field. Use the field for the related changes in Authentication module. Authentication method `get_current_user` will need to get `User` object based on `profile`. For that, implement `Database.find_one_by_attributes` method to find user object matching username from user profile. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update `post_user` handler to create user profile object and use it to create user object. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update `post_node` handler to use user profile to get node owner's username. This change is due to restructuring user model with `UserProfile`. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update unit tests to accommodate changes in the `User` field related to user profile. Also, add mock function for `Database.find_one_by_attributes` and use it for token handler tests. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update `authorize_user` method to use user profile to get node owner's username and groups. This change is due to restructuring user model with `UserProfile`. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update e2e tests to accommodate changes in the `User` field related to user profile. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Update `setup_admin_user` method to use user profile to while creating admin user. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
7ff3445
to
c4bf969
Compare
Updated all existing users on staging instance to have Tested OK on staging:
|
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.
I can see a number of issues with user profiles which haven't been solved or even properly identified yet, and we don't really need user profiles for early access. So I still think we should put this aside for now and keep it as a follow-up development activity. We will need a way for users to change their passwords for early access and having it blocked because the user profile implementation is not ready is going to cause some problems.
username: str | ||
hashed_password: str = Field(description="Hash of the plaintext password") |
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.
I wonder if these 2 fields should rather be in the User model rather than User Profile. I think the profile part hasn't been well defined yet. The password will most likely require a dedicated API endpoint to update it, and maybe the username too. In fact, even groups
might be something to keep in User
as it's not something the users should be able to update themselves.
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.
I thought we agreed to move username
, password
, and groups
to user profile. Only passwords should be hidden from the response when we get all user profiles.
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.
Right, I guess that's not very clearly defined then. One thing is about information users can read publicly, then what users can read from their own profile, then what can users update themselves. Users shouldn't be able to escalate their privileges, and passwords shouldn't be readable at all (even encrypted as that facilitates brute-force attacks).
The profiles can be updated using PUT |
A few things from the top of my head:
|
We would need to go through this in more detail, these are just a few things I thought about while reviewing the code. |
Okay. And what about
Yes, that's true. The PUT
We can add another
We are not storing |
I'll reply to this in a more structured way on the GitHub issue. I think we now need to look at a minimal implementation with a public profile set of attributes and then split out things we can leave for later. Also it seems worth investigating if there's a library we can use directly with FastAPI to manage all the user / group side of things. |
This package provides a base user model, user manager, and basic endpoints. https://github.com/fastapi-users/fastapi-users |
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.
As discussed, I think we can have this merged as-is and then rework things slightly to make it safe even if it means some features will be missing. Then we can see if there's anything else that needs to be done for "early access" and update the backlog with things to do for a full production implementation (probably using an existing package, see #304).
username: str | ||
hashed_password: str = Field(description="Hash of the plaintext password") |
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.
Right, I guess that's not very clearly defined then. One thing is about information users can read publicly, then what users can read from their own profile, then what can users update themselves. Users shouldn't be able to escalate their privileges, and passwords shouldn't be readable at all (even encrypted as that facilitates brute-force attacks).
Create a separate model to store user information that will be accessible publicly and can be updated by user. Store private information along with profile to
User
model and only admins will be allowed to access/update it.