Skip to content

Commit 3b328ea

Browse files
authored
chore: rbac v1 cleanup (#2385)
Removed rbac v1 and its leftovers, kept shared parts RHINENG-26714
1 parent 42f1f73 commit 3b328ea

25 files changed

Lines changed: 243 additions & 1150 deletions

common/config.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ def __init__(self):
120120

121121
self.dashboard_rules_age = int(os.getenv("DASHBOARD_RULES_AGE", "30"))
122122

123-
# RBAC request timeout in seconds
124-
self.rbac_timeout = int(os.getenv("RBAC_TIMEOUT", "15"))
125-
self.disable_rbac = strtobool(os.getenv("DISABLE_RBAC", "FALSE"))
126-
# Granular RBAC feature-flag
127-
self.granular_rbac = strtobool(os.getenv("GRANULAR_RBAC", "FALSE"))
128-
129123
# Minimal systems in account to enable cache
130124
self.cache_minimal_account_systems = int(os.getenv("CACHE_MINIMAL_ACCOUNT_SYSTEMS", "400"))
131125
self.keep_cache_hours = int(os.getenv("CACHE_KEEP_KEEPALIVE_HOURS", "168"))

common/feature_flags.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# Flag toggles
2121
CACHES_FEATURE = "vulnerability.account_cache"
2222
OS_EXPOSURE_REPORT_FEATURE = "vulnerability.os_exposure_report"
23-
OMIT_PERMISSION_METADATA_FROM_RESPONSE_FEATURE = "vulnerability.omit_permission_metadata_from_response"
2423
KESSEL_ENABLED = "vulnerability.kessel_enabled"
2524
NEW_NOTIFICATIONS_FEATURE = "vulnerability.new_notifications"
2625

conf/manager.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
DISABLE_RBAC=FALSE
2-
GRANULAR_RBAC=FALSE
31
MAX_REQUEST_SIZE_MB=2
42
MAXIMUM_PAGE_SIZE=0
53
API_MAX_RPS=100

conf/manager_base.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ PATH_PREFIX=/api
33
GUNICORN_WORKERS=4
44
READ_ONLY_MODE=FALSE
55
RBAC_URL=http://platform_mock:8000
6-
RBAC_TIMEOUT=15
76
API_VERSION=v1
87
TASKOMATIC_HOST=http://ve_taskomatic:8000
98
NOTIFICATOR_HOST=http://ve_notificator:8000

deploy/clowdapp.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,8 @@ objects:
8181
value: '10'
8282
- name: DASHBOARD_RULES_AGE
8383
value: '30'
84-
- name: RBAC_TIMEOUT
85-
value: '15'
86-
- name: DISABLE_RBAC
87-
value: ${DISABLE_RBAC}
8884
- name: DEFAULT_PAGE_SIZE
8985
value: '5000'
90-
- name: GRANULAR_RBAC
91-
value: ${GRANULAR_RBAC}
9286
- name: UNLEASH_BOOTSTRAP_FILE
9387
value: ${UNLEASH_BOOTSTRAP_FILE}
9488
- name: MAXIMUM_PAGE_SIZE
@@ -956,9 +950,6 @@ parameters:
956950
- name: SYSTEM_DELETION_THRESHOLD
957951
description: Delete systems marked as deleted before N hours
958952
value: "1"
959-
- name: DISABLE_RBAC
960-
description: Toggle to disable RBAC in manager
961-
value: "FALSE"
962953
- name: CACHE_MINIMAL_ACCOUNT_SYSTEMS
963954
value: '400'
964955
- name: CACHE_KEEP_KEEPALIVE_HOURS
@@ -969,8 +960,6 @@ parameters:
969960
value: '30'
970961
- name: DB_MIN_POOL_SIZE
971962
value: '10'
972-
- name: GRANULAR_RBAC
973-
value: "TRUE"
974963
- name: MAX_LOADED_EVALUATOR_MSGS
975964
value: "20"
976965
- name: MAX_LOADED_LISTENER_MSGS

develfeatureflags.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@
5757
"strategy": "default",
5858
"parameters": {}
5959
},
60-
{
61-
"name": "vulnerability.omit_permission_metadata_from_response",
62-
"type": "release",
63-
"enabled": false,
64-
"stale": false,
65-
"strategies": [
66-
{
67-
"name": "default",
68-
"parameters": {}
69-
}
70-
],
71-
"strategy": "default",
72-
"parameters": {}
73-
},
7460
{
7561
"name": "vulnerability.kessel_enabled",
7662
"type": "release",

manager/base.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
from common.utils import validate_cve_cache_keepalive
5757

5858
from .filters import apply_filters
59-
from .rbac_manager import RbacException
60-
from .rbac_manager import RbacManager
59+
from .rbac_exceptions import RbacException
6160

6261
LOGGER = get_logger(__name__)
6362
CFG = Config()
@@ -163,18 +162,14 @@ def auth_common(identity, x_rh_identity): # pylint: disable=unused-argument
163162
LOGGER.warning("Invalid system UUID: %s", system_cn)
164163
return None
165164

166-
if identity_type != "System": # Call RBAC by default for non-system identity types (User, ServiceAccount)
167-
rbac_manager = RbacManager()
168-
rbac_perms, group_ids = rbac_manager.fetch_permissions(x_rh_identity)
169-
else:
170-
rbac_perms, group_ids = [], []
165+
group_ids = []
171166

172167
principal_id = extract_principal_id(identity)
173168
if principal_id is None:
174169
raise RbacException({"msg": f"Unknown principal type: {identity['identity']['type']}"})
175170

176171
return {"uid": {"account_number": account_number, "org_id": org_id, "identity_type": identity_type, "system_cn": system_cn,
177-
"rbac_perms": rbac_perms, "group_ids": group_ids, "principal_id": principal_id}}
172+
"group_ids": group_ids, "principal_id": principal_id}}
178173

179174

180175
def auth(x_rh_identity, required_scopes=None): # pylint: disable=unused-argument

manager/cve_handler.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@
6767
from .filters import apply_filters
6868
from .filters import filter_types
6969
from .list_view import ListView
70-
from .rbac_manager import RbacFilterRoutePermissions
71-
from .rbac_manager import RbacManager as RBAC
72-
from .rbac_manager import RbacRoutePermissions
70+
from .rbac_v2_manager import RbacFilterRoutePermissions
71+
from .rbac_v2_manager import RbacRoutePermissions
7372
from .rbac_v2_manager import RbacV2Manager as RBACv2
7473

7574
LOGGER = get_logger(__name__)
@@ -660,8 +659,6 @@ def _cve_details(cls, synopsis, advisory_available):
660659
return retval
661660

662661
@classmethod
663-
@RBAC.need_permissions(RbacRoutePermissions.VULNERABILITY_RESULTS)
664-
@RBAC.need_permissions_filter_value(RbacFilterRoutePermissions.CSV_FORMAT_ENDPOINTS)
665662
@RBACv2.enforce_workspace_permission(RbacRoutePermissions.VULNERABILITY_RESULTS)
666663
@RBACv2.enforce_workspace_permission_filter_value(RbacFilterRoutePermissions.CSV_FORMAT_ENDPOINTS)
667664
def handle_get(cls, **kwargs):
@@ -695,8 +692,6 @@ def _cve_exists(synopsis):
695692
raise ApplicationException("No such CVE ID", 404) from exc
696693

697694
@classmethod
698-
@RBAC.need_permissions(RbacRoutePermissions.VULNERABILITY_RESULTS)
699-
@RBAC.need_permissions_filter_value(RbacFilterRoutePermissions.REPORTABLE_ENDPOINTS)
700695
@RBACv2.enforce_workspace_permission(RbacRoutePermissions.VULNERABILITY_RESULTS)
701696
@RBACv2.enforce_workspace_permission_filter_value(RbacFilterRoutePermissions.REPORTABLE_ENDPOINTS)
702697
def handle_get(cls, **kwargs): # pylint: disable=too-many-branches
@@ -847,7 +842,6 @@ class PatchCveRisk(PatchRequest):
847842
_conflict_target = [CveAccountData.cve_id, CveAccountData.rh_account_id]
848843

849844
@classmethod
850-
@RBAC.need_permissions(RbacRoutePermissions.CVE_BR_AND_STATUS_EDIT)
851845
@RBACv2.enforce_default_workspace_permission(RbacRoutePermissions.CVE_BR_AND_STATUS_EDIT)
852846
def handle_patch(cls, **kwargs):
853847
"""Set business risk for a CVE"""
@@ -903,7 +897,6 @@ class PatchCveStatus(PatchRequest):
903897
_conflict_target = [CveAccountData.cve_id, CveAccountData.rh_account_id]
904898

905899
@classmethod
906-
@RBAC.need_permissions(RbacRoutePermissions.CVE_BR_AND_STATUS_EDIT)
907900
@RBACv2.enforce_default_workspace_permission(RbacRoutePermissions.CVE_BR_AND_STATUS_EDIT)
908901
def handle_patch(cls, **kwargs):
909902
"""Set status for a CVE"""

manager/dashbar_handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
from .base import parse_tags
3434
from .filters import apply_filters
3535
from .filters import filter_types
36-
from .rbac_manager import RbacManager as RBAC
37-
from .rbac_manager import RbacRoutePermissions
36+
from .rbac_v2_manager import RbacRoutePermissions
3837
from .rbac_v2_manager import RbacV2Manager as RBACv2
3938

4039
LOGGER = get_logger(__name__)
@@ -47,7 +46,6 @@ class GetDashbar(GetRequest):
4746
_endpoint_name = r"/v1/dashbar"
4847

4948
@classmethod
50-
@RBAC.need_permissions(RbacRoutePermissions.VULNERABILITY_RESULTS)
5149
@RBACv2.enforce_workspace_permission(RbacRoutePermissions.VULNERABILITY_RESULTS)
5250
def handle_get(cls, **kwargs):
5351
# pylint: disable=singleton-comparison

manager/dashboard_handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
from .base import round_to_100_percent
4040
from .filters import apply_filters
4141
from .filters import filter_types
42-
from .rbac_manager import RbacManager as RBAC
43-
from .rbac_manager import RbacRoutePermissions
42+
from .rbac_v2_manager import RbacRoutePermissions
4443
from .rbac_v2_manager import RbacV2Manager as RBACv2
4544

4645
LOGGER = get_logger(__name__)
@@ -58,7 +57,6 @@ class GetDashboard(GetRequest):
5857
_endpoint_name = r"/v1/dashboard"
5958

6059
@classmethod
61-
@RBAC.need_permissions(RbacRoutePermissions.VULNERABILITY_RESULTS)
6260
@RBACv2.enforce_workspace_permission(RbacRoutePermissions.VULNERABILITY_RESULTS)
6361
def handle_get(cls, **kwargs):
6462
# pylint: disable=singleton-comparison, too-many-branches, too-many-statements

0 commit comments

Comments
 (0)