Skip to content

Commit

Permalink
Fix missing now parameter in BaseShamirComponent.add_recovery_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Aug 21, 2024
1 parent 4612e4f commit 9349757
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions server/parsec/components/memory/shamir.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import override

from parsec._parsec import DeviceID, OrganizationID, UserID, VerifyKey, authenticated_cmds
from parsec._parsec import DateTime, DeviceID, OrganizationID, UserID, VerifyKey, authenticated_cmds
from parsec.ballpark import RequireGreaterTimestamp, TimestampOutOfBallpark
from parsec.components.events import EventBus
from parsec.components.memory.datamodel import (
Expand Down Expand Up @@ -68,6 +68,7 @@ async def remove_recovery_setup(
@override
async def add_recovery_setup(
self,
now: DateTime,
organization_id: OrganizationID,
author: UserID,
device: DeviceID,
Expand All @@ -88,7 +89,7 @@ async def add_recovery_setup(
case error:
return error

match shamir_add_recovery_setup_validate(setup, device, author, author_verify_key):
match shamir_add_recovery_setup_validate(now, setup, device, author, author_verify_key):
case (brief, shares):
pass
case error:
Expand Down
15 changes: 9 additions & 6 deletions server/parsec/components/shamir.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ async def api_shamir_recovery_setup(
return authenticated_cmds.latest.shamir_recovery_setup.RepOk()
else:
match await self.add_recovery_setup(
client_ctx.organization_id,
client_ctx.user_id,
client_ctx.device_id,
client_ctx.device_verify_key,
req.setup,
now=DateTime.now(),
organization_id=client_ctx.organization_id,
author=client_ctx.user_id,
device=client_ctx.device_id,
author_verify_key=client_ctx.device_verify_key,
setup=req.setup,
):
case None:
return authenticated_cmds.latest.shamir_recovery_setup.RepOk()
Expand Down Expand Up @@ -106,6 +107,7 @@ async def remove_recovery_setup(

async def add_recovery_setup(
self,
now: DateTime,
organization_id: OrganizationID,
author: UserID,
device: DeviceID,
Expand Down Expand Up @@ -152,6 +154,7 @@ class ShamirInvalidRecipientBadOutcome(BadOutcome):

# Check internal consistency of certificate
def shamir_add_recovery_setup_validate(
now: DateTime,
setup: authenticated_cmds.latest.shamir_recovery_setup.ShamirRecoverySetup,
author: DeviceID,
user_id: UserID,
Expand All @@ -169,7 +172,7 @@ def shamir_add_recovery_setup_validate(
except ValueError:
return ShamirAddRecoverySetupValidateBadOutcome.BRIEF_INVALID_DATA

match timestamps_in_the_ballpark(brief_certificate.timestamp, DateTime.now()):
match timestamps_in_the_ballpark(brief_certificate.timestamp, now):
case TimestampOutOfBallpark() as error:
return error
case _:
Expand Down

0 comments on commit 9349757

Please sign in to comment.