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

COST-4764 Set lower level rbac roles when only top level are set for OpenShift cluster/node/project #5020

Merged
merged 8 commits into from
Apr 9, 2024

Conversation

lcouzens
Copy link
Contributor

@lcouzens lcouzens commented Apr 5, 2024

Jira Ticket

COST-4764

Description

This change will fix partial matching for things like project/node filtering with a higher level rbac roles such as cluster by explicitly implying the correct lower level role accordingly.

Example:

If you restrict to a single cluster this change will set node and project role to * (Access all items beneath that cluster)

Testing

  1. Checkout Main
  2. run python koku/manage.py shell
  3. from koku.rbac import _apply_access
  4. _apply_access({'openshift.cluster': [{'operation': 'read', 'resources': ['test_cluster']}]})
  5. see returned access specifically the openshift sections just have test_cluster set
  6. Checkout this branch and repeat steps 2-5 above
  7. See the returned access now explicitly sets the lower lover access to * for node/project

Additional testing:
Try various access settings such as node and project levels:
_apply_access({'openshift.cluster': [{'operation': 'read', 'resources': ['test_cluster']}], 'openshift.node': [{'operation': 'read', 'resources': ['test_node']}]})
_apply_access({'openshift.cluster': [{'operation': 'read', 'resources': ['test_cluster']}], 'openshift.node': [{'operation': 'read', 'resources': ['test_node']}], 'openshift.project': [{'operation': 'read', 'resources': ['test_project']}]})

really adventurous you can try these too
'openshift.node': [{'operation': 'read', 'resources': ['test_node']}]
result:
'openshift.cluster': {'read': []},
'openshift.node': {'read': ['test_node]},
'openshift.project': {'read': ['*']},

'openshift.project': [{'operation': 'read', 'resources': ['test_project']}]
result:
'openshift.cluster': {'read': []},
'openshift.node': {'read': []},
'openshift.project': {'read': ['test_project']},

Release Notes

  • proposed release note
* [COST-4764](https://issues.redhat.com/browse/COST-4764) Fix Rbac issue around partial matching when filtering data

@lcouzens lcouzens requested review from a team as code owners April 5, 2024 09:52
@lcouzens lcouzens added the smoke-tests pr_check will build the image and run minimal required smokes label Apr 5, 2024
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Merging #5020 (20a2193) into main (be7d562) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #5020     +/-   ##
=======================================
- Coverage   94.1%   94.1%   -0.0%     
=======================================
  Files        377     377             
  Lines      31230   31237      +7     
  Branches    3709    3713      +4     
=======================================
+ Hits       29390   29393      +3     
- Misses      1171    1174      +3     
- Partials     669     670      +1     

@maskarb
Copy link
Member

maskarb commented Apr 5, 2024

What is being fixed? Should we be allowing partial matching when filtering? I don't think we should because this was explicitly disallowed with this issue:
https://issues.redhat.com/browse/COST-382

@lcouzens lcouzens force-pushed the COST-4764-fix-rbac-filtering branch from cf26bfd to 27ae496 Compare April 8, 2024 09:13
@lcouzens lcouzens changed the title COST-4764 fix rbac partial match filtering COST-4764 Set lower level rbac roles when only top level are set for OpenShift cluster/node/project Apr 8, 2024
bacciotti
bacciotti previously approved these changes Apr 8, 2024
Copy link
Member

@maskarb maskarb left a comment

Choose a reason for hiding this comment

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

lgtm!

@lcouzens lcouzens enabled auto-merge (squash) April 9, 2024 08:12
@lcouzens lcouzens merged commit 61433e1 into main Apr 9, 2024
11 checks passed
@lcouzens lcouzens deleted the COST-4764-fix-rbac-filtering branch April 9, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
smoke-tests pr_check will build the image and run minimal required smokes smokes-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants