Skip to content

Conversation

hkethi002
Copy link
Contributor

@hkethi002 hkethi002 commented Jul 26, 2017

Fixes #869

Changes Made

  • New phi-access permission property blacklists phi fields (This is a frontend change)
    • phi-access is a required property for every permission POST except at group level, defaults to true
  • phi flag can be used to return PHI fields on get_all calls
phi=false/missing phi=true/superuser invoked
phi=true get_all 403 phi returned
phi=false/missing get_all phi not returned phi not returned
phi=true get phi not returned phi returned
phi=false/missing get phi not returned phi returned*

* This is to support existing behavior

This PR has not applied PHI permissions to POST and PUT methods on containers

Review Checklist

  • Tests were added to cover all code changes
  • Documentation was added / updated
  • Code and tests follow standards in CONTRIBUTING.md

@hkethi002 hkethi002 requested a review from nagem July 26, 2017 21:59
@hkethi002 hkethi002 force-pushed the PHI-perm-three branch 2 times, most recently from 49112df to 0b6e126 Compare August 2, 2017 18:17
@ryansanford
Copy link
Contributor

Confirmed today that the scope of this PR does not include ability to configure which fields are impacted.

@kofalt kofalt self-assigned this Aug 15, 2017
@kofalt
Copy link
Contributor

kofalt commented Aug 15, 2017

I'll need to hop on this to make sure the SDK will work with this change.

@codecov-io
Copy link

codecov-io commented Sep 27, 2017

Codecov Report

Merging #877 into master will increase coverage by <.01%.
The diff coverage is 87.12%.

@@            Coverage Diff             @@
##           master     #877      +/-   ##
==========================================
+ Coverage   90.64%   90.64%   +<.01%     
==========================================
  Files          50       50              
  Lines        6763     6854      +91     
==========================================
+ Hits         6130     6213      +83     
- Misses        633      641       +8

@kofalt kofalt self-requested a review September 27, 2017 16:53
@kofalt
Copy link
Contributor

kofalt commented Sep 27, 2017

Questions:

  1. How can I tell the difference between a field that was censored, and a field set to ***?
  2. Any objection to changing no-phi-ro to ro-no-phi? Seems more logical.
  3. You mention that PHI is returned on a get_all call when you have > ro-no-phi access. Can you give an example?

@hkethi002
Copy link
Contributor Author

hkethi002 commented Sep 27, 2017

  1. We are removing ***, soon to be pushed
  2. Nope
  3. If your access is ro, and the phi param is set to true on a get_all, the PHI will be returned and logged.

else:
has_access = False

if method == 'GET' and exec_op is not noop:
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the noop clause for? Usually we'll pass a noop when we want to see if the user had permission to do something but don't want to actually to follow through with the action yet.


if method == 'GET' and exec_op is not noop:
handler.phi = _get_access(handler.uid, container) > INTEGER_PERMISSIONS['ro-no-phi']
if not handler.phi:
Copy link
Contributor

Choose a reason for hiding this comment

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

For organizational purposes we should set the projection and view the query param in the handler logic. Then we can just pass a PHI=true/false to this method instead.

result = self.handle_origin(result)
modified_results.append(result)
if self.is_true('phi'):
self.log_user_access(AccessType.view_container, cont_name, result.get('_id'))
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably want to create a more efficient way to call this with a list. Right now it will recreate the hierarchy from this container up. If this level is acquisitions, it means grabbing the same session-project-group from the db for each acquisition, even when it's the same session-project-group.


r = as_admin.get('/projects/' + project)
assert r.ok
assert r.json()['files']
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this change order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly, it had to do with some persistence of the validator when the test failed before the moved line that made it difficult to understand the underlying error.

@nagem
Copy link
Contributor

nagem commented Oct 2, 2017

I see some tests were added, mind adding a few more to get diff coverage closer to 100%? Looks like some of the missed lines involved PHI permissions, covering those lines are most important.

projection.pop('info')
projection = None
# if self.is_true('info'): Seems redundant with new phi functionality
# projection.pop('info')
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed

@ryansanford
Copy link
Contributor

I need to create an instance tracking this branch for integration testing.

@ryansanford ryansanford self-assigned this Oct 24, 2017
@hkethi002 hkethi002 force-pushed the PHI-perm-three branch 3 times, most recently from 9d1743e to f9244ec Compare October 25, 2017 21:58
@hkethi002 hkethi002 force-pushed the PHI-perm-three branch 2 times, most recently from f999ae5 to 2e81556 Compare November 13, 2017 15:09
@ryansanford
Copy link
Contributor

Was it intentional for phi-access to be a required parameter on group POST? Could we get a summary in PR description where this is to be required, and what the default is where it is not required?

2017-11-14 14:41:22      scitran.api                  base.py    54:INFO Initialized request request_id=d505f2d1-1510670482
2017-11-14 14:41:22      scitran.api                  base.py   340:WARN u'phi-access' is a required property

Failed validating u'required' in schema:
    {u'$schema': u'http://json-schema.org/draft-04/schema#',
     u'allOf': [{u'$ref': u'../definitions/permission.json#/definitions/permission'}],
     u'key_fields': [u'_id'],
     u'required': [u'_id', u'access', u'phi-access'],
     u'type': u'object'}

On instance:
    {u'_id': u'ci@flywheel.io', u'access': u'admin'} request_id=d505f2d1-1510670482
[pid: 23|app: 0|req: 28/58] 172.20.0.11 () {40 vars in 576 bytes} [Tue Nov 14 14:41:22 2017] POST /api/groups/scitran/permissions => generated 447 bytes in 14 msecs (HTTP/1.1 400) 3 headers in 121 bytes 
(2 switches on core 1)

@hkethi002
Copy link
Contributor Author

hkethi002 commented Nov 15, 2017

Having the phi-access property at the group level would simplify the propagation logic and allow projects and groups to keep the same permission logic. However I am not sure if that would complicate the frontend more than its worth, so I can change it if it would make more sense to only require it at the project and collection level permissions.
Made change in #991 but group perm post no longer requires phi-access, defaults to True

@hkethi002
Copy link
Contributor Author

hkethi002 commented Nov 15, 2017

Also, it may be better to track #991 as it is branched off of this PR and is ready for review.

@nagem
Copy link
Contributor

nagem commented Feb 19, 2018

Closing PR for now as requirements for this enhancement are reworked within the team.

@nagem nagem closed this Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants