django-usermgmt 1.0.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.5
2
+ Name: django-usermgmt
3
+ Version: 1.0.6
4
+ Summary: A production-oriented command line toolkit for managing users, groups and permissions in any Django project.
5
+ Project-URL: Homepage, https://github.com/cumulus13/django-usermgmt
6
+ Project-URL: Documentation, https://github.com/cumulus13/django-usermgmt/tree/main/docs
7
+ Project-URL: Repository, https://github.com/cumulus13/django-usermgmt.git
8
+ Project-URL: Bug Tracker, https://github.com/cumulus13/django-usermgmt/issues
9
+ Project-URL: Changelog, https://github.com/cumulus13/django-usermgmt/blob/main/CHANGELOG.md
10
+ Author-email: Hadi Cahyadi <cumulus13@gmail.com>
11
+ Maintainer-email: Hadi Cahyadi <cumulus13@gmail.com>
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ Keywords: audit-log,bulk-import,cli,django,groups,management-command,permissions,user-management,usermgr
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Environment :: Console
17
+ Classifier: Environment :: Web Environment
18
+ Classifier: Framework :: Django
19
+ Classifier: Framework :: Django :: 4.2
20
+ Classifier: Framework :: Django :: 5.0
21
+ Classifier: Framework :: Django :: 5.1
22
+ Classifier: Framework :: Django :: 5.2
23
+ Classifier: Intended Audience :: Developers
24
+ Classifier: Intended Audience :: System Administrators
25
+ Classifier: Operating System :: OS Independent
26
+ Classifier: Programming Language :: Python :: 3
27
+ Classifier: Programming Language :: Python :: 3.9
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Classifier: Programming Language :: Python :: 3.12
31
+ Classifier: Programming Language :: Python :: 3.13
32
+ Classifier: Topic :: Internet :: WWW/HTTP
33
+ Classifier: Topic :: System :: Systems Administration :: Authentication/Directory
34
+ Requires-Python: >=3.9
35
+ Requires-Dist: django>=4.2
36
+ Provides-Extra: dev
37
+ Requires-Dist: build; extra == 'dev'
38
+ Requires-Dist: pytest-django>=4.8; extra == 'dev'
39
+ Requires-Dist: pytest>=8.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
41
+ Requires-Dist: twine; extra == 'dev'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # django-usermgmt
45
+
46
+ <p align="center">
47
+ <img src="https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/logo.png" width="40%" alt="logo">
48
+ </p>
49
+
50
+ <p align="center">
51
+ <img src="https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/screenshot.png" width="98%" alt="logo">
52
+ </p>
53
+
54
+
55
+ A production-oriented command line toolkit for managing **users, groups and permissions** in any Django project.
56
+
57
+ Stock `manage.py` only ships `createsuperuser` and `changepassword`. There is no built-in way to create a regular
58
+ user, list users, inspect permissions, manage groups or import accounts in bulk. `django-usermgmt` adds a single
59
+ management command, `usermgr`, that covers all of that, with safety guards, audit logging and scriptable output.
60
+
61
+ ```bash
62
+ python manage.py usermgr create-user john --email john@example.com --group editors --create-missing-groups
63
+ python manage.py usermgr list-users --active --format json
64
+ python manage.py usermgr who-can blog.add_post
65
+ ```
66
+
67
+ ## Highlights
68
+
69
+ - **26 actions** across users, permissions, groups and bulk import/export.
70
+ - **Custom user model support**: the login field is read from `USERNAME_FIELD`; extra fields via `--field KEY=VALUE`.
71
+ - **Safe password handling**: interactive prompt, stdin or environment variable; validated against
72
+ `AUTH_PASSWORD_VALIDATORS`; never logged.
73
+ - **Safety guards**: the last active superuser cannot be deleted, deactivated or demoted without `--force`;
74
+ destructive actions ask for confirmation.
75
+ - **Atomic and auditable**: every mutation runs in a transaction and writes a line to the `usermgmt.audit` logger.
76
+ - **Automation friendly**: `table`, `json` and `csv` output, stable exit codes, no prompts when stdin is not a TTY.
77
+ - **Layered design**: all logic lives in `usermgmt.services`; the command is a thin CLI wrapper you can bypass.
78
+
79
+ ## Requirements
80
+
81
+ | Component | Version |
82
+ |---|---|
83
+ | Python | 3.9 or newer |
84
+ | Django | 4.2 or newer |
85
+
86
+ No third-party dependencies.
87
+
88
+ ## Installation
89
+
90
+ 1. Copy the `usermgmt/` directory into your project, next to `manage.py`.
91
+ 2. Add it to `INSTALLED_APPS`:
92
+
93
+ ```python
94
+ INSTALLED_APPS = [
95
+ # ...
96
+ "django.contrib.auth",
97
+ "django.contrib.contenttypes",
98
+ "usermgmt",
99
+ ]
100
+ ```
101
+ 3. Verify:
102
+
103
+ ```bash
104
+ python manage.py usermgr -h
105
+ ```
106
+
107
+ See [`examples/settings_snippet.py`](examples/settings_snippet.py) for an audit-log configuration.
108
+
109
+ ## Quick tour
110
+
111
+ ```bash
112
+ # Create users
113
+ python manage.py usermgr create-user john --email john@example.com # prompts for a password
114
+ echo "$PW" | python manage.py usermgr create-user sari --password-stdin
115
+ python manage.py usermgr create-user svc-sso --no-password # unusable password (SSO / API only)
116
+ python manage.py usermgr create-user ops --staff --group operators --create-missing-groups
117
+
118
+ # Inspect
119
+ python manage.py usermgr list-users --active --stale-days 90 --format csv
120
+ python manage.py usermgr show-user john --all-perms
121
+ python manage.py usermgr check-user john --perm auth.view_user
122
+
123
+ # Permissions and groups
124
+ python manage.py usermgr create-group editors --perm blog.add_post --perm blog.change_post
125
+ python manage.py usermgr add-to-group john editors
126
+ python manage.py usermgr grant-perm john "reports.*"
127
+ python manage.py usermgr who-can blog.add_post
128
+
129
+ # Lifecycle
130
+ python manage.py usermgr set-password john --revoke-sessions
131
+ python manage.py usermgr deactivate john --revoke-sessions
132
+
133
+ # Bulk
134
+ python manage.py usermgr import-users examples/users.csv --dry-run
135
+ python manage.py usermgr export-users --format csv --output users.csv
136
+ ```
137
+
138
+ ## Action overview
139
+
140
+ ```mermaid
141
+ mindmap
142
+ root((usermgr))
143
+ Users
144
+ create-user
145
+ list-users
146
+ show-user
147
+ check-user
148
+ update-user
149
+ set-password
150
+ set-flags
151
+ activate
152
+ deactivate
153
+ delete-user
154
+ revoke-sessions
155
+ Permissions
156
+ grant-perm
157
+ revoke-perm
158
+ list-perms
159
+ who-can
160
+ Groups
161
+ create-group
162
+ delete-group
163
+ rename-group
164
+ list-groups
165
+ show-group
166
+ group-grant
167
+ group-revoke
168
+ add-to-group
169
+ remove-from-group
170
+ Bulk
171
+ import-users
172
+ export-users
173
+ ```
174
+
175
+ [![Action overview](https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/architecture1.jpg)](https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/architecture1.jpg)
176
+
177
+ ## How it fits together
178
+
179
+ ```mermaid
180
+ flowchart LR
181
+ Admin["Operator / script / CI"] -->|"manage.py usermgr ..."| CLI["usermgr command<br/>(argparse, output, prompts)"]
182
+ CLI --> SVC["usermgmt.services<br/>(business logic)"]
183
+ Py["Your Python code<br/>(Celery, shell, tests)"] --> SVC
184
+ SVC --> ORM["Django ORM<br/>auth.User / Group / Permission"]
185
+ SVC --> LOG["usermgmt.audit logger"]
186
+ ORM --> DB[("Database")]
187
+ ```
188
+
189
+ [![How it fits together](https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/architecture2.jpg)](https://raw.githubusercontent.com/licface15/images/refs/heads/main/django-usermgmt/architecture2.jpg)
190
+
191
+ ## Documentation
192
+
193
+ | Document | Purpose |
194
+ |---|---|
195
+ | [User guide](docs/USER_GUIDE.md) | Task-oriented walkthroughs and recipes |
196
+ | [Command reference](docs/COMMAND_REFERENCE.md) | Every action, argument, output and exit code |
197
+ | [Architecture](docs/ARCHITECTURE.md) | Design, data model and flow diagrams |
198
+ | [Security guide](docs/SECURITY.md) | Threat model, password handling, audit logging, hardening checklist |
199
+ | [Developer guide](docs/DEVELOPER_GUIDE.md) | Using the service layer, extending the command, running tests |
200
+ | [Troubleshooting](docs/TROUBLESHOOTING.md) | Common errors and fixes |
201
+ | [Changelog](CHANGELOG.md) | Release history |
202
+
203
+ ## Running the tests
204
+
205
+ ```bash
206
+ python manage.py test usermgmt
207
+ ```
208
+
209
+ ## Known limitations
210
+
211
+ - Operates on the default database connection only (no `--database` option yet).
212
+ - `revoke-sessions` supports database-backed sessions (`django.contrib.sessions`) only.
213
+ - `who-can` evaluates permissions the way Django's `ModelBackend` does (superuser, direct, via group).
214
+ Custom authentication backends with their own permission logic are not consulted.
215
+ - Passwords in import files are plain text; protect and delete those files (see the [security guide](docs/SECURITY.md)).
216
+
217
+
218
+ **for cli's color, install `pip install rchf`**
219
+
220
+ ## 👤 Author
221
+
222
+ [Hadi Cahyadi](mailto:cumulus13@gmail.com)
223
+
224
+
225
+ [![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)
226
+
227
+ [![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)
228
+
229
+ [Support me on Patreon](https://www.patreon.com/cumulus13)
@@ -0,0 +1,12 @@
1
+ usermgmt/__init__.py,sha256=oMA6ePRhdB_Ckhz3gQ2hSdj9u7latRsFuy5gokII_nk,171
2
+ usermgmt/apps.py,sha256=n3W5vaOwO7FF1UPLQG06JiLj92oXDdLv_NcMlgAKh54,356
3
+ usermgmt/services.py,sha256=e1ZKK-s2UEzyUjNpzkdegHn3FzevuN4B4HVwgSawSM4,28800
4
+ usermgmt/management/__init__.py,sha256=9fYTq96aqK6WbgDxC78rypkoJVDxb4gvNgosi90RGJA,182
5
+ usermgmt/management/commands/__init__.py,sha256=S5OYKyBEm5C87lKR-HCd5VhoEZKt6GmAg29d_GghLD4,191
6
+ usermgmt/management/commands/usermgr.py,sha256=0X0QqvaAmCXjq2D_T_Q8tDD23j8yMPz2lcCq3FTvazA,24967
7
+ usermgmt/tests/__init__.py,sha256=dOTnTdyg5pk_-M6u-8I1Oyrrz3bX9c9GR46ggYfo2Sw,177
8
+ usermgmt/tests/test_usermgr.py,sha256=7ai4Tu9FwNS_6EOSaAYpfnEWwqiZWf4F-zvAzUR9xbc,5112
9
+ django_usermgmt-1.0.6.dist-info/METADATA,sha256=lVlRJS2U7LIRSINMbCOj_MNyc9kJnfhA1MbUMY_OU_s,8728
10
+ django_usermgmt-1.0.6.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
11
+ django_usermgmt-1.0.6.dist-info/licenses/LICENSE,sha256=YUZAmTZXLbSJqc2UabCY7nJH-s_jCegXkhfTpHrOSRU,1068
12
+ django_usermgmt-1.0.6.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hadi Cahyadi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
usermgmt/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ # File: django-usermgmt/usermgmt/__init__.py
2
+ # Author: Hadi Cahyadi <cumulus13@gmail.com>
3
+ # Date: 2026-11-17 04:19:48 SE Asia Standard Time
4
+ # Description:
5
+ # License: MIT
6
+
usermgmt/apps.py ADDED
@@ -0,0 +1,13 @@
1
+ # File: django-usermgmt/usermgmt/apps.py
2
+ # Author: Hadi Cahyadi <cumulus13@gmail.com>
3
+ # Date: 2026-11-17 04:19:48 SE Asia Standard Time
4
+ # Description:
5
+ # License: MIT
6
+
7
+ from django.apps import AppConfig
8
+
9
+
10
+ class UsermgmtConfig(AppConfig):
11
+ default_auto_field = "django.db.models.BigAutoField"
12
+ name = "usermgmt"
13
+ verbose_name = "User Management CLI"
@@ -0,0 +1,6 @@
1
+ # File: django-usermgmt/usermgmt/management/__init__.py
2
+ # Author: Hadi Cahyadi <cumulus13@gmail.com>
3
+ # Date: 2026-11-17 04:19:48 SE Asia Standard Time
4
+ # Description:
5
+ # License: MIT
6
+
@@ -0,0 +1,6 @@
1
+ # File: django-usermgmt/usermgmt/management/commands/__init__.py
2
+ # Author: Hadi Cahyadi <cumulus13@gmail.com>
3
+ # Date: 2026-11-17 04:19:48 SE Asia Standard Time
4
+ # Description:
5
+ # License: MIT
6
+