{"id":22261386,"url":"https://github.com/adaptant-labs/opa-api-authz-dart","last_synced_at":"2025-08-24T15:12:46.333Z","repository":{"id":66208377,"uuid":"214893608","full_name":"adaptant-labs/opa-api-authz-dart","owner":"adaptant-labs","description":"Open Policy Agent-based API Authorization in Dart","archived":false,"fork":false,"pushed_at":"2019-10-15T23:46:46.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T12:28:08.509Z","etag":null,"topics":["api-authentication","authz","dart","dart2","dartlang","opa","openpolicyagent"],"latest_commit_sha":null,"homepage":null,"language":"Dart","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/adaptant-labs.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":"2019-10-13T21:04:24.000Z","updated_at":"2023-04-28T08:59:44.000Z","dependencies_parsed_at":"2023-05-30T00:45:18.628Z","dependency_job_id":null,"html_url":"https://github.com/adaptant-labs/opa-api-authz-dart","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaptant-labs%2Fopa-api-authz-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaptant-labs%2Fopa-api-authz-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaptant-labs%2Fopa-api-authz-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaptant-labs%2Fopa-api-authz-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adaptant-labs","download_url":"https://codeload.github.com/adaptant-labs/opa-api-authz-dart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245472518,"owners_count":20621125,"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":["api-authentication","authz","dart","dart2","dartlang","opa","openpolicyagent"],"created_at":"2024-12-03T09:12:37.655Z","updated_at":"2025-03-25T13:41:11.796Z","avatar_url":"https://github.com/adaptant-labs.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![logo](logo.png) OPA API Authorization in Dart Example\n\nThis repository shows how to integrate a service written in Dart with [OPA](http://www.openpolicyagent.org) to perform\nAPI authorization. It is a direct port of the [OPA-Python](https://github.com/open-policy-agent/example-api-authz-python)\nexample, with a few enhancements.\n\n## Trying the example\n\nThis example utilizes an independent OPA server which must already be running, and which must allow new policies to be\nuploaded. An existing OPA server URI can be defined in the `OPA_URL` environment variable, which otherwise defaults to\na local instance at `http://localhost:8181`.\n\nTo run the OPA instance locally:\n\n```bash\n$ opa run -s\n```\n\nnote that the example policy (in the `./policies` directory) will be uploaded to the OPA server by the application\ndirectly. Any additional policies with the `.rego` extension found in this directory will similarly be uploaded to the\nOPA server on start.\n\nRun the server:\n\n```bash\n$ dart bin/server.dart\n```\n\nWithout authorization, view a list of cars:\n\n```bash\n$ curl -X GET localhost:8080/cars\n```\n\nAs someone with the manager role, create a car (this should be allowed):\n\n```bash\n$ curl -H 'Authorization: alice' -H 'Content-Type: application/json' \\\n    -X PUT localhost:8080/cars/test-car \\\n    -d '{\"model\": \"Toyota\", \"vehicle_id\": \"357192\", \"owner_id\": \"4821\", \"id\": \"test-car\"}'\n```\n\nAs someone with the car admin role, try to delete a car (this should be denied):\n\n```bash\n$ curl -H 'Authorization: kelly' \\\n    -X DELETE localhost:8080/cars/test-car\n```\n\n## Running from Docker\n\nTo run from Docker, simply specify the host and port of the OPA server through\nthe passed in `OPA_URL` environment variable:\n\n```bash\n$ docker run -e OPA_URL='opa:8181' -p 8080:8080 adaptant/opa-api-authz-dart\n```\n\nNote that by default the Docker image enables the Dart Observatory, which binds\nport 8181 within the container by default. If using `--net=host`, the default\nObservatory port needs to be shifted out of the way. This can be done by\ntweaking the `DART_VM_OPTIONS`, as so:\n\n```bash\n$ docker run -e DART_VM_OPTIONS='--enable-vm-service=8282' --net=host adaptant/opa-api-authz-dart:latest\n\nStarting Dart with additional options --enable-vm-service=8282\nObservatory listening on http://127.0.0.1:8282/4y7welzb8Fc=/\nApplying policy: ./policies/example.rego\nExample Service listening on 0.0.0.0:8080\n...\n```\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: https://github.com/adaptant-labs/opa-api-authz-dart/issues\n\n## License\n\nLicensed under the terms of the Apache 2.0 license (the license under which the `OPA-Python` example was released),\nthe full version of which can be found in the [LICENSE](LICENSE)\nfile included in this distribution.\n\n## Acknowledgements\n\n- Derived from [example-api-authz-python](https://github.com/open-policy-agent/example-api-authz-python) by [@tsandall](https://github.com/tsandall).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptant-labs%2Fopa-api-authz-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaptant-labs%2Fopa-api-authz-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptant-labs%2Fopa-api-authz-dart/lists"}