-
Notifications
You must be signed in to change notification settings - Fork 21
api.main: GET users and user profiles #279
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
/users
endpoint/users
endpoint
This is returning the full User documents including the hashed passwords, so adding |
Yes, this needs to be tweaked once we add user profile model. |
Even then, I'm not sure all the user profile should be public. So we could have this in the database:
as a way to allow POST queries to let the user update the Then we would also have this model, not stored in the database but only part of the user API:
|
Another way to look at this, along the lines of the discussion around updating models for node ownership, is to just have a User model for the database and a UserProfile model shared with the public. Then the application would encode rules about what fields can be read or written depending on the user initiating the query, rather than at the API validation level. I think that's actually almost inevitable as things like What is going to be more important is that we use the same UserProfile model for PUT and GET requests, so we get the same data in and out even if that's not directly an object stored in the database. Then admins should be able to POST, PUT and GET the full User objects which would be directly the same model as in the database. The only potential exception to this that I can see is for the password field, maybe it should never be returned at all and therefore not included in the data models used by the API but handled with a dedicated endpoint instead. |
Please see #292 |
64ce045
to
e932649
Compare
Updated the PR to get user public profiles. |
Well, #292 is not what I was suggesting with a different model for the API and for the database but I'll take a look next week. I think we basically need to get the simplest implementation merged to get the feature enabled and then we can extend it as second priority. |
I have implemented |
e932649
to
a977ea4
Compare
Commands will look like:
|
/users
endpoint
Added handler to get user profile by ID:
Added a handler to get user model by ID:
|
f196609
to
fc9f13b
Compare
Updated the PR to accommodate user profile changes. |
Tested OK on staging:
|
fc9f13b
to
f1a003e
Compare
Adding the skip label as this is returning the hashed passwords again. |
Yes, I need to exclude it. |
f1a003e
to
44af1e9
Compare
Excluded password from |
But what about not including passwords in the profile model? I think there are a number of things to clarify before we can resolve this and complete the implementation. |
I have moved all the editable fields by the user to |
Please see #292 (comment) |
Implement an endpoint to get public profile details of all available users. It also accepts request query parameters to get matching user. e.g. `http://API_URL/users?username=test` This will exclude password field from the response for security reasons. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Implement an endpoint to get all available user models. The user model will contain private information along with public user profiles. Thus, the endpoint will be accessible by admin users only. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Implement an endpoint to get user model matching provided user ID. The endpoint will be accessible by admin users only and will not include password in the response. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
44af1e9
to
44e6d08
Compare
|
||
@app.get('/users', response_model=PageModel, | ||
response_model_exclude={"items": {"__all__": {"profile": { | ||
"hashed_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.
OK I think that should be fine for now.
Fixes #300
Implement an endpoint to get users.
It also accepts request query parameters to get matching user.
e.g.
http://API_URL/users?username=test