jigkit 0.5.1__tar.gz → 0.6.0__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.
- {jigkit-0.5.1 → jigkit-0.6.0}/PKG-INFO +2 -2
- {jigkit-0.5.1 → jigkit-0.6.0}/README.md +1 -1
- {jigkit-0.5.1 → jigkit-0.6.0}/pyproject.toml +1 -1
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/auth/__init__.py +1 -5
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_auth.py +1 -31
- jigkit-0.5.1/src/jigkit/auth/setup.py +0 -34
- {jigkit-0.5.1 → jigkit-0.6.0}/.gitignore +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/LICENSE +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/__init__.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/auth/cookies.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/auth/passwords.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/auth/sessions.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/auth/throttle.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/db.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/delivery.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/healthcheck.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/heartbeat.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/influx/__init__.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/influx/lineprotocol.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/influx/sink.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/logging.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/migrations.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/models.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/notify.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/py.typed +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/ratelimit.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/scheduler.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/secrets.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/settings.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/sinks.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/spool.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/testing/__init__.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/testing/http.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/testing/migrations.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/testing/notify.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/__init__.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/guard.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/health.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/manifest.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/server.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/src/jigkit/web/spa.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/conftest.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/sample_app/alembic/env.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/sample_app/alembic/script.py.mako +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/sample_app/alembic/versions/0001_initial.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/sample_app/alembic.ini +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/sample_app/sample_schema.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_db.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_delivery.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_healthcheck.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_heartbeat.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_influx_lineprotocol.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_influx_read.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_influx_sink.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_logging.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_migrations.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_models.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_notify.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_ratelimit.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_scheduler.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_secrets.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_settings.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_sinks.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_spool.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_testing_plugin.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_version.py +0 -0
- {jigkit-0.5.1 → jigkit-0.6.0}/tests/test_web.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: jigkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: The shared foundations of small self-hosted web apps: settings, database, migrations, logging, health checks and test fixtures
|
|
5
5
|
Project-URL: Homepage, https://github.com/jmerhar/jigkit
|
|
6
6
|
Project-URL: Changelog, https://github.com/jmerhar/jigkit/blob/main/CHANGELOG.md
|
|
@@ -86,7 +86,7 @@ pip install "jigkit[db]"
|
|
|
86
86
|
| `jigkit.scheduler` | — | `TickLoop`: in-process work on a fixed tick |
|
|
87
87
|
| `jigkit.notify` | `notify` | Apprise delivery off the event loop, and URL redaction for logs |
|
|
88
88
|
| `jigkit.ratelimit` | — | `RateLimiter`: a token bucket per client with bounded memory |
|
|
89
|
-
| `jigkit.auth` | `auth` | Argon2id passwords, a bounded failed-login throttle, the
|
|
89
|
+
| `jigkit.auth` | `auth` | Argon2id passwords, a bounded failed-login throttle, the session cookie |
|
|
90
90
|
| `jigkit.auth.sessions` | `auth`, `db` | logins in the database as hashed, revocable tokens with a sliding expiry |
|
|
91
91
|
| `jigkit.testing` | `testing` | a pytest plugin (`data_dir`, `no_network`), migration checks run through the application's own `env.py`, and a recording stand-in HTTP server |
|
|
92
92
|
|
|
@@ -25,7 +25,7 @@ pip install "jigkit[db]"
|
|
|
25
25
|
| `jigkit.scheduler` | — | `TickLoop`: in-process work on a fixed tick |
|
|
26
26
|
| `jigkit.notify` | `notify` | Apprise delivery off the event loop, and URL redaction for logs |
|
|
27
27
|
| `jigkit.ratelimit` | — | `RateLimiter`: a token bucket per client with bounded memory |
|
|
28
|
-
| `jigkit.auth` | `auth` | Argon2id passwords, a bounded failed-login throttle, the
|
|
28
|
+
| `jigkit.auth` | `auth` | Argon2id passwords, a bounded failed-login throttle, the session cookie |
|
|
29
29
|
| `jigkit.auth.sessions` | `auth`, `db` | logins in the database as hashed, revocable tokens with a sliding expiry |
|
|
30
30
|
| `jigkit.testing` | `testing` | a pytest plugin (`data_dir`, `no_network`), migration checks run through the application's own `env.py`, and a recording stand-in HTTP server |
|
|
31
31
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jigkit"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
description = "The shared foundations of small self-hosted web apps: settings, database, migrations, logging, health checks and test fixtures"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Logging people in (extra ``auth``): passwords, the login throttle
|
|
1
|
+
"""Logging people in (extra ``auth``): passwords, the login throttle and the session cookie.
|
|
2
2
|
|
|
3
3
|
Database sessions are in :mod:`jigkit.auth.sessions`, which also needs the ``db`` extra.
|
|
4
4
|
"""
|
|
@@ -11,12 +11,10 @@ from jigkit.auth.passwords import (
|
|
|
11
11
|
hash_password,
|
|
12
12
|
verify_password,
|
|
13
13
|
)
|
|
14
|
-
from jigkit.auth.setup import SETUP_TOKEN_DISABLED, resolve_setup_token, setup_token_matches
|
|
15
14
|
from jigkit.auth.throttle import LoginThrottle
|
|
16
15
|
|
|
17
16
|
__all__ = [
|
|
18
17
|
"MIN_PASSWORD_LENGTH",
|
|
19
|
-
"SETUP_TOKEN_DISABLED",
|
|
20
18
|
"LoginThrottle",
|
|
21
19
|
"PasswordTooShort",
|
|
22
20
|
"burn_password_check",
|
|
@@ -24,7 +22,5 @@ __all__ = [
|
|
|
24
22
|
"cookie_secure",
|
|
25
23
|
"hash_password",
|
|
26
24
|
"issue_session_cookie",
|
|
27
|
-
"resolve_setup_token",
|
|
28
|
-
"setup_token_matches",
|
|
29
25
|
"verify_password",
|
|
30
26
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Passwords, the login throttle,
|
|
1
|
+
"""Passwords, the login throttle, the session cookie and database sessions."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -14,7 +14,6 @@ from sqlalchemy.ext.asyncio import AsyncEngine
|
|
|
14
14
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
15
15
|
|
|
16
16
|
from jigkit.auth import (
|
|
17
|
-
SETUP_TOKEN_DISABLED,
|
|
18
17
|
LoginThrottle,
|
|
19
18
|
PasswordTooShort,
|
|
20
19
|
burn_password_check,
|
|
@@ -22,8 +21,6 @@ from jigkit.auth import (
|
|
|
22
21
|
cookie_secure,
|
|
23
22
|
hash_password,
|
|
24
23
|
issue_session_cookie,
|
|
25
|
-
resolve_setup_token,
|
|
26
|
-
setup_token_matches,
|
|
27
24
|
verify_password,
|
|
28
25
|
)
|
|
29
26
|
from jigkit.auth.sessions import SessionMixin, SessionStore, token_digest
|
|
@@ -111,33 +108,6 @@ class TestLoginThrottle:
|
|
|
111
108
|
assert not throttle.blocked("b")
|
|
112
109
|
|
|
113
110
|
|
|
114
|
-
class TestSetupToken:
|
|
115
|
-
def test_a_configured_token_is_used(self) -> None:
|
|
116
|
-
assert resolve_setup_token("let-me-in") == "let-me-in"
|
|
117
|
-
|
|
118
|
-
def test_one_is_generated_when_none_is_configured(self) -> None:
|
|
119
|
-
first, second = resolve_setup_token(None), resolve_setup_token("")
|
|
120
|
-
|
|
121
|
-
assert first and second and first != second
|
|
122
|
-
|
|
123
|
-
def test_it_can_be_switched_off(self) -> None:
|
|
124
|
-
assert resolve_setup_token(SETUP_TOKEN_DISABLED) is None
|
|
125
|
-
|
|
126
|
-
@pytest.mark.parametrize(
|
|
127
|
-
("expected", "given", "matches"),
|
|
128
|
-
[
|
|
129
|
-
("token", "token", True),
|
|
130
|
-
("token", "tokeN", False),
|
|
131
|
-
("token", None, False),
|
|
132
|
-
("token", "tökén", False),
|
|
133
|
-
(None, None, True),
|
|
134
|
-
(None, "anything", True),
|
|
135
|
-
],
|
|
136
|
-
)
|
|
137
|
-
def test_matching(self, expected: str | None, given: str | None, matches: bool) -> None:
|
|
138
|
-
assert setup_token_matches(expected, given) is matches
|
|
139
|
-
|
|
140
|
-
|
|
141
111
|
def cookie_app() -> FastAPI:
|
|
142
112
|
"""An application that logs in and out with the session cookie."""
|
|
143
113
|
app = FastAPI()
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"""First-run setup: the token that guards creating the first administrator."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import hmac
|
|
6
|
-
import secrets
|
|
7
|
-
|
|
8
|
-
#: The value that turns the setup token off, for an instance nobody else can reach.
|
|
9
|
-
SETUP_TOKEN_DISABLED = "off"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def resolve_setup_token(configured: str | None) -> str | None:
|
|
13
|
-
"""The token the first-run setup will ask for, or None when it is switched off.
|
|
14
|
-
|
|
15
|
-
Generated when none is configured, so an instance reachable from the internet before anyone
|
|
16
|
-
has set it up cannot be claimed by whoever finds its address first. Log a generated token
|
|
17
|
-
where the operator will see it; it is needed once, and never after setup.
|
|
18
|
-
"""
|
|
19
|
-
if configured == SETUP_TOKEN_DISABLED:
|
|
20
|
-
return None
|
|
21
|
-
return configured or secrets.token_urlsafe(9)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def setup_token_matches(expected: str | None, given: str | None) -> bool:
|
|
25
|
-
"""Whether ``given`` is the setup token, compared in constant time.
|
|
26
|
-
|
|
27
|
-
With the token switched off (``expected`` None) anything matches. Compared as UTF-8 bytes, so
|
|
28
|
-
a token with non-ASCII characters is refused rather than raising.
|
|
29
|
-
"""
|
|
30
|
-
if expected is None:
|
|
31
|
-
return True
|
|
32
|
-
if given is None:
|
|
33
|
-
return False
|
|
34
|
-
return hmac.compare_digest(expected.encode(), given.encode())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|