{"id":23108376,"url":"https://github.com/kennethlove/django-middle-management","last_synced_at":"2025-07-05T05:36:17.418Z","repository":{"id":268168786,"uuid":"903201665","full_name":"kennethlove/django-middle-management","owner":"kennethlove","description":"A small Django utility for safely executing remote management commands","archived":false,"fork":false,"pushed_at":"2025-05-27T17:50:04.000Z","size":60,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T23:05:58.084Z","etag":null,"topics":["django","management","remote-execution"],"latest_commit_sha":null,"homepage":"","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/kennethlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-12-14T01:32:28.000Z","updated_at":"2025-05-22T07:24:24.000Z","dependencies_parsed_at":"2024-12-14T21:28:04.227Z","dependency_job_id":"9799e4ec-c324-48bb-89e5-e1f6f9d6e4e8","html_url":"https://github.com/kennethlove/django-middle-management","commit_stats":null,"previous_names":["kennethlove/django-middle-management"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kennethlove/django-middle-management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlove%2Fdjango-middle-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlove%2Fdjango-middle-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlove%2Fdjango-middle-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlove%2Fdjango-middle-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kennethlove","download_url":"https://codeload.github.com/kennethlove/django-middle-management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethlove%2Fdjango-middle-management/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263691539,"owners_count":23496871,"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":["django","management","remote-execution"],"created_at":"2024-12-17T01:20:26.949Z","updated_at":"2025-07-05T05:36:17.398Z","avatar_url":"https://github.com/kennethlove.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Middle Management\n\nIt's usually a bad idea to connect to production servers to run one-off or repetitive\nmaintenance commands. There may not be any auditing, commands and payloads can easily\nhave mistakes, and a rogue developer could get away with almost anything. With\n`django-middle-management`, though, you don't have to allow shell access to your\nproduction servers while still being able to run commands on them.\n\nThis is a small library that makes it possible to securely and remotely execute Django\nmanagement commands via `POST` requests. Commands must be merged into your code base\nbefore they're eligible to be used. They must also be listed in `settings.py` or they\ncannot be triggered. Finally, requests must be authenticated by your system before any\ncommand can be given.\n\n**Warning:** This project runs management commands remotely but _synchronously_.\nLong-running commands will potentially block your server from responding to other requests.\nUsing a task queue like Celery is recommend for anything that may take more than a few\nmilliseconds.\n\n## Installation\n\n```bash\npip install django-middle-management\n```\n\n\nAdd the package to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    ...,\n    \"middle_management\",\n    ...\n]\n```\n\nAdd the URLs to your project's `urls.py`:\n\n```python\nfrom middle_management.urls import manage_urls\n\nurlpatterns = [\n    ...\n] + manage_urls\n```\n\nYou'll need to write a new management command or select an\nexisting one to expose. Finally, add that command name to\nan allowlist of commands in `settings.py`:\n\n```python\nMANAGE_ALLOW_LIST = [\"noop\"]\n```\n\n## Usage\n\nTo execute a management command, make a `POST` request to the\n`/__manage__/\u003ccommand name\u003e` endpoint with a payload similar to\nthe following:\n\n```json\n{\n    \"data\": {\n        \"arg1\": \"value1\",\n        \"arg2\": \"value2\"\n    }\n}\n```\n\nYour `POST` must also contain a valid `HTTP_AUTHORIZATION` header\nwith the value `Bearer \u003ctoken\u003e`. The final request will look\nsomething like:\n\n```shell\ncurl -XPOST \\\n  -H 'Authorization: Bearer not-a-real-token' \\\n  -H \"Content-type: application/json\" \\\n  -d '{\"data\": { \"arg1\": \"value1\", \"arg2\": \"value2\" }}' \\\n  'https://example.com/__manage__/noop'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethlove%2Fdjango-middle-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethlove%2Fdjango-middle-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethlove%2Fdjango-middle-management/lists"}