Skip to content
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

Unable to revoke non-admin users #67

Closed
5 of 6 tasks
emteknetnz opened this issue Apr 21, 2021 · 4 comments · Fixed by #68
Closed
5 of 6 tasks

Unable to revoke non-admin users #67

emteknetnz opened this issue Apr 21, 2021 · 4 comments · Fixed by #68
Assignees

Comments

@emteknetnz
Copy link
Member

emteknetnz commented Apr 21, 2021

Non-admin user isn't able to revoke their own sessions.

With a test user in the group "Content authors", when attempting to revoke a session I see a red toast "Could not log out of session. Try again later"

Originally noted on this pull-request #62 (comment)

ACs

  • Non-admin users are able to revoke their own sessions
  • Admin users are able to revoke their own sessions
  • Behat and cucumber studio test are updated to require CMS users with restricted access.
  • Logout end point is covered by functional test to make sure anyone can terminate sessions and the CSRF token is enforced

Pull request

@maxime-rainville
Copy link

I've updated the ACs

I spent some time trying to solve this through #62. There's a couple thoughts:

  • LoginSessionController is not covered by any unit test which is probably why we miss this for so long
    • Should test that any user can logout
    • Should test that the CSRF token is enforce
    • Should test the response code
  • DELETE admin/loginsession/remove/123 is a weird REST API call, it should be DELETE admin/loginsession/123
  • A quick fix could be to add private static $required_permission_codes = false; to LoginSessionController. This mimics what CMSProfileController does.
  • It's not clear to me LoginSessionController needs to be a LeftAndMain.
  • It's not clear to me LoginSessionController should even exists. Other form fields that need AJAX endpoint add them as URL handlers directly on the FormField.

In short, this is an example of how cutting corners and not following best practices does not actually save you time in the long run.

@emteknetnz
Copy link
Member Author

emteknetnz commented Apr 22, 2021

My preference is do it all and refactor the whole thing to make it more proper. And of course there's no sane argument against "Do it right first time"

I'm just not sure the time investment is worth it at this stage in the project though? Seems like the refactor itself could easily add several days once peer-review and testing is taken into consideration?

Other than "code less bad" what's the long term benefit here? There's no plan at this stage to develop or extend this module any further beyond this project.

Seems like MVP here is:

  • Add private static $required_permission_codes = false;
  • Should test that any user can logout
  • Should test that the CSRF token is enforce
  • Behat and cucumber studio test are updated to require CMS users with restricted access.

?

@maxime-rainville
Copy link

Obviously, I don't know that if we don't refactor this bit of the system, some horrible calamity will befall us. It's totally possible - even probable - that we could get away with the suggested MVP and never have to look at this bit of code ever again.

But it's worth pointing out that this refactor is relatively cheap right now:

  • It's a very small piece of code that can easily be copy pasted in another class
  • Fortunately, there's no unit test for this class right (which on another level is absolutely horrible and disgusting)
  • We don't have any API commitments right now.

If we ship this like this in version 1.0.0, we're stuck keeping it like this forever.

On a side note that's probably more relevant for a post-project retro, there seems to have been very little planning around the architecture of this module or review of the pre-existing implementation. I would argue that this led to a lot of those late critical issues:

@emteknetnz
Copy link
Member Author

Cucumber test looks good

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 a pull request may close this issue.

2 participants