Skip to content

Commit

Permalink
Update README.md and sample values
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Sep 7, 2024
1 parent 1d7d9e3 commit ad142cd
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ pyninja start
- **WORKERS** - Number of workers for the uvicorn server.
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **SERVICE_MANAGER** - Service manager filepath to handle the service status requests.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **APIKEY** - API Key for authentication.
Expand Down
4 changes: 4 additions & 0 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ <h2>Environment Variables<a class="headerlink" href="#environment-variables" tit
<li><p><strong>WORKERS</strong> - Number of workers for the uvicorn server.</p></li>
<li><p><strong>REMOTE_EXECUTION</strong> - Boolean flag to enable remote execution.</p></li>
<li><p><strong>API_SECRET</strong> - Secret access key for running commands on server remotely.</p></li>
<li><p><strong>MONITOR_USERNAME</strong> - Username to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_PASSWORD</strong> - Password to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_SESSION</strong> - Session timeout for the monitoring page.</p></li>
<li><p><strong>SERVICE_MANAGER</strong> - Service manager filepath to handle the service status requests.</p></li>
<li><p><strong>DATABASE</strong> - FilePath to store the auth database that handles the authentication errors.</p></li>
<li><p><strong>RATE_LIMIT</strong> - List of dictionaries with <code class="docutils literal notranslate"><span class="pre">max_requests</span></code> and <code class="docutils literal notranslate"><span class="pre">seconds</span></code> to apply as rate limit.</p></li>
<li><p><strong>APIKEY</strong> - API Key for authentication.</p></li>
Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ pyninja start
- **WORKERS** - Number of workers for the uvicorn server.
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **SERVICE_MANAGER** - Service manager filepath to handle the service status requests.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **APIKEY** - API Key for authentication.
Expand Down
4 changes: 4 additions & 0 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ pyninja start
- **WORKERS** - Number of workers for the uvicorn server.
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **SERVICE_MANAGER** - Service manager filepath to handle the service status requests.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **APIKEY** - API Key for authentication.
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyninja/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class EnvConfig(BaseSettings):
api_secret: str | None = None
monitor_username: str | None = None
monitor_password: str | None = None
monitor_session: PositiveInt = 10
monitor_session: PositiveInt = 3_600
service_manager: FilePath | ServiceManager = get_service_manager()
database: str = Field("auth.db", pattern=".*.db$")
rate_limit: RateLimit | List[RateLimit] = []
Expand Down
1 change: 1 addition & 0 deletions pyninja/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def get_all_routes() -> List[APIRoute]:
dependencies=dependencies,
)
)
# Conditional endpoint based on monitor_username and monitor_password
if all((models.env.monitor_username, models.env.monitor_password)):
routes.extend(monitor.get_all_monitor_routes(dependencies))
return routes
16 changes: 10 additions & 6 deletions release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ Release Notes

v0.0.4 (09/06/2024)
-------------------
- Include an option to monitor system resources via websockets
- Includes an option to monitor system resources via `WebSockets`

v0.0.3 (08/16/2024)
-------------------
- Release `v0.0.3`
- Allows env vars to be sourced from both ``env_file`` and ``kwargs``

v0.0.2 (08/16/2024)
-------------------
- Release `v0.0.2`
- Includes added support for custom log configuration

v0.0.1 (08/11/2024)
-------------------
- Release `v0.0.1`
- Includes a process monitor and remote command execution functionality
- Security improvements including brute force protection and rate limiting
- Accepts ``JSON`` and ``YAML`` files for env config
- Supports custom worker count for ``uvicorn`` server
- Allows custom logging using ``logging.ini``
- Includes an option to set the ``apikey`` via commandline

v0.0.0 (08/11/2024)
-------------------
- Implement concurrency for validating process health
- Update logger names across the module and README.md
- Release first stable version

0.0.0-a (08/10/2024)
--------------------
Expand Down
3 changes: 3 additions & 0 deletions samples/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ NINJA_PORT=8005
WORKERS=3
REMOTE_EXECUTION=True
API_SECRET="3A%3/[&1X>ARsz{hADFYI'}XhK4H)Gi~"
MONITOR_USERNAME="username"
MONITOR_PASSWORD="password"
MONITOR_SESSION=3600
DATABASE="auth_errors.db"
RATE_LIMIT='[{"max_requests": 3, "seconds": 1}, {"max_requests": 10, "seconds": 3}]'
APIKEY="MySecreatAccessToken"
3 changes: 3 additions & 0 deletions samples/secrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"WORKERS": 3,
"REMOTE_EXECUTION": true,
"API_SECRET": "3A%3/[&1X>ARsz{hADFYI'}XhK4H)Gi~",
"MONITOR_USERNAME": "username",
"MONITOR_PASSWORD": "password",
"MONITOR_SESSION": 3600,
"DATABASE": "auth_errors.db",
"RATE_LIMIT": [
{
Expand Down
9 changes: 6 additions & 3 deletions samples/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
NINJA_HOST: "0.0.0.0"
NINJA_HOST: 0.0.0.0
NINJA_PORT: 8005
WORKERS: 3
REMOTE_EXECUTION: true
API_SECRET: "3A%3/[&1X>ARsz{hADFYI'}XhK4H)Gi~"
DATABASE: "auth_errors.db"
MONITOR_USERNAME: username
MONITOR_PASSWORD: password
MONITOR_SESSION: 3600
DATABASE: auth_errors.db
RATE_LIMIT:
- max_requests: 3
seconds: 1
- max_requests: 10
seconds: 3
APIKEY: "MySecreatAccessToken"
APIKEY: MySecreatAccessToken

0 comments on commit ad142cd

Please sign in to comment.