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

Add permission check for admins updating user passwords #3394

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

JDutil
Copy link
Contributor

@JDutil JDutil commented Oct 23, 2019

For security purposes administrators should not be able to set a
users password. Only the accounts owner should be able to directly set
their password. administrators should only have the ability to send a
password reset email to the account owner. Otherwise someone working in
customer service or another role could take over a users account in
order to make illegal purchases with their stored credit card
information.

In order to maintain backwards compatibility, and leave more power in
control of the store owner this will leave the current admin role
behavior the same, but anyone creating custom roles will no longer
be able to update passwords unless they explicitly add a change
password permission.

Fixes #438

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

@@ -58,21 +58,4 @@
<% end %>

</div>

<div data-hook="admin_user_form_password_fields" class="col-6">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if we should delete this div with the form fields or not. There maybe stores using this data-hook so I'm thinking that perhaps we should leave it in for backwards compatibility. Although I'm also annoyed the data-hook would have a bad name.

Copy link
Member

Choose a reason for hiding this comment

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

If I got it correctly, I think this div should go into the if statement. I think it will still be evaluated even if the if statement is false, since Deface should do its magic before the erb is rendered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought here was that someone may have a deface customization that's adding non-password related fields here simply because it would be a convenient place to add more user fields. I'm fine putting the div into the conditional statement as well, but I think that may cause customizations to be hidden unintentionally if people are using this data hook for non-password stuff.

Copy link
Member

Choose a reason for hiding this comment

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

I think that if someone is adding some non-password related fields into the password dedicated div it's ok to make this change, we can't handle every scenario. The problem is if someone is using this hook in the insert_after or insert_before deface action, which is legit and the added parts will be hidden at that point. :(

That said, your solution is probably the safest one in terms of backward compatibility.

@JDutil JDutil force-pushed the fixes-438 branch 5 times, most recently from d7e3ca2 to 6fc62e3 Compare October 23, 2019 21:35
Copy link
Member

@tvdeyen tvdeyen 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 agree with removing the feature completely. Can we do this with permissions instead?

At least we should have a button that allows admins to send a password reset mail.

@JDutil
Copy link
Contributor Author

JDutil commented Oct 24, 2019

@tvdeyen a button to send a password reset email was added to solidusio/solidus_auth_devise#146 I can modify this to work based on permissions though.

@JDutil JDutil force-pushed the fixes-438 branch 2 times, most recently from 1b006f3 to edd342a Compare October 24, 2019 16:51
@JDutil JDutil requested a review from tvdeyen October 24, 2019 16:52
@JDutil JDutil changed the title Remove ability to set user passwords Add permission check for admins updating user passwords Oct 24, 2019
@JDutil
Copy link
Contributor Author

JDutil commented Oct 24, 2019

@tvdeyen updated to be permission based 👍

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks.

Note for further PRs. I think it makes sense to ship Solidus with a Customer Support role that must not change

  • users passwords
  • Everything thats under settings
  • store settings

But this is 🤘🏻

@JDutil
Copy link
Contributor Author

JDutil commented Oct 24, 2019

@tvdeyen Yeah I also think it'd be great to start shipping Solidus with some sort of customer service role. Giving every "admin" super user permissions is a bit much by default. That would also help for testing many permission related features.

@tvdeyen tvdeyen mentioned this pull request Oct 25, 2019
6 tasks
@tvdeyen
Copy link
Member

tvdeyen commented Oct 25, 2019

@JDutil agreed, I made #3404

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Left a quick comment about Rubocop, but I'm 👍with the PR's content, thanks!

backend/spec/features/admin/users_spec.rb Outdated Show resolved Hide resolved
For security purposes administrators should not be able to set a
users password. Only the accounts owner should be able to directly set
their password. administrators should only have the ability to send a
password reset email to the account owner. Otherwise someone working in
customer service or another role could take over a users account in
order to make illegal purchases with their stored credit card
information.

In order to maintain backwards compatibility, and leave more power in
control of the store owner this will leave the current admin role
behavior the same, but anyone creating custom roles will no longer
be able to update passwords unless they explicitly add a change
password permission.
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks!

@kennyadsl kennyadsl merged commit 4cd6736 into solidusio:master Nov 6, 2019
@JDutil JDutil deleted the fixes-438 branch November 6, 2019 17:33
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.

Remove admin ability to set a password, replace reset password email trigger.
3 participants