1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 17:22:42 +01:00
phorge-phorge/src/applications/project
epriestley 4d89afcc61 Remove requireCapabilities() from ApplicationTransactionEditor and require CAN_EDIT by default
Summary:
Depends on D19585. Ref T13164.

Almost all transactions require CAN_EDIT on the object, but they generally do not enforce this directly today. Instead, this is effectively enforced by Controllers, API methods, and EditEngine doing a `CAN_EDIT` check when loading the object to be edited.

A small number of transactions do not require CAN_EDIT, and instead require only a weaker/lesser permission. These are:

  - Joining a project which you have CAN_JOIN on.
  - Leaving a project which isn't locked.
  - Joining a Conpherence thread you can see (today, no separate CAN_JOIN permission for Conpherence).
  - Leaving a Conpherence thread.
  - Unsubscribing.
  - Using the special `!history` command from email.

Additionally, these require CAN_INTERACT, which is weaker than CAN_EDIT:

  - Adding comments.
  - Subscribing.
  - Awarding tokens.

Soon, I want to add "disabling users" to this list, so that you can disable users if you have "Can Disable User" permission, even if you can not otherwise edit users.

It's possible this list isn't exhaustive, so this change might break something by adding a policy check to a place where we previously didn't have one. If so, we can go weaken that policy check to the appropriate level.

Enforcement of these special cases is currently weird:

  - We mostly don't actually enforce CAN_EDIT in the Editor; instead, it's enforced before you get to the editor (in EditEngine/Controllers).
  - To apply a weaker requirement (like leaving comments or leaving a project), we let you get through the Controller without CAN_EDIT, then apply the weaker policy check in the Editor.
  - Some transactions apply a confusing/redundant explicit CAN_EDIT policy check. These mostly got cleaned up in previous changes.

Instead, the new world order is:

  - Every transaction has capability/policy requirements.
  - The default is CAN_EDIT, but transactions can weaken this explicitly they want.
  - So now we'll get requirements right in the Editor, even if Controllers or API endpoints make a mistake.
  - And you don't have to copy/paste a bunch of code to say "yes, every transaction should require CAN_EDIT".

Test Plan:
- Tried to add members to a Conpherence thread I could not edit (permissions error).
- Left a Conpherence thread I could not edit (worked properly).
- Joined a thread I could see but could not edit (worked properly).
- Tried to join a thread I could not see (permissions error).
- Implemented `requireCapabilites()` on ManiphestTransactionEditor and tried to edit a task (upgrade guidance error).
- Mentioned an object I can not edit on another object (works).
- Mentioned another object on an object I can not edit (works).
- Added a `{F...}` reference to an object I can not edit (works).
- Awarded tokens to an object I can not edit (works).
- Subscribed/unsubscribed from an object I can not edit (works).
- Muted/unmuted an object I can not edit (works).
- Tried to do other types of edits to an object I can not edit (correctly results in a permissions error).
- Joined and left a project I can not edit (works).
- Tried to edit and add members to a project I can not edit (permissions error).

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13164

Differential Revision: https://secure.phabricator.com/D19586
2018-08-24 17:45:56 -07:00
..
__tests__ Add a "members of all projects" (vs "...any project") custom policy rule to the upstream 2018-06-12 11:51:51 -07:00
application Add Dashboards as a default pinned application 2017-03-21 11:10:20 -07:00
capability Add default View, Edit, and Join Policies to Projects 2014-11-21 11:22:17 -08:00
command Implement a "!projects" mail command 2015-04-01 11:51:51 -07:00
conduit Migrate Project color to modular transactions 2017-05-18 16:46:06 -07:00
config Choose default project image by icon 2017-07-09 11:41:02 -07:00
constants Allow workboard background colors to be configured 2016-02-16 08:15:12 -08:00
controller Put "Subprojects" on top of "Milestones" in the Project UI 2018-08-01 13:49:42 -07:00
customfield Fix errors found by PHPStan 2017-02-17 10:10:15 +00:00
edge Replace subscribe/unsubscribe for projects with explicit mail setting 2016-01-19 19:39:02 -08:00
editor Remove requireCapabilities() from ApplicationTransactionEditor and require CAN_EDIT by default 2018-08-24 17:45:56 -07:00
engine Improve Space behavior for subprojects and milestones 2018-07-31 10:22:39 -07:00
engineextension Modularize the "jump nav" behaviors in global search 2018-02-14 18:08:07 -08:00
events Property list view on Diffusion commits should show build status but not Subscriptions, Projects, or Tokens 2017-12-01 18:16:26 +00:00
herald Add "Committer's projects" and "Author's projects" fields to Herald commit rules 2018-02-27 14:33:12 -08:00
icon Test 0 and "" cases in Project Icon Config 2017-07-10 12:01:22 -07:00
interface Roughly implement milestone columns on workboards 2016-02-03 16:37:59 -08:00
lipsum Migrate Project status to modular transactions 2017-05-18 11:36:13 -07:00
mail phtize all the things 2015-05-22 21:16:39 +10:00
menuitem Prevent hiding the PhabricatorProjectDetailsProfileMenuItem 2017-12-23 11:38:05 -08:00
phid Add Editor-based mail stamps: actor, via, silent, encrypted, new, mention, self-actor, self-mention 2018-02-06 04:04:52 -08:00
policyrule Add a "members of all projects" (vs "...any project") custom policy rule to the upstream 2018-06-12 11:51:51 -07:00
query Document the Ferret "=" operator and improve related documentation 2018-07-23 12:44:43 -07:00
remarkup Fix spelling 2017-10-09 10:48:04 -07:00
search Support Ferret engine in Projects 2017-09-07 13:24:23 -07:00
searchfield Fix a bad call when prefilling ApplicationSearch from ?projects=some_slug 2016-02-08 10:44:33 -08:00
storage Improve Space behavior for subprojects and milestones 2018-07-31 10:22:39 -07:00
typeahead Add an "only()" edge logic constraint, meaning "only the other constraints, exactly" 2017-09-06 12:16:06 -07:00
view Add Spaces information to the project list UI 2018-07-31 10:24:51 -07:00
xaction Move the "Can Lock Projects" check from requireCapabilities() to transaction validation 2018-08-16 10:56:00 -07:00