Skip to content

Commit

Permalink
support for .yaml policy file
Browse files Browse the repository at this point in the history
  • Loading branch information
daveads committed Oct 29, 2024
1 parent c450108 commit f19b265
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/opal-client/opal_client/policy/updater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
from typing import List, Optional
import json
import yaml
import pydantic
from fastapi_websocket_pubsub import PubSubClient
from fastapi_websocket_rpc.rpc_channel import RpcChannel
Expand Down Expand Up @@ -343,6 +344,12 @@ async def update_policy(
await store_transaction.set_policy(policy_module.path, json.dumps(policy_data))
except json.JSONDecodeError:
logger.error(f"Invalid JSON in OpenFGA policy file: {policy_module.path}")

elif policy_module.path.endswith('.yaml'):
policy_data = yaml.safe_load(policy_module.rego)
await store_transaction.set_policy(policy_module.path, json.dumps(policy_data))
#logger.error(f"yaml file")

else:
logger.warning(f"Skipping non-JSON file for OpenFGA: {policy_module.path}")
else:
Expand Down

0 comments on commit f19b265

Please sign in to comment.