-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract datafiltering code into a separate package: permit-datafilter
- Loading branch information
Asaf Cohen
committed
Aug 12, 2024
1 parent
b593e13
commit c97fda1
Showing
29 changed files
with
174 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
helm/ | ||
.venv/ | ||
.github/ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ dist/ | |
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include *.md requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: help | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
clean: | ||
rm -rf *.egg-info build/ dist/ | ||
|
||
publish: | ||
$(MAKE) clean | ||
python setup.py sdist bdist_wheel | ||
python -m twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Permit.io Data Filtering SDK (EAP) | ||
|
||
Initial SDK to enable data filtering scenarios based on compiling OPA policies from Rego AST into SQL-like expressions. | ||
|
||
## Installation | ||
|
||
```py | ||
pip install permit-datafilter | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...iltering/boolean_expression/translator.py → ...tafilter/boolean_expression/translator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
lib/permit-datafilter/permit_datafilter/sdk/permit_filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# from typing import Union | ||
|
||
# from horizon.enforcer import schemas as enforcer_schemas | ||
# from horizon.enforcer.api import MAIN_PARTIAL_EVAL_PACKAGE | ||
# from permit_datafilter.boolean_expression.schemas import ( | ||
# ResidualPolicyResponse, | ||
# ) | ||
# from permit_datafilter.compile_api.compile_client import OpaCompileClient | ||
|
||
# User = Union[dict, str] | ||
# Action = str | ||
# Resource = Union[dict, str] | ||
|
||
|
||
# def normalize_user(user: User) -> dict: | ||
# if isinstance(user, str): | ||
# return dict(key=user) | ||
# else: | ||
# return user | ||
|
||
|
||
# def normalize_resource_type(resource: Resource) -> str: | ||
# if isinstance(resource, dict): | ||
# t = resource.get("type", None) | ||
# if t is not None and isinstance(t, str): | ||
# return t | ||
# raise ValueError("no resource type provided") | ||
# else: | ||
# return resource | ||
|
||
|
||
# def filter_resource_query( | ||
# user: User, action: Action, resource: Resource | ||
# ) -> enforcer_schemas.AuthorizationQuery: | ||
# normalized_user = normalize_user(user) | ||
# resource_type: str = normalize_resource_type(resource) | ||
# return enforcer_schemas.AuthorizationQuery( | ||
# user=normalized_user, | ||
# action=action, | ||
# resource=enforcer_schemas.Resource(type=resource_type), | ||
# ) | ||
|
||
|
||
# class Permit: | ||
# """ | ||
# stub for future SDK code | ||
# """ | ||
|
||
# def __init__(self, token: str): | ||
# self._headers = { | ||
# "Authorization": f"Bearer {token}", | ||
# "Content-Type": "application/json", | ||
# } | ||
|
||
# async def filter_resources( | ||
# self, user: User, action: Action, resource: Resource | ||
# ) -> ResidualPolicyResponse: | ||
# """ | ||
# stub for future permit.filter_resources() function | ||
# """ | ||
# client = OpaCompileClient(headers=self._headers) | ||
# input = filter_resource_query(user, action, resource) | ||
# return await client.compile_query( | ||
# query=f"data.{MAIN_PARTIAL_EVAL_PACKAGE}.allow == true", | ||
# input=input, | ||
# unknowns=[ | ||
# "input.resource.key", | ||
# "input.resource.tenant", | ||
# "input.resource.attributes", | ||
# ], | ||
# raw=True, | ||
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
aiohttp>=3.9.4,<4 | ||
ddtrace | ||
fastapi>=0.109.1,<1 | ||
loguru | ||
pydantic[email]>=1.9.1,<2 | ||
pytest | ||
SQLAlchemy==1.4.46 |
Oops, something went wrong.