Skip to content

Commit

Permalink
Task auth checker (#140)
Browse files Browse the repository at this point in the history
Fixed Route Matching checks on authorisor

---------

Co-authored-by: Scott Alexander <scott.alexander@madetech.com>
  • Loading branch information
SRAlexander and Scott Alexander authored Nov 8, 2023
1 parent 146b105 commit b716637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions lambdas/handlers/authoriser_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,26 @@ def lambda_handler(event, context):

def validate_access_policy(http_verb, path, user_role):
logger.info("Validating resource req: %s, http: %s" % (path, http_verb))

logger.info(f"Path: {path}")
match path:
case "/DocumentDelete":
deny_resource = (
user_role is RepositoryRole.GP_CLINICAL.value
or user_role is RepositoryRole.GP_ADMIN.value
user_role == RepositoryRole.GP_CLINICAL.value
)

case "/DocumentManifest":
deny_resource = (
user_role is RepositoryRole.GP_CLINICAL.value
or user_role is RepositoryRole.GP_ADMIN.value
user_role == RepositoryRole.GP_CLINICAL.value
)

case "/DocumentReference":
deny_resource = (
user_role is RepositoryRole.GP_CLINICAL.value
or user_role is RepositoryRole.GP_ADMIN.value
user_role == RepositoryRole.GP_CLINICAL.value
)

case "/SearchDocumentReferences":
deny_resource = user_role is RepositoryRole.PCSE.value
deny_resource = user_role == RepositoryRole.PCSE.value

case _:
deny_resource = False
Expand Down Expand Up @@ -160,7 +159,6 @@ def find_login_session(ndr_session_id):
current_session = query_response["Items"][0]
return current_session
except (KeyError, IndexError) as error:
logger.info(error)
raise AuthorisationException(
f"Unable to find session for session ID ending in: {redact_id(ndr_session_id)}"
)
Expand Down
2 changes: 1 addition & 1 deletion lambdas/services/mock_pds_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def pds_request(self, nhs_number: str, *args, **kwargs) -> Response:
mock_pds_results: list[dict] = []

try:
with open("services/mock_data/pds_patient_not_active.json") as f:
with open("services/mock_data/pds_patient_gp_clinical_ods_practise.json") as f:
mock_pds_results.append(json.load(f))

with open("services/mock_data/pds_patient_restricted.json") as f:
Expand Down

0 comments on commit b716637

Please sign in to comment.