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

OpenFGA Integration #673

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2008c54
Draft
daveads Sep 30, 2024
81f9fa1
test
daveads Oct 4, 2024
59b2f89
init test**
daveads Oct 20, 2024
b84bd88
inital test
daveads Oct 20, 2024
0778841
configs
daveads Oct 21, 2024
2c30962
fix...
daveads Oct 21, 2024
646a244
packages/opal-common/opal_common/engine/paths.py
daveads Oct 21, 2024
d29c71e
test...
daveads Oct 21, 2024
f802eb2
implemented using api calls drop openfga_sdk
daveads Oct 25, 2024
fa9df9d
openfga test
daveads Oct 26, 2024
2a89c34
test
daveads Oct 26, 2024
7c98c35
docker test
daveads Oct 28, 2024
c450108
..
daveads Oct 28, 2024
f19b265
support for .yaml policy file
daveads Oct 29, 2024
832d903
bug free
daveads Oct 30, 2024
e9b013b
docker
daveads Nov 4, 2024
42374cc
Done
daveads Nov 5, 2024
bebad51
based off review
daveads Nov 13, 2024
0862044
fix improper indentation
daveads Nov 13, 2024
150edd9
review
daveads Nov 13, 2024
773bea4
..
daveads Nov 17, 2024
3ecba01
Merge branch 'master' into feat/openfga-policy-engine
daveads Nov 17, 2024
b7f27e9
formatted
daveads Nov 17, 2024
96a55db
Merge branch 'master' into feat/openfga-policy-engine
daveads Nov 20, 2024
e1bacf0
added INLINE_OPENFGA_EXEC_PATH
daveads Nov 20, 2024
d4ecc3c
formatter
daveads Nov 20, 2024
73d31da
test
daveads Nov 20, 2024
d602c0b
..
daveads Nov 20, 2024
4d57122
..
daveads Nov 20, 2024
4900a9e
openfga app-test
daveads Nov 20, 2024
fe7da70
...
daveads Nov 20, 2024
96c54b4
EXEC_PATH openfga
daveads Nov 20, 2024
9451b04
doc
daveads Nov 21, 2024
2f093c9
openfga docs
daveads Nov 22, 2024
a8b147f
formatted
daveads Nov 22, 2024
71ee7d0
..
daveads Nov 22, 2024
d417531
format
daveads Nov 22, 2024
f45f366
docker
daveads Nov 27, 2024
f8c3eea
..
daveads Nov 27, 2024
93b853c
Merge branch 'master' into feat/openfga-policy-engine
danyi1212 Dec 2, 2024
31c0204
Merge branch 'master' into feat/openfga-policy-engine
danyi1212 Dec 2, 2024
2c22639
format
daveads Dec 8, 2024
3550ea9
merge master
daveads Dec 9, 2024
4880a02
test
daveads Dec 9, 2024
5d567ee
formatt
daveads Dec 9, 2024
3eaa392
Merge branch 'master' into feat/openfga-policy-engine
daveads Dec 11, 2024
5ee38c3
merged master
daveads Dec 11, 2024
c4d16c2
docs
daveads Dec 16, 2024
c05b885
format
daveads Dec 16, 2024
dd19cfc
Update documentation/docs/tutorials/openfga.mdx
gemanor Dec 17, 2024
a17ee8e
Update documentation/docs/tutorials/openfga.mdx
gemanor Dec 17, 2024
3c5adb2
Update documentation/docs/tutorials/openfga.mdx
gemanor Dec 17, 2024
088f9bc
Merge branch 'master' into feat/openfga-policy-engine
daveads Dec 30, 2024
d1421cc
Merge branch 'master' into feat/openfga-policy-engine
daveads Feb 6, 2025
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
2 changes: 1 addition & 1 deletion packages/opal-common/opal_common/schemas/policy_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BasePolicyScopeSource(BaseSchema):
)
directories: List[str] = Field(["."], description="Directories to include")
extensions: List[str] = Field(
[".rego", ".yaml"], description="File extensions to use"
[".rego", ".json",".yaml"], description="File extensions to use"
)
bundle_ignore: Optional[List[str]] = Field(
None, description="glob paths to omit from bundle"
Expand Down
68 changes: 31 additions & 37 deletions packages/opal-server/opal_server/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
import json
from pathlib import Path

def load_json_data(file_path):
"""Helper function to load JSON data from a file."""
try:
with open(file_path, 'r') as f:
data = json.load(f)
logger.info(f"Successfully loaded data from {file_path}")
return data
except json.JSONDecodeError:
logger.error(f"Error parsing {file_path}: Invalid JSON format")
except Exception as e:
logger.error(f"Error reading {file_path}: {str(e)}")
return {}


def init_data_updates_router(
data_update_publisher: DataUpdatePublisher,
Expand All @@ -34,58 +47,39 @@ def init_data_updates_router(

@router.get(opal_server_config.ALL_DATA_ROUTE)
async def default_all_data():

"""Look for default data file in the repo clone directory and return its contents."""
try:
clone_path = opal_server_config.POLICY_REPO_CLONE_PATH
data_filename = opal_server_config.POLICY_REPO_DEFAULT_DATA_FILENAME

# Look for data.json in the clone directory
data_file = Path(clone_path) / data_filename

if data_file.exists():
daveads marked this conversation as resolved.
Show resolved Hide resolved
logger.info(f"Found {data_filename} at {data_file}")
try:
with open(data_file, 'r') as f:
data = json.load(f)
logger.info(f"Successfully loaded {data_filename}")
return data
except json.JSONDecodeError:
logger.error(f"Error parsing {data_filename}: Invalid JSON format")
return {}
except Exception as e:
logger.error(f"Error reading {data_filename}: {str(e)}")
return {}
else:
# If data file not found in root, try searching subdirectories
for root, dirs, files in os.walk(clone_path):
if data_filename in files:
data_file = Path(root) / data_filename
logger.info(f"Found {data_filename} at {data_file}")
try:
with open(data_file, 'r') as f:
data = json.load(f)
logger.info(f"Successfully loaded {data_filename}")
return data
except json.JSONDecodeError:
logger.error(f"Error parsing {data_filename}: Invalid JSON format")
continue
except Exception as e:
logger.error(f"Error reading {data_filename}: {str(e)}")
continue

logger.warning(
"No valid {filename} found in repository clone directory: {clone_path}",
filename=data_filename,
clone_path=clone_path
)
return {}
return load_json_data(data_file)

# If data file not found in root, try searching subdirectories
for root, dirs, files in os.walk(clone_path):
if data_filename in files:
data_file = Path(root) / data_filename
logger.info(f"Found {data_filename} at {data_file}")
data = load_json_data(data_file)
if data: # Return if valid data was loaded
return data

logger.warning(
"No valid {filename} found in repository clone directory: {clone_path}",
filename=data_filename,
clone_path=clone_path
)
return {}

except Exception as e:
logger.error(f"Error in default_all_data: {str(e)}")
return {}



@router.post(
opal_server_config.DATA_CALLBACK_DEFAULT_ROUTE,
dependencies=[Depends(authenticator)],
Expand Down
Loading