Skip to content

Commit

Permalink
Space supporter process write permissions (#2359)
Browse files Browse the repository at this point in the history
* space application supporter can access specific "process" GET endpoints.
- add some information about redacted info in the docs
* Space supporter can update processes

#2211

Co-authored-by: Weyman Fung <weymanf@vmware.com>
Co-authored-by: Merric de Launey <mdelauney@pivotal.io>
Co-authored-by: Galen Hammond <galenh@vmware.com>
Co-authored-by: Belinda Liu <bliu@pivotal.io>
Co-authored-by: Mona Mohebbi <mmohebbi@pivotal.io>
  • Loading branch information
5 people committed Jul 1, 2021
1 parent c70f8ec commit 301aeaf
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 162 deletions.
10 changes: 5 additions & 5 deletions app/controllers/v3/processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def index

if app_nested?
app, dataset = ProcessListFetcher.fetch_for_app(message, eager_loaded_associations: Presenters::V3::ProcessPresenter.associated_resources)
app_not_found! unless app && permission_queryer.can_read_from_space?(app.space.guid, app.organization.guid)
app_not_found! unless app && permission_queryer.untrusted_can_read_from_space?(app.space.guid, app.organization.guid)
else
dataset = if permission_queryer.can_read_globally?
ProcessListFetcher.fetch_all(message, eager_loaded_associations: Presenters::V3::ProcessPresenter.associated_resources)
else
ProcessListFetcher.fetch_for_spaces(
message,
space_guids: permission_queryer.readable_space_guids,
space_guids: permission_queryer.readable_application_supporter_space_guids,
eager_loaded_associations: Presenters::V3::ProcessPresenter.associated_resources
)
end
Expand Down Expand Up @@ -109,16 +109,16 @@ def stats
def find_process_and_space
if app_nested?
@process, app, @space, org = ProcessFetcher.fetch_for_app_by_type(app_guid: hashed_params[:app_guid], process_type: hashed_params[:type])
app_not_found! unless app && permission_queryer.can_read_from_space?(@space.guid, org.guid)
app_not_found! unless app && permission_queryer.untrusted_can_read_from_space?(@space.guid, org.guid)
process_not_found! unless @process
else
@process, @space, org = ProcessFetcher.fetch(process_guid: hashed_params[:process_guid])
process_not_found! unless @process && permission_queryer.can_read_from_space?(@space.guid, org.guid)
process_not_found! unless @process && permission_queryer.untrusted_can_read_from_space?(@space.guid, org.guid)
end
end

def ensure_can_write
unauthorized! unless permission_queryer.can_write_to_space?(@space.guid)
unauthorized! unless permission_queryer.untrusted_can_write_to_space?(@space.guid)
end

def process_not_found!
Expand Down
11 changes: 6 additions & 5 deletions docs/v3/source/includes/resources/processes/_get.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ Content-Type: application/json
`GET /v3/apps/:guid/processes/:type`

#### Permitted roles
|
Role | Notes |
--- | ---
Admin |
Admin Read-Only |
Global Auditor |
Org Manager |
Space Auditor |
Global Auditor | Some fields are redacted
Org Manager | Some fields are redacted
Space Application Supporter | Some fields are redacted. Experimental |
Space Auditor | Some fields are redacted
Space Developer |
Space Manager |
Space Manager | Some fields are redacted
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Name | Type | Description
**updated_ats** (*experimental*)| _[timestamp](#timestamps)_ | Timestamp to filter by. When filtering on equality, several comma-delimited timestamps may be passed. Also supports filtering with [relational operators](#relational-operators-experimental)

#### Permitted roles
|
Roles | Notes |
--- | ---
Admin |
Admin Read-Only |
Expand All @@ -49,3 +49,4 @@ Org Manager |
Space Auditor |
Space Developer |
Space Manager |
Space Supporter |
1 change: 1 addition & 0 deletions docs/v3/source/includes/resources/processes/_scale.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ Name | Type | Description
--- | ---
Admin |
Space Developer |
Space Supporter |
11 changes: 6 additions & 5 deletions docs/v3/source/includes/resources/processes/_stats.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ Content-Type: application/json
`GET /v3/apps/:guid/processes/:type/stats`

#### Permitted roles
|
Role | Notes |
--- | ---
Admin |
Admin Read-Only |
Global Auditor |
Org Manager |
Space Auditor |
Global Auditor | Some fields are redacted
Org Manager | Some fields are redacted
Space Application Supporter | Some fields are redacted. Experimental |
Space Auditor | Some fields are redacted
Space Developer |
Space Manager |
Space Manager | Some fields are redacted
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ This allows a user to stop a single misbehaving instance of a process.
--- | ---
Admin |
Space Developer |
Space Supporter |
1 change: 1 addition & 0 deletions docs/v3/source/includes/resources/processes/_update.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ Name | Type | Description
--- | ---
Admin |
Space Developer |
Space Supporter |

0 comments on commit 301aeaf

Please sign in to comment.