fix(dashboard): address persistent auth review
This commit is contained in:
@@ -150,14 +150,30 @@ def test_oversized_and_malformed_tokens_are_rejected() -> None:
|
||||
|
||||
|
||||
def test_payload_does_not_encode_secrets() -> None:
|
||||
settings = replace(_settings(), admin_id="configured-admin-identity")
|
||||
issued = authentication.issue_persistent_token(
|
||||
_settings(),
|
||||
settings,
|
||||
remember_me=False,
|
||||
now=1_700_000_000,
|
||||
token_id="fixed-token-id",
|
||||
)
|
||||
payload = authentication._serializer_for(_settings()).loads(issued.value)
|
||||
payload = authentication._serializer_for(settings).loads(issued.value)
|
||||
|
||||
assert set(payload) == {"v", "sub", "iat", "exp", "jti"}
|
||||
assert "password" not in json.dumps(payload).lower()
|
||||
assert "secret" not in json.dumps(payload).lower()
|
||||
assert settings.admin_id not in json.dumps(payload)
|
||||
|
||||
|
||||
def test_remember_me_token_expires_at_exact_30_day_boundary() -> None:
|
||||
settings = _settings()
|
||||
issued = authentication.issue_persistent_token(
|
||||
settings, remember_me=True, now=1_700_000_000, token_id="boundary-token-id"
|
||||
)
|
||||
|
||||
assert authentication.verify_persistent_token(
|
||||
settings, issued.value, now=issued.expires_at - 1
|
||||
) is not None
|
||||
assert authentication.verify_persistent_token(
|
||||
settings, issued.value, now=issued.expires_at
|
||||
) is None
|
||||
|
||||
Reference in New Issue
Block a user