Skip to content

Commit

Permalink
Merge pull request #143 from wazo-platform/add-tenant-uuid-to-unautho…
Browse files Browse the repository at this point in the history
…rized-exception

add tenant_uuid to Unauthorized exception
  • Loading branch information
fblackburn1 authored Jul 17, 2024
2 parents ec78da7 + a400a20 commit bc7bd0f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion xivo/auth_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def validate_token(
except exceptions.InvalidTokenException:
raise InvalidTokenAPIException(token_uuid, required_acl)
except exceptions.MissingPermissionsTokenException:
raise MissingPermissionsTokenAPIException(token_uuid, required_acl)
raise MissingPermissionsTokenAPIException(
token_uuid,
required_acl,
tenant_uuid,
)
except requests.RequestException as error:
raise AuthServerUnreachable(auth_client.host, auth_client.port, error)

Expand Down
16 changes: 12 additions & 4 deletions xivo/http_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ def __init__(self, token: str, required_access: str | None = None) -> None:


class MissingPermissionsTokenAPIException(rest_api_helpers.APIException):
def __init__(self, token: str, required_access: str | None = None) -> None:
details = {'invalid_token': token, 'reason': 'missing_permission'}
if required_access:
details['required_access'] = required_access
def __init__(
self,
token: str,
required_access: str | None,
tenant_uuid: str | None,
) -> None:
details = {
'invalid_token': token,
'reason': 'missing_permission_or_invalid_tenant',
'required_access': required_access,
'tenant_uuid': tenant_uuid,
}
super().__init__(
status_code=401,
message='Unauthorized',
Expand Down

0 comments on commit bc7bd0f

Please sign in to comment.