Skip to content

Conversation

JenySadadia
Copy link
Collaborator

Depends on #292 for user profile changes.

api.main: set node ownership to a hierarchy of nodes

When submitting a hierarchy of nodes using put_nodes, set node ownership information to all the nodes recursively.
Also, use the authorize_user method for user authorization upon receiving the request.

Jeny Sadadia added 9 commits July 13, 2023 16:16
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>
`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>
When submitting a hierarchy of nodes using `put_nodes`,
set node ownership information to all the nodes recursively.
Also, use `authorize_user` method for user authorization
upon receiving the request.

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Copy link
Collaborator

@gctucker gctucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this depends on user profile changes, just the Node.owner field needs to be populated. Which model it's using doesn't make a difference, as far as I can tell.

@JenySadadia
Copy link
Collaborator Author

I don't think this depends on user profile changes, just the Node.owner field needs to be populated. Which model it's using doesn't make a difference, as far as I can tell.

Please see below line of change. It needs to have user.profile field.

hierarchy.node.owner = user.profile.username

@gctucker
Copy link
Collaborator

Ah yes, thanks. Well if we don't have the UserProfile changes then we can just do node.owner = user.username. But I see what you mean.

@gctucker gctucker added this pull request to the merge queue Jul 20, 2023
Merged via the queue into kernelci:main with commit 771ab5e Jul 20, 2023
@JenySadadia JenySadadia deleted the node-hierarchy-ownership branch July 20, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants