Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

User Management UI #511

Merged
merged 60 commits into from
May 17, 2022
Merged

User Management UI #511

merged 60 commits into from
May 17, 2022

Conversation

LKCSmith
Copy link
Contributor

@LKCSmith LKCSmith commented May 12, 2022

Purpose

This adds the User Management UI to ops

Changes

  1. Add UI table to list all existing users
  2. Ability to search for users on the table (fuzzy search)
  3. Pagination for table when 25+
  4. Can add a new user
  5. Can edit a user's info (username is always uneditable, as an admin, I can edit any user's name, as the user that is currently logged in, I can change my own password)
  6. I can delete a user

Note/Asks for reviewers:

  1. I would like an extra check on the safety of entering and updating a user's password and make sure this is good from a security POV.

Checklist

  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Closes #357
Closes #358
Closes #359
Closes #360

@LKCSmith LKCSmith marked this pull request as ready for review May 13, 2022 17:27
@LKCSmith LKCSmith changed the title DRAFT: User Management UI User Management UI May 13, 2022
fidesops.toml Outdated
@@ -25,5 +25,5 @@ DRP_JWT_SECRET="secret"
TASK_RETRY_COUNT=0
TASK_RETRY_DELAY=1
TASK_RETRY_BACKOFF=1
REQUIRE_MANUAL_REQUEST_APPROVAL=false
REQUIRE_MANUAL_REQUEST_APPROVAL=true
Copy link
Contributor

@seanpreston seanpreston May 13, 2022

Choose a reason for hiding this comment

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

Can we change this back to false? Right now the spec. is for Fidesops to default to automatically approving privacy requests, so it's causing the API tests to fail as they expect this to be happening.

Copy link
Contributor

@seanpreston seanpreston left a comment

Choose a reason for hiding this comment

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

Hey @LKCSmith great start! I've spent some time functionally testing this afternoon and found the following to address:

  • User is prompted to login inconsistently on view change — were you experiencing this during development?
  • No error message in UI for user creation 422s (e.g. password not strong enough) — this should ideally show the same way as if a username or password is omitted, with a different message
  • View users permission omitted from list — I suspect this was an oversight in the design? What happens is that new users created are not able to view users in the system, even if they are able to create them
  • Login screen asks for email, should read username for now — not directly related to this PR but would be nice to correct
  • Privileges toggles not working correctly (unless this is intentional and I'm not across the decision?)
    • Viewing policies auto toggles viewing datastore connections
    • Create policies auto triggers approve subject requests
    • Can’t remove dependencies ^

@LKCSmith
Copy link
Contributor Author

@seanpreston

User is prompted to login inconsistently on view change — were you experiencing this during development?
I wasn't, and I am not experiencing this locally this morning either. Are you noticing a specific navigation around the app that causes this? I've tried jumping around all over but couldn't trigger this bug.

No error message in UI for user creation 422s (e.g. password not strong enough) — this should ideally show the same way as if a username or password is omitted, with a different message
Will work on this now 🙂

View users permission omitted from list — I suspect this was an oversight in the design? What happens is that new users created are not able to view users in the system, even if they are able to create them
Added, although I don't think that alone resolves the issue. I also added a checkbox for 'View users'. Should this as well as 'View roles' be automatically checked for each user created?

Login screen asks for email, should read username for now — not directly related to this PR but would be nice to correct
Fixed!

Privileges toggles not working correctly (unless this is intentional and I'm not across the decision?)
Viewing policies auto toggles viewing datastore connections
Create policies auto triggers approve subject requests
Can’t remove dependencies ^

I'm not experiencing these bugs locally either. Maybe you can demonstrate to me on a call?

Copy link
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

Wow, nice job getting this all set up! 💪

Here are also some comments from playing around locally:

  • Creating a new user doesn't tell me which fields are required but doesn't let me save if there's no password
    • Only says it's required if you have touched it
  • Unchecking a permission and saving seems to work, but get a POST error in the console
POST http://0.0.0.0:8080/api/v1/api/v1/user/fid_3abb8caf-29a5-48d5-a4d9-b8c362ccf9c6/reset-password 404 (Not Found)
  • No error when trying to delete a user and the usernames don't match
    • Can't tab between the two fields of username and enter username again
  • Can edit the superuser and make it so they are stuck and can't edit anymore :(
    • Repro steps:
      1. Edit your superuser and remove some permissions (I removed "Approve subject requests", "view datastore connections", "create or update datastore connections", "delete datastore connections")
      2. After you save, there will be no users listed in the User Management page (not sure if one of those perms I removed controls that? I purposefully didn't remove the "view users" policy)
    • Looks like this is because of a 403 forbidden, though I'm not sure which of those permissions makes me unable to view users anymore. Also, it seems undesirable to let the superuser get themselves into this state.

return result;
})
.then((result) => {
console.log('result', result);
Copy link
Contributor

Choose a reason for hiding this comment

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

probably want to clean up console.log's

router.replace('/user-management');
});
},
validate: (values) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

outside the scope of this PR, but I would vote to use something like Yup for validation https://formik.org/docs/guides/validation

id={`scopes-${policy.privilege}`}
name="scopes"
value={policy.scope}
isDisabled={policy.scope === 'privacy-request:read'}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe pull out 'privacy-request:read' as a constant?

Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity, how did you get rid of that uncontrolled vs controlled input console log msg?

old_password: existingUser?.password,
new_password: values.password,
};
console.log(updatePasswordbody);
Copy link
Contributor

Choose a reason for hiding this comment

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

def want to remove this one :)

Copy link
Contributor

Choose a reason for hiding this comment

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

and while you're at it.... another nit: updatePasswordbody --> updatePasswordBody

scopes: [],
},
onSubmit: async (values) => {
const host =
Copy link
Contributor

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 const gets used anywhere?


if (!/[\W]/.test(values.password)) {
errors.password = 'Password must have at least one symbol.';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

id={`scopes-${policy.privilege}`}
name="scopes"
// @ts-ignore
isChecked={values.scopes[policy.privilege]}
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm what does typescript complain about it here? does it just need to be coerced into a boolean via !!?

>
Save
</Button>
</chakra.form>
Copy link
Contributor

Choose a reason for hiding this comment

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

is this form almost the same as edit user? are there any parts that could be refactored so that we don't have to make changes on both sides?

import { User } from '../user/types';
import { useUpdatePasswordMutation } from '../user/user.slice';

function UpdatePasswordModal(user: User) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how come we don't use formik for this one? It's simpler than the other form, but for handling errors and such, may still want to go through formik

export const userPrivilegesArray: UserPrivileges[] = [
{
privilege: 'View subject requests',
scope: 'privacy-request:read',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think one day, not necessarily in this PR, we will want to pull these out as constants, such as like what is in the backend https://github.com/ethyca/fidesops/blob/user-management/src/fidesops/api/v1/scope_registry.py so that it'll be a lot easier in code to refer to the permissions

@elliotbonneville
Copy link
Contributor

elliotbonneville commented May 17, 2022

Absolutely crushing it, Laura. Love how fast you onboarded and that you're knocking out such a big feature already. Great work! 🎉

I think the functional testing Sean and Allison did is quite thorough. In addition to what they've found, I've noticed the following things:

  • Logging in, then navigating around User Management pages triggers logout sporadically (and then you need to log in twice)
  • Clicking links in the breadcrumbs nav triggers a full page reload (should use Next link component to avoid that)
  • Spacing issues throughout the layout (mostly just padding tweaks for eyecandy – not critical path)
  • Submit button for creating a user should read 'Create' instead of 'Save'
  • There shouldn't be a placeholder in the login screen
  • Can't tab through inputs in the Delete User modal for some reason
  • Password input for new users is a bit laggy (this may indicate state mismanagement on some level)
  • Username is not passed to dropdown menu

Of these, the only critical bug is the sporadic logout issues. However, since the functionality is there, I'm comfortable merging, provided we address this bug this week (something I'm happy to take on today / tomorrow). The rest of these don't need to be addressed in these PR either – I'm just dropping them here for future reference.

I also have a number of stylistic / cleanup related nitpicks w/r/t the code. I began to make individual comments to address them, but I think in this case it might be more efficient for me to clean them up on my own after this PR is merged, and then we can do a bit of a post mortem next week and review some of the changes I made.

And to be clear, when doing PR reviews in general, it's generally my opinion that any syntax or style things that come up are more a function of the scope of work and the time constraint around it than of somebody's personal coding style. So don't feel like any changes I make are because mistakes were made or that there were glaring oversights. I totally recognize that it's more just the sheer volume of code leaves plenty of spaces for bugs to hide and makes cleanup difficult + time-consuming :)

Finally, I'd like to address the scope of this PR – I think going forward we'll want to try to break features down into smaller, more manageable PRs so that we don't get into a place of overwhelm like this again. That would help with both finding bugs, general feelings of overwhelm, and also give more time and space to do cleanup.

Again, amazing job with this! Very happy to see it land. 🥳 Overall, I'm happy to merge this, and then we can schedule in some cleanup over the next week or two.

@seanpreston seanpreston merged commit 9c58e7e into main May 17, 2022
@seanpreston seanpreston deleted the user-management branch May 17, 2022 22:02
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
* Start setup on user management feature

* User form

* Add set-up for some actions and profile page with form

* Work on new user

* Update row

* Clean-up navbar

* Set active classnames in nav links

* Add privileges

* Cancel functionality on new user form

* User slice

* Delete user modal

* Breadcrumbs and delete user modal as menuitem

* User POST in slice

* Update slice

* Create through slice

* Set-up for future api work

* Start get

* Create and Delete set-up

* Delete user validation

* Amend

* User search

* Edit tweaks

* User privileges

* Ui tweaks

* Permissions

* Add additional user info to table

* Checkboxes

* Some small form fixes

* Refreshes and checkboxes on load

* Default values

* Split out edit and new forms for easier flow and initial value in formik handlin

* Type checking

* Some file cleanup

* Pagination;

* Some style tweaks

* Change checkbox color

* Checkboxes

* Cleanup

* Remove unused effect

* Update session with user info and fix client console warning for controlled input

* Update session in pages

* Some form cleanup

* Clean index page

* Edit user permissions checks

* Feedback

* Remove duplicate

* Fix checkbox bug

* Password update

* Add error handling on new user form

* Change password modal

* Remove rogue console

Co-authored-by: Laura Smith <laurasmith@Lauras-MacBook-Pro.local>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants