{"id":29691785,"url":"https://github.com/casbin/casbin-python-cli","last_synced_at":"2025-07-23T07:06:45.624Z","repository":{"id":304017139,"uuid":"1013044695","full_name":"casbin/casbin-python-cli","owner":"casbin","description":"Python CLI for Casbin","archived":false,"fork":false,"pushed_at":"2025-07-20T09:49:51.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T11:31:18.022Z","etag":null,"topics":["abac","acl","api","auth","authorization","authz","casbin","cli","py","pycasbin","python","rbac"],"latest_commit_sha":null,"homepage":"https://casbin.org","language":"Python","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/casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null},"funding":{"github":"casbin"}},"created_at":"2025-07-03T09:19:30.000Z","updated_at":"2025-07-20T09:48:17.000Z","dependencies_parsed_at":"2025-07-10T23:04:07.016Z","dependency_job_id":"41642e2f-408c-4cb8-9983-d398d137276e","html_url":"https://github.com/casbin/casbin-python-cli","commit_stats":null,"previous_names":["casbin/casbin-python-cli"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/casbin/casbin-python-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcasbin-python-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcasbin-python-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcasbin-python-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcasbin-python-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/casbin-python-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcasbin-python-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266402428,"owners_count":23923262,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["abac","acl","api","auth","authorization","authz","casbin","cli","py","pycasbin","python","rbac"],"created_at":"2025-07-23T07:06:44.947Z","updated_at":"2025-07-23T07:06:45.608Z","avatar_url":"https://github.com/casbin.png","language":"Python","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"# casbin-python-cli\n\n![PyPI - Python Version](https://img.shields.io/badge/python-3.6%2B-blue)\n![PyPI - License](https://img.shields.io/badge/license-Apache%202.0-green)\n![PyPI - PyCasbin Version](https://img.shields.io/badge/pycasbin-1.17.0%2B-orange)\n\n## Features\n\n- **casbin-editor Integration**: Full API compatibility with casbin-editor for multi-language backend support\n- **Unified JSON Response Format**: Standardized `{\"allow\": boolean|null, \"explain\": array|null}` response format\n- **Method Name Mapping**: Automatic conversion between Java-style command names and Python method names\n- **Comprehensive API Coverage**: Support for policy execution, management, RBAC operations, and data retrieval\n- **Cross-platform Binaries**: Automated builds for Windows, macOS, and Linux\n- **Dynamic Command Execution**: Reflection-based method invocation similar to Java version\n\n## Installation\n\n### Prerequisites\n\n- Python 3.6+\n- pip package manager\n\n### Installation Methods\n\n**Clone from repository**:\n\n```bash\ngit clone https://github.com/casbin/casbin-python-cli.git\ncd casbin-python-cli\npip install -r requirements.txt\n```\n\n## Usage\n\n### Basic Command Structure\n\n```bash\npython -m casbin_cli.client [command] [options] [args]\n```\n\n### Examples\n\n**Policy Execution**:\n```bash\n# Basic enforcement\npython -m casbin_cli.client enforce -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\" \"alice\" \"data1\" \"read\"\n{\"allow\":true,\"explain\":null}\n\n# Enforcement with explanation\npython -m casbin_cli.client enforceEx -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\" \"alice\" \"data1\" \"read\"\n{\"allow\":true,\"explain\":[\"alice\",\"data1\",\"read\"]}\n```\n\n**Policy Management**:\n```bash\n# Add policy\npython -m casbin_cli.client addPolicy -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\" \"eve\" \"data3\" \"read\"\n{\"allow\":true,\"explain\":null}\n\n# Get all policies\npython -m casbin_cli.client getPolicy -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\"\n{\"allow\":null,\"explain\":[[\"alice\",\"data1\",\"read\"],[\"bob\",\"data2\",\"write\"]]}\n```\n\n**RBAC Operations**:\n```bash\n# Get user roles\npython -m casbin_cli.client getRolesForUser -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\" \"alice\"\n{\"allow\":null,\"explain\":[\"data2_admin\"]}\n\n# Get role users\npython -m casbin_cli.client getUsersForRole -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\" \"data2_admin\"\n{\"allow\":null,\"explain\":[\"alice\"]}\n```\n\n**Data Retrieval**:\n```bash\n# Get all subjects\npython -m casbin_cli.client getAllSubjects -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\"\n{\"allow\":null,\"explain\":[\"alice\",\"bob\",\"data2_admin\"]}\n\n# Get all objects\npython -m casbin_cli.client getAllObjects -m \"examples/rbac_model.conf\" -p \"examples/rbac_policy.csv\"\n{\"allow\":null,\"explain\":[\"data1\",\"data2\"]}\n```\n\n### API Compatibility\n\nThe Python CLI maintains full compatibility with the Java version through:\n\n- **Command Interface**: Identical command-line arguments (`-m`, `-p`, etc.)\n- **Method Name Mapping**: Automatic conversion from Java camelCase to Python snake_case\n- **Response Format**: Standardized JSON responses matching Java implementation\n- **Error Handling**: Consistent error reporting across all backends\n\n### Supported APIs\n\n| Category              | Commands                                                     | Status |\n| --------------------- | ------------------------------------------------------------ | ------ |\n| **Policy Execution**  | `enforce`, `enforceEx`, `enforceWithMatcher`                 | ✅      |\n| **Policy Management** | `addPolicy`, `removePolicy`, `getPolicy`, `hasPolicy`        | ✅      |\n| **RBAC Operations**   | `getRolesForUser`, `getUsersForRole`, `hasRoleForUser`       | ✅      |\n| **Data Retrieval**    | `getAllSubjects`, `getAllObjects`, `getAllActions`           | ✅      |\n| **Grouping Policies** | `getGroupingPolicy`, `addGroupingPolicy`, `removeGroupingPolicy` | ✅      |\n| **Named Policies**    | `getNamedPolicy`, `getAllNamedRoles`                         | ✅      |\n| **Filtered Queries**  | `getFilteredPolicy`, `getFilteredGroupingPolicy`             | ✅      |\n\n## Project Structure\n\n```\ncasbin-python-cli/  \n├── .github/  \n│   └── workflows/  \n│       └── release.yml           # GitHub Actions CI/CD  \n├── scripts/  \n│   ├── update_version.py         # Version management  \n│   └── build_binaries.py         # Binary building  \n├── casbin_cli/  \n│   ├── __init__.py  \n│   ├── __version__.py            # Version information\n│   ├── client.py                 # Main CLI entry point \u0026 argument parsing\n│   ├── command_executor.py       # Dynamic command execution \u0026 method mapping\n│   ├── enforcer_factory.py       # PyCasbin enforcer creation\n│   ├── response.py               # Standardized JSON response formatting\n│   └── utils.py                  # Utility functions\n├── examples/                     # Example model and policy files\n│   ├── rbac_model.conf          # RBAC model configuration\n│   ├── rbac_policy.csv          # RBAC policy data\n│   ├── basic_model.conf         # Basic model configuration\n│   └── basic_policy.csv         # Basic policy data\n├── tests/                       # Test files (if any)\n├── .releaserc.json              # Semantic release configuration\n├── package.json                 # Node.js dependencies for release automation\n├── requirements.txt             # Python dependencies\n├── setup.py                     # Package setup and distribution\n└── README.md                    # This file\n```\n\n## Requirements\n\n- Python 3.6+\n- PyCasbin 1.17.0+\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n---\n\n**Note**: This Python CLI is part of the Casbin ecosystem and designed to work seamlessly with casbin-editor for multi-language backend support. For more information about Casbin, visit [casbin.org](https://casbin.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fcasbin-python-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fcasbin-python-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fcasbin-python-cli/lists"}