Skip to content

Commit

Permalink
Update default encryption key (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorensr authored Nov 24, 2022
1 parent 0560628 commit 1a414e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions encryption/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from temporalio.api.common.v1 import Payload
from temporalio.converter import PayloadCodec

default_key = base64.b64decode(b"MkUb3RVdHQuOTedqETZW7ra2GkZqpBRmYWRACUospMc=")
default_key_id = "my-key"
default_key = b"test-key-test-key-test-key-test!"
default_key_id = "test-key-id"


class EncryptionCodec(PayloadCodec):
Expand Down Expand Up @@ -43,7 +43,9 @@ async def decode(self, payloads: Iterable[Payload]) -> List[Payload]:
# Confirm our key ID is the same
key_id = p.metadata.get("encryption-key-id", b"").decode()
if key_id != self.key_id:
raise ValueError(f"Unrecognized key ID {key_id}")
raise ValueError(
f"Unrecognized key ID {key_id}. Current key ID is {self.key_id}."
)
# Decrypt and append
ret.append(Payload.FromString(self.decrypt(p.data)))
return ret
Expand Down
2 changes: 1 addition & 1 deletion encryption/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def main():
GreetingWorkflow.run,
"Temporal",
id=f"encryption-workflow-id",
task_queue="encryption-task-queue",
task_queue="encryption",
)
print(f"Workflow result: {result}")

Expand Down
2 changes: 1 addition & 1 deletion encryption/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from encryption.codec import EncryptionCodec


@workflow.defn
@workflow.defn(name="Workflow")
class GreetingWorkflow:
@workflow.run
async def run(self, name: str) -> str:
Expand Down

0 comments on commit 1a414e2

Please sign in to comment.