python-neva 0.6.0.dev1__tar.gz → 0.6.0.dev3__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.
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/PKG-INFO +1 -1
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/database/provider.py +0 -1
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/__init__.py +3 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/config.py +1 -1
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/hash_manager.py +0 -10
- python_neva-0.6.0.dev3/neva/security/tokens/__init__.py +5 -0
- python_neva-0.6.0.dev3/neva/security/tokens/token_hash.py +30 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/pyproject.toml +1 -1
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/uv.lock +1 -1
- python_neva-0.6.0.dev1/neva/security/hashing/hashers/sha256.py +0 -42
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/.envrc +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/.gitignore +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/.pre-commit-config.yaml +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/.python-version +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/README.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/app.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/application.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/config.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/facade.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/arch/service_provider.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/config/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/config/base_providers.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/config/loader.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/config/provider.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/config/repository.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/console/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/console/kernel.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/console/runner.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/database/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/database/config.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/database/manager.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/database/repository.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/dispatcher.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/event.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/event_registry.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/interface.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/events/listener.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/logging/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/logging/manager.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/logging/provider.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/middleware/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/middleware/correlation.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/obs/middleware/profiler.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/py.typed +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/encryption/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/encryption/encrypter.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/encryption/protocol.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/hashers/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/hashers/argon2.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/hashers/bcrypt.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/hashing/hashers/protocol.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/security/provider.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/accessors.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/app.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/app.pyi +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/config.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/config.pyi +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/crypt.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/crypt.pyi +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/hash.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/hash.pyi +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/log.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/facade/log.pyi +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/results.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/strategy.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/strconv.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/support/time.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/testing/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/testing/fixtures.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/testing/http.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/neva/testing/test_case.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/ruff.toml +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/specifications/future_ideas.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/specifications/security.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/__init__.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/conftest.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_encrypter.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_example_usage.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_fixtures.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_hash_manager.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_scope.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/tests/test_test_case.py +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/01-overview.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/02-dependency-injection.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/03-service-providers.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/04-facades.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/05-application-lifecycle.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/06-result-option.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/01-overview.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/02-configuration-files.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/03-accessing-configuration.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/04-config-repository.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/05-loading-process.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/06-configuration-in-providers.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/01-introduction.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/02-test-case.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/03-fixtures.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/04-http-testing.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/05-custom-configuration.md +0 -0
- {python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/testing/06-test-isolation.md +0 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from neva.security.encryption import AesEncrypter, DecryptionError, Encrypter
|
|
4
4
|
from neva.security.hashing import Argon2Hasher, BcryptHasher, HashManager, Hasher
|
|
5
5
|
from neva.security.provider import SecurityProvider
|
|
6
|
+
from neva.security.tokens import hash_token, verify_token
|
|
6
7
|
|
|
7
8
|
__all__ = [
|
|
8
9
|
"AesEncrypter",
|
|
@@ -13,4 +14,6 @@ __all__ = [
|
|
|
13
14
|
"HashManager",
|
|
14
15
|
"Hasher",
|
|
15
16
|
"SecurityProvider",
|
|
17
|
+
"hash_token",
|
|
18
|
+
"verify_token",
|
|
16
19
|
]
|
|
@@ -8,7 +8,6 @@ from neva.config import ConfigRepository
|
|
|
8
8
|
from neva.security.hashing.hashers.argon2 import Argon2Hasher
|
|
9
9
|
from neva.security.hashing.hashers.bcrypt import BcryptHasher
|
|
10
10
|
from neva.security.hashing.hashers.protocol import Hasher
|
|
11
|
-
from neva.security.hashing.hashers.sha256 import Sha256Hasher
|
|
12
11
|
from neva.support.strategy import StrategyResolver
|
|
13
12
|
|
|
14
13
|
|
|
@@ -25,7 +24,6 @@ class HashManager(StrategyResolver[Hasher]):
|
|
|
25
24
|
|
|
26
25
|
_ = self.register("argon2", self._create_argon2_hasher)
|
|
27
26
|
_ = self.register("bcrypt", self._create_bcrypt_hasher)
|
|
28
|
-
_ = self.register("sha256", self._create_sha256_hasher)
|
|
29
27
|
|
|
30
28
|
@override
|
|
31
29
|
def default(self) -> Option[str]:
|
|
@@ -146,11 +144,3 @@ class HashManager(StrategyResolver[Hasher]):
|
|
|
146
144
|
prefix=bcrypt_config.get("prefix", "2b"),
|
|
147
145
|
)
|
|
148
146
|
return BcryptHasher()
|
|
149
|
-
|
|
150
|
-
def _create_sha256_hasher(self, _: StrategyResolver[Hasher]) -> Sha256Hasher:
|
|
151
|
-
"""Create an instance of the SHA256 hash strategy.
|
|
152
|
-
|
|
153
|
-
Returns:
|
|
154
|
-
Configured Sha256Hasher instance.
|
|
155
|
-
"""
|
|
156
|
-
return Sha256Hasher()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Token hashing utilities."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import hmac
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def hash_token(token: str | bytes) -> str:
|
|
8
|
+
"""Hash a secure random token for storage.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
token: The token to hash.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
Hex-encoded hash of the token.
|
|
15
|
+
"""
|
|
16
|
+
data = token.encode() if isinstance(token, str) else token
|
|
17
|
+
return hashlib.sha256(data).hexdigest()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def verify_token(token: str | bytes, hashed: str) -> bool:
|
|
21
|
+
"""Verify a token against its stored hash.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
token: The plaintext token to verify.
|
|
25
|
+
hashed: The stored hash to verify against.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
True if the token matches, False otherwise.
|
|
29
|
+
"""
|
|
30
|
+
return hmac.compare_digest(hash_token(token), hashed)
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"""SHA256 hasher."""
|
|
2
|
-
|
|
3
|
-
import hashlib
|
|
4
|
-
from typing import override
|
|
5
|
-
from neva.security.hashing.hashers.protocol import Hasher
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def ensure_bytes(value: str | bytes) -> bytes:
|
|
9
|
-
"""Ensure the value is in bytes.
|
|
10
|
-
|
|
11
|
-
Returns:
|
|
12
|
-
the value in bytes
|
|
13
|
-
"""
|
|
14
|
-
return value.encode() if isinstance(value, str) else value
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class Sha256Hasher(Hasher):
|
|
18
|
-
"""SHA256 hasher."""
|
|
19
|
-
|
|
20
|
-
@override
|
|
21
|
-
def make(
|
|
22
|
-
self,
|
|
23
|
-
plaintext: str | bytes,
|
|
24
|
-
*,
|
|
25
|
-
salt: bytes | None = None,
|
|
26
|
-
) -> str:
|
|
27
|
-
return hashlib.sha256(ensure_bytes(plaintext)).hexdigest()
|
|
28
|
-
|
|
29
|
-
@override
|
|
30
|
-
def check(
|
|
31
|
-
self,
|
|
32
|
-
plaintext: str | bytes,
|
|
33
|
-
hashed: str | bytes,
|
|
34
|
-
) -> bool:
|
|
35
|
-
return hashlib.sha256(ensure_bytes(plaintext)).digest() == ensure_bytes(hashed)
|
|
36
|
-
|
|
37
|
-
@override
|
|
38
|
-
def needs_rehash(
|
|
39
|
-
self,
|
|
40
|
-
hashed: str | bytes,
|
|
41
|
-
) -> bool:
|
|
42
|
-
return False
|
|
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
|
|
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
|
{python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/02-dependency-injection.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/architecture/05-application-lifecycle.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/02-configuration-files.md
RENAMED
|
File without changes
|
{python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/03-accessing-configuration.md
RENAMED
|
File without changes
|
{python_neva-0.6.0.dev1 → python_neva-0.6.0.dev3}/wiki/configuration/04-config-repository.md
RENAMED
|
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
|