diff --git a/packages/opal-client/opal_client/config.py b/packages/opal-client/opal_client/config.py index e1e324e60..620d15eaf 100644 --- a/packages/opal-client/opal_client/config.py +++ b/packages/opal-client/opal_client/config.py @@ -191,6 +191,12 @@ def load_policy_store(): # OpenFGA runner configuration INLINE_OPENFGA_ENABLED = confi.bool("INLINE_OPENFGA_ENABLED", True) + INLINE_OPENFGA_EXEC_PATH = confi.str( + "INLINE_OPENFGA_EXEC_PATH", + None, + description="Path to the OpenFGA executable. Defaults to searching for 'openfga' binary in PATH if not specified." + ) + INLINE_OPENFGA_CONFIG = confi.model( "INLINE_OPENFGA_CONFIG", OpenFGAServerOptions, diff --git a/packages/opal-client/opal_client/engine/runner.py b/packages/opal-client/opal_client/engine/runner.py index 5c0f80700..e4c279d1d 100644 --- a/packages/opal-client/opal_client/engine/runner.py +++ b/packages/opal-client/opal_client/engine/runner.py @@ -323,12 +323,22 @@ async def handle_log_line(self, line: bytes) -> bool: await log_engine_output_simple(line) return False - @property - def command(self) -> str: - """Get OpenFGA run command.""" - # return f"openfga run --http-addr=0.0.0.0:8080 --playground-enabled=false" - return f"/usr/local/bin/openfga run --http-addr=0.0.0.0:8080 --playground-enabled=false" + def get_executable_path(self) -> str: + if opal_client_config.INLINE_OPENFGA_EXEC_PATH: + return opal_client_config.INLINE_OPENFGA_EXEC_PATH + else: + logger.warning( + "OpenFGA executable path not set, looking for 'openfga' binary in PATH. " + "It is recommended to set the INLINE_OPENFGA_EXEC_PATH configuration." + ) + path = shutil.which("openfga") + if path is None: + raise FileNotFoundError("OpenFGA executable not found in PATH") + return path + def get_arguments(self) -> list[str]: + return ["run", "--http-addr=0.0.0.0:8080", "--playground-enabled=false"] + @staticmethod def setup_openfga_runner( options: Optional[OpenFGAServerOptions] = None,