{"id":13787779,"url":"https://github.com/borgeby/jarl","last_synced_at":"2025-05-12T02:30:34.996Z","repository":{"id":36952734,"uuid":"477504053","full_name":"borgeby/jarl","owner":"borgeby","description":"Jarl is an Open Policy Agent (OPA) evaluator for the JVM and Javascript, written in Clojure(Script)","archived":false,"fork":false,"pushed_at":"2024-02-01T14:04:05.000Z","size":3593,"stargazers_count":35,"open_issues_count":24,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-19T00:26:44.758Z","etag":null,"topics":["clojure","clojurescript","jvm","opa","rego"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borgeby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-04T00:43:31.000Z","updated_at":"2024-07-24T06:26:47.881Z","dependencies_parsed_at":"2024-07-24T06:39:43.503Z","dependency_job_id":null,"html_url":"https://github.com/borgeby/jarl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgeby%2Fjarl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgeby%2Fjarl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgeby%2Fjarl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgeby%2Fjarl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borgeby","download_url":"https://codeload.github.com/borgeby/jarl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213062977,"owners_count":15531521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","clojurescript","jvm","opa","rego"],"created_at":"2024-08-03T21:00:30.755Z","updated_at":"2024-08-03T21:01:12.104Z","avatar_url":"https://github.com/borgeby.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jarl\n\n![build](https://github.com/borgeby/jarl/actions/workflows/check.yaml/badge.svg)\n[![codecov](https://codecov.io/gh/borgeby/jarl/branch/main/graph/badge.svg?token=PHGLRDWE39)](https://codecov.io/gh/borgeby/jarl)\n\nJarl is an [Open Policy Agent](https://www.openpolicyagent.org/) (OPA) evaluator for the JVM and Javascript, written in Clojure(Script). Jarl allows you to evaluate policy directly in your JVM language or Javascript environment of choice. See [this blog](https://blog.openpolicyagent.org/i-have-a-plan-exploring-the-opa-intermediate-representation-ir-format-7319cd94b37d) for an introduction to the intermediate representation (IR) format of OPA that Jarl uses for evaluation, and why you may want to consider that as an option.\n\nWhile originally an abbreviation for the \"JVM Alternative for the Rego Language\", Javascript support — for both the browser\nand Node.js — has been made possible by ClojureScript, and it's not unthinkable that more platforms will be added to the\n[support matrix](https://github.com/johanfylling/jarl/blob/main/doc/builtins.md) in the future.\n\n## Usage\n\nSimple example policy compiled to plan by OPA, and executed by Jarl.\n\n**policy.rego**\n```rego\npackage policy\n\nimport future.keywords.if\nimport future.keywords.in\n\ndefault allow := false\n\n# METADATA\n# entrypoint: true\nallow if \"admin\" in input.user.roles\n```\n```shell\nopa build --target plan policy.rego\n```\n\nWe now have a bunde containing the `plan.json` file that we may submit for execution by Jarl!\n\nBefore we do, we'll need to create an input to use for evaluation.\n\n**input.json**\n```json\n{\n    \"user\": {\n        \"roles\": [\n            \"admin\"\n        ]\n    }\n}\n```\n\n**Evaluate**\n```shell\nlein run bundle.tar.gz --input input.json\n```\n\n**Output**\n```json\n[{\"result\":true}]\n```\n\nNote that the above constitutes a simple flow for development and testing only. Production artifacts, or a fixed API for\nintegrations, will be here at a later point in time.\n\n### Clojure\n\nIn the `core` directory, run `lein repl` to launch a REPL in the `jarl.core` namespace:\n\n```clojure\n(jarl.logging/set-log-level :warn)\n\n(def input {\"user\" {\"roles\" [\"admin\"]}})\n(def data {})\n\n(-\u003e (slurp \"path/to/plan.json\")\n    (parser/parse-json)\n    (eval-plan \"policy/allow\" input data))\n\n; [{\"result\" true}]\n```\n\n### Java\n\nJarl provides a simple API for evaluating policies.\n\n#### Evaluating a Plan\n\n```java\nvar file = new File(\"path/to/plan.json\");\nvar input = Map.of(\"user\", \"alice\");\nMap\u003cString, ?\u003e data = Map.of();\nvar allowed = Jarl.builder(file)\n        .build()\n        .getPlan(\"my_policy/allow\")\n        .eval(input, data)\n        .allowed();\nif (allowed) {\n  ...\n}\n```\n\n## Built-in Functions\n\nWhile still in an early stage of development, Jarl already supports [most of the built-in functions](doc/builtins.md)\nprovided by OPA. Jarl intends not just to support all built-in functions out of the box, but to make it trivial to\nimplement custom built-in functions for any platform, or even replace existing implementations with custom ones.\n\n## Development\n\nSee the [development guide](doc/development.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgeby%2Fjarl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborgeby%2Fjarl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgeby%2Fjarl/lists"}