putplace-server 0.8.2__tar.gz

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.
Files changed (57) hide show
  1. putplace_server-0.8.2/.gitignore +97 -0
  2. putplace_server-0.8.2/PKG-INFO +182 -0
  3. putplace_server-0.8.2/README.md +131 -0
  4. putplace_server-0.8.2/pyproject.toml +124 -0
  5. putplace_server-0.8.2/src/putplace_server/__init__.py +5 -0
  6. putplace_server-0.8.2/src/putplace_server/auth.py +279 -0
  7. putplace_server-0.8.2/src/putplace_server/cleanup_tasks.py +42 -0
  8. putplace_server-0.8.2/src/putplace_server/config.py +273 -0
  9. putplace_server-0.8.2/src/putplace_server/database.py +573 -0
  10. putplace_server-0.8.2/src/putplace_server/email_service.py +197 -0
  11. putplace_server-0.8.2/src/putplace_server/email_tokens.py +41 -0
  12. putplace_server-0.8.2/src/putplace_server/main.py +4195 -0
  13. putplace_server-0.8.2/src/putplace_server/models.py +222 -0
  14. putplace_server-0.8.2/src/putplace_server/ppserver.py +519 -0
  15. putplace_server-0.8.2/src/putplace_server/scripts/README_send_ses_email.md +388 -0
  16. putplace_server-0.8.2/src/putplace_server/scripts/__init__.py +1 -0
  17. putplace_server-0.8.2/src/putplace_server/scripts/atlas_cluster_control.py +379 -0
  18. putplace_server-0.8.2/src/putplace_server/scripts/create_api_key.py +119 -0
  19. putplace_server-0.8.2/src/putplace_server/scripts/deploy_digitalocean.py +986 -0
  20. putplace_server-0.8.2/src/putplace_server/scripts/deploy_digitalocean_old.py +487 -0
  21. putplace_server-0.8.2/src/putplace_server/scripts/pp_manage_users.py +1031 -0
  22. putplace_server-0.8.2/src/putplace_server/scripts/putplace_configure.py +1176 -0
  23. putplace_server-0.8.2/src/putplace_server/scripts/send_ses_email.py +324 -0
  24. putplace_server-0.8.2/src/putplace_server/scripts/setup_apprunner_fixed_ip.py +352 -0
  25. putplace_server-0.8.2/src/putplace_server/scripts/setup_aws_iam_users.py +446 -0
  26. putplace_server-0.8.2/src/putplace_server/scripts/toggle_registration.py +241 -0
  27. putplace_server-0.8.2/src/putplace_server/scripts/update_apprunner_vpc.py +196 -0
  28. putplace_server-0.8.2/src/putplace_server/scripts/update_deployment.py +175 -0
  29. putplace_server-0.8.2/src/putplace_server/static/README.md +67 -0
  30. putplace_server-0.8.2/src/putplace_server/static/css/.gitkeep +1 -0
  31. putplace_server-0.8.2/src/putplace_server/static/images/.gitkeep +5 -0
  32. putplace_server-0.8.2/src/putplace_server/static/images/LOGO_USAGE.md +152 -0
  33. putplace_server-0.8.2/src/putplace_server/static/images/favicon.svg +16 -0
  34. putplace_server-0.8.2/src/putplace_server/static/images/putplace-logo.svg +25 -0
  35. putplace_server-0.8.2/src/putplace_server/static/js/.gitkeep +1 -0
  36. putplace_server-0.8.2/src/putplace_server/storage.py +456 -0
  37. putplace_server-0.8.2/src/putplace_server/user_auth.py +52 -0
  38. putplace_server-0.8.2/src/putplace_server/version.py +3 -0
  39. putplace_server-0.8.2/tests/__init__.py +1 -0
  40. putplace_server-0.8.2/tests/conftest.py +383 -0
  41. putplace_server-0.8.2/tests/test_admin_creation.py +196 -0
  42. putplace_server-0.8.2/tests/test_api.py +397 -0
  43. putplace_server-0.8.2/tests/test_api_endpoints.py +366 -0
  44. putplace_server-0.8.2/tests/test_auth.py +324 -0
  45. putplace_server-0.8.2/tests/test_auth_api_keys.py +294 -0
  46. putplace_server-0.8.2/tests/test_configure.py +258 -0
  47. putplace_server-0.8.2/tests/test_configure_helper.py +207 -0
  48. putplace_server-0.8.2/tests/test_console_scripts.py +359 -0
  49. putplace_server-0.8.2/tests/test_database.py +534 -0
  50. putplace_server-0.8.2/tests/test_e2e.py +540 -0
  51. putplace_server-0.8.2/tests/test_electron_gui.py +229 -0
  52. putplace_server-0.8.2/tests/test_email_confirmation.py +344 -0
  53. putplace_server-0.8.2/tests/test_models.py +162 -0
  54. putplace_server-0.8.2/tests/test_ppserver.py +477 -0
  55. putplace_server-0.8.2/tests/test_registration_control.py +112 -0
  56. putplace_server-0.8.2/tests/test_send_ses_email.py +322 -0
  57. putplace_server-0.8.2/tests/test_storage.py +328 -0
@@ -0,0 +1,97 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ pip-wheel-metadata/
20
+ share/python-wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+ MANIFEST
25
+
26
+ # Virtual environments
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ env.bak/
32
+ venv.bak/
33
+
34
+ # uv
35
+ .python-version
36
+ uv.lock
37
+
38
+ # Testing
39
+ .pytest_cache/
40
+ .coverage
41
+ .coverage.*
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+
49
+ # Type checking
50
+ .mypy_cache/
51
+ .dmypy.json
52
+ dmypy.json
53
+ .pyre/
54
+ .pytype/
55
+
56
+ # Linting
57
+ .ruff_cache/
58
+
59
+ # IDEs
60
+ .vscode/
61
+ .idea/
62
+ *.swp
63
+ *.swo
64
+ *~
65
+ .DS_Store
66
+
67
+ # Jupyter Notebook
68
+ .ipynb_checkpoints
69
+
70
+ # Configuration files (actual config files, not templates)
71
+ ppserver.toml
72
+ ppserver-*.toml
73
+ *-config.toml
74
+
75
+ # Client configuration
76
+ ppclient.conf
77
+
78
+ # AWS credentials and configuration output
79
+ aws_credentials_output/
80
+ .env
81
+ .env.*
82
+ !.env.example
83
+
84
+ # Documentation
85
+ docs/_build/
86
+
87
+ # Storage
88
+ storage/
89
+ .storage/
90
+
91
+ # PutPlace server runtime files
92
+ .ppserver.pid
93
+ ppserver.log
94
+
95
+ # Backup directories from package split
96
+ src_old/
97
+ tests_old/
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: putplace-server
3
+ Version: 0.8.2
4
+ Summary: PutPlace FastAPI server for file metadata storage
5
+ License: Apache-2.0
6
+ Classifier: Development Status :: 4 - Beta
7
+ Classifier: Framework :: FastAPI
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: System Administrators
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: System :: Archiving
18
+ Classifier: Topic :: System :: Filesystems
19
+ Classifier: Topic :: System :: Systems Administration
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: aioboto3>=12.0.0
22
+ Requires-Dist: argon2-cffi>=23.1.0
23
+ Requires-Dist: authlib>=1.3.0
24
+ Requires-Dist: boto3>=1.34.0
25
+ Requires-Dist: certifi>=2023.0.0
26
+ Requires-Dist: configargparse>=1.7.0
27
+ Requires-Dist: fastapi>=0.110.0
28
+ Requires-Dist: google-auth>=2.27.0
29
+ Requires-Dist: httpx>=0.26.0
30
+ Requires-Dist: invoke>=2.2.1
31
+ Requires-Dist: pydantic-settings>=2.1.0
32
+ Requires-Dist: pydantic>=2.6.0
33
+ Requires-Dist: pymongo>=4.10.0
34
+ Requires-Dist: python-dotenv>=1.0.0
35
+ Requires-Dist: python-jose[cryptography]>=3.3.0
36
+ Requires-Dist: python-multipart>=0.0.6
37
+ Requires-Dist: rich>=13.7.0
38
+ Requires-Dist: tomli-w>=1.0.0
39
+ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
40
+ Requires-Dist: uvicorn[standard]>=0.27.0
41
+ Provides-Extra: dev
42
+ Requires-Dist: invoke>=2.2.0; extra == 'dev'
43
+ Requires-Dist: mypy>=1.8.0; extra == 'dev'
44
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
45
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
46
+ Requires-Dist: pytest-xdist>=3.5.0; extra == 'dev'
47
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
48
+ Requires-Dist: ruff>=0.3.0; extra == 'dev'
49
+ Requires-Dist: twine>=5.0.0; extra == 'dev'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # PutPlace Server
53
+
54
+ A FastAPI-based file metadata storage service using MongoDB.
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install putplace-server
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ ```bash
65
+ # Start MongoDB (using Docker)
66
+ docker run -d --name mongodb -p 27017:27017 mongo:latest
67
+
68
+ # Configure the server (creates admin user, tests connections)
69
+ putplace_configure
70
+
71
+ # Start the server
72
+ ppserver start
73
+
74
+ # Check server status
75
+ ppserver status
76
+
77
+ # View logs
78
+ ppserver logs
79
+ ```
80
+
81
+ ## Features
82
+
83
+ - REST API for storing and retrieving file metadata
84
+ - MongoDB backend with async support
85
+ - JWT and API key authentication
86
+ - User registration with email confirmation
87
+ - Admin dashboard for user management
88
+ - S3 storage backend support (optional)
89
+ - Google OAuth integration (optional)
90
+
91
+ ## API Endpoints
92
+
93
+ - `GET /` - Root endpoint
94
+ - `GET /health` - Health check
95
+ - `POST /put_file` - Store file metadata
96
+ - `GET /get_file/{sha256}` - Retrieve file by SHA256 hash
97
+ - `GET /docs` - Interactive API documentation (Swagger UI)
98
+ - `GET /redoc` - Alternative API documentation
99
+
100
+ ## Configuration
101
+
102
+ Configuration via environment variables or `.env` file:
103
+
104
+ ```bash
105
+ MONGODB_URL=mongodb://localhost:27017
106
+ MONGODB_DATABASE=putplace
107
+ API_TITLE=PutPlace API
108
+ API_VERSION=0.8.1
109
+
110
+ # Admin user (created on first startup)
111
+ PUTPLACE_ADMIN_EMAIL=admin@example.com
112
+ PUTPLACE_ADMIN_PASSWORD=your-secure-password
113
+ ```
114
+
115
+ Or via `ppserver.toml`:
116
+
117
+ ```toml
118
+ [server]
119
+ host = "0.0.0.0"
120
+ port = 8000
121
+
122
+ [mongodb]
123
+ url = "mongodb://localhost:27017"
124
+ database = "putplace"
125
+ ```
126
+
127
+ ## Server Management
128
+
129
+ ```bash
130
+ # Start server (background)
131
+ ppserver start
132
+
133
+ # Start with custom options
134
+ ppserver start --host 0.0.0.0 --port 8080
135
+
136
+ # Stop server
137
+ ppserver stop
138
+
139
+ # Restart server
140
+ ppserver restart
141
+
142
+ # Check status
143
+ ppserver status
144
+
145
+ # View logs
146
+ ppserver logs
147
+ ppserver logs --follow
148
+ ```
149
+
150
+ ## User Management
151
+
152
+ ```bash
153
+ # List all users
154
+ pp_manage_users list
155
+
156
+ # Add a new user
157
+ pp_manage_users add --email user@example.com
158
+
159
+ # Delete a user
160
+ pp_manage_users delete --email user@example.com
161
+
162
+ # Reset password
163
+ pp_manage_users reset-password --email user@example.com
164
+
165
+ # Set/unset admin privileges
166
+ pp_manage_users setadmin --email user@example.com
167
+ pp_manage_users unsetadmin --email user@example.com
168
+
169
+ # List pending registrations
170
+ pp_manage_users pending
171
+
172
+ # Approve pending user
173
+ pp_manage_users approve --email user@example.com
174
+ ```
175
+
176
+ ## Related
177
+
178
+ - [putplace-client](https://pypi.org/project/putplace-client/) - CLI tool for scanning directories and uploading file metadata
179
+
180
+ ## License
181
+
182
+ Apache-2.0
@@ -0,0 +1,131 @@
1
+ # PutPlace Server
2
+
3
+ A FastAPI-based file metadata storage service using MongoDB.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install putplace-server
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Start MongoDB (using Docker)
15
+ docker run -d --name mongodb -p 27017:27017 mongo:latest
16
+
17
+ # Configure the server (creates admin user, tests connections)
18
+ putplace_configure
19
+
20
+ # Start the server
21
+ ppserver start
22
+
23
+ # Check server status
24
+ ppserver status
25
+
26
+ # View logs
27
+ ppserver logs
28
+ ```
29
+
30
+ ## Features
31
+
32
+ - REST API for storing and retrieving file metadata
33
+ - MongoDB backend with async support
34
+ - JWT and API key authentication
35
+ - User registration with email confirmation
36
+ - Admin dashboard for user management
37
+ - S3 storage backend support (optional)
38
+ - Google OAuth integration (optional)
39
+
40
+ ## API Endpoints
41
+
42
+ - `GET /` - Root endpoint
43
+ - `GET /health` - Health check
44
+ - `POST /put_file` - Store file metadata
45
+ - `GET /get_file/{sha256}` - Retrieve file by SHA256 hash
46
+ - `GET /docs` - Interactive API documentation (Swagger UI)
47
+ - `GET /redoc` - Alternative API documentation
48
+
49
+ ## Configuration
50
+
51
+ Configuration via environment variables or `.env` file:
52
+
53
+ ```bash
54
+ MONGODB_URL=mongodb://localhost:27017
55
+ MONGODB_DATABASE=putplace
56
+ API_TITLE=PutPlace API
57
+ API_VERSION=0.8.1
58
+
59
+ # Admin user (created on first startup)
60
+ PUTPLACE_ADMIN_EMAIL=admin@example.com
61
+ PUTPLACE_ADMIN_PASSWORD=your-secure-password
62
+ ```
63
+
64
+ Or via `ppserver.toml`:
65
+
66
+ ```toml
67
+ [server]
68
+ host = "0.0.0.0"
69
+ port = 8000
70
+
71
+ [mongodb]
72
+ url = "mongodb://localhost:27017"
73
+ database = "putplace"
74
+ ```
75
+
76
+ ## Server Management
77
+
78
+ ```bash
79
+ # Start server (background)
80
+ ppserver start
81
+
82
+ # Start with custom options
83
+ ppserver start --host 0.0.0.0 --port 8080
84
+
85
+ # Stop server
86
+ ppserver stop
87
+
88
+ # Restart server
89
+ ppserver restart
90
+
91
+ # Check status
92
+ ppserver status
93
+
94
+ # View logs
95
+ ppserver logs
96
+ ppserver logs --follow
97
+ ```
98
+
99
+ ## User Management
100
+
101
+ ```bash
102
+ # List all users
103
+ pp_manage_users list
104
+
105
+ # Add a new user
106
+ pp_manage_users add --email user@example.com
107
+
108
+ # Delete a user
109
+ pp_manage_users delete --email user@example.com
110
+
111
+ # Reset password
112
+ pp_manage_users reset-password --email user@example.com
113
+
114
+ # Set/unset admin privileges
115
+ pp_manage_users setadmin --email user@example.com
116
+ pp_manage_users unsetadmin --email user@example.com
117
+
118
+ # List pending registrations
119
+ pp_manage_users pending
120
+
121
+ # Approve pending user
122
+ pp_manage_users approve --email user@example.com
123
+ ```
124
+
125
+ ## Related
126
+
127
+ - [putplace-client](https://pypi.org/project/putplace-client/) - CLI tool for scanning directories and uploading file metadata
128
+
129
+ ## License
130
+
131
+ Apache-2.0
@@ -0,0 +1,124 @@
1
+ [project]
2
+ name = "putplace-server"
3
+ # IMPORTANT: Keep this version in sync with src/putplace_server/version.py!
4
+ version = "0.8.2"
5
+ description = "PutPlace FastAPI server for file metadata storage"
6
+ readme = "README.md"
7
+ license = {text = "Apache-2.0"}
8
+ requires-python = ">=3.10"
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Intended Audience :: Developers",
12
+ "Intended Audience :: System Administrators",
13
+ "License :: OSI Approved :: Apache Software License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Framework :: FastAPI",
21
+ "Topic :: System :: Archiving",
22
+ "Topic :: System :: Filesystems",
23
+ "Topic :: System :: Systems Administration",
24
+ ]
25
+ dependencies = [
26
+ "fastapi>=0.110.0",
27
+ "uvicorn[standard]>=0.27.0",
28
+ "pymongo>=4.10.0",
29
+ "pydantic>=2.6.0",
30
+ "pydantic-settings>=2.1.0",
31
+ "python-dotenv>=1.0.0",
32
+ "httpx>=0.26.0",
33
+ "rich>=13.7.0",
34
+ "configargparse>=1.7.0",
35
+ "python-multipart>=0.0.6",
36
+ "argon2-cffi>=23.1.0",
37
+ "python-jose[cryptography]>=3.3.0",
38
+ "tomli>=2.0.0; python_version < '3.11'",
39
+ "tomli-w>=1.0.0",
40
+ "authlib>=1.3.0",
41
+ "google-auth>=2.27.0",
42
+ "certifi>=2023.0.0",
43
+ "boto3>=1.34.0",
44
+ "aioboto3>=12.0.0",
45
+ "invoke>=2.2.1",
46
+ ]
47
+
48
+ [project.scripts]
49
+ ppserver = "putplace_server.ppserver:main"
50
+ putplace_configure = "putplace_server.scripts.putplace_configure:main"
51
+ pp_manage_users = "putplace_server.scripts.pp_manage_users:run"
52
+
53
+ [project.optional-dependencies]
54
+ dev = [
55
+ "pytest>=8.0.0",
56
+ "pytest-cov>=4.1.0",
57
+ "pytest-asyncio>=0.23.0",
58
+ "pytest-xdist>=3.5.0",
59
+ "invoke>=2.2.0",
60
+ "ruff>=0.3.0",
61
+ "mypy>=1.8.0",
62
+ "twine>=5.0.0",
63
+ ]
64
+
65
+ [build-system]
66
+ requires = ["hatchling"]
67
+ build-backend = "hatchling.build"
68
+
69
+ [tool.hatch.build.targets.wheel]
70
+ packages = ["src/putplace_server"]
71
+
72
+ [tool.pytest.ini_options]
73
+ testpaths = ["tests"]
74
+ python_files = ["test_*.py"]
75
+ python_classes = ["Test*"]
76
+ python_functions = ["test_*"]
77
+ addopts = [
78
+ "--strict-markers",
79
+ "--strict-config",
80
+ "--cov=putplace_server",
81
+ "--cov-report=term-missing",
82
+ "--cov-report=html",
83
+ ]
84
+ markers = [
85
+ "integration: marks tests as integration tests (require server and database)",
86
+ ]
87
+ asyncio_mode = "auto"
88
+
89
+ [tool.ruff]
90
+ line-length = 100
91
+ target-version = "py310"
92
+
93
+ [tool.ruff.lint]
94
+ select = [
95
+ "E", # pycodestyle errors
96
+ "W", # pycodestyle warnings
97
+ "F", # pyflakes
98
+ "I", # isort
99
+ "B", # flake8-bugbear
100
+ "C4", # flake8-comprehensions
101
+ "UP", # pyupgrade
102
+ ]
103
+ ignore = []
104
+
105
+ [tool.ruff.lint.per-file-ignores]
106
+ "tests/**/*" = ["B", "S101"]
107
+ "src/putplace_server/ppserver.py" = ["T201"] # Allow print statements in server script
108
+
109
+ [tool.mypy]
110
+ python_version = "3.10"
111
+ warn_return_any = true
112
+ warn_unused_configs = true
113
+ disallow_untyped_defs = true
114
+ disallow_incomplete_defs = true
115
+ check_untyped_defs = true
116
+ no_implicit_optional = true
117
+ warn_redundant_casts = true
118
+ warn_unused_ignores = true
119
+ warn_no_return = true
120
+ strict_equality = true
121
+
122
+ [[tool.mypy.overrides]]
123
+ module = "tests.*"
124
+ disallow_untyped_defs = false
@@ -0,0 +1,5 @@
1
+ """PutPlace Server - FastAPI server for file metadata storage."""
2
+
3
+ from .version import __version__
4
+
5
+ __all__ = ["__version__"]