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

perf(auth): faster middleware util iteration fns #191

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bento_lib/auth/middleware/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def _evaluate_body(resources: Iterable[dict], permissions: Iterable[Permission])

@staticmethod
def _matrix_tuple_cast(authz_result: list[list[bool]]) -> EvaluationResultMatrix:
return tuple(tuple(x) for x in authz_result)
return tuple(map(tuple, authz_result))

@staticmethod
def _permissions_matrix_to_dict(
m: EvaluationResultMatrix,
permissions: Iterable[Permission],
) -> EvaluationResultDict:
return tuple({p: pv for p, pv in zip(permissions, r)} for r in m)
return tuple(dict(zip(permissions, r)) for r in m)

def evaluate(
self,
Expand Down