import os from ..connectors import cerbos from ..logic.principal import hydrate_JWT, create_cerbos_principal from cerbos.sdk.client import CerbosClient def check(orchardIdentityId, action, resource): principal = hydrate_JWT(orchardIdentityId) cerbos_principal = create_cerbos_principal(principal) cerbos_server_host = os.environ.get('CERBOS_SERVER_HOST', 'http://localhost:8080') with CerbosClient(cerbos_server_host) as client: return cerbos.check_helper(client, cerbos_principal, action, resource)