Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Fix for TOTP #50

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions examples/4_totp_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,26 @@ def to_json(self, secret):

async def add(self, bot, team, issuer, secret):
val = json.dumps(self.to_json(secret))
await bot.kvstore.put(self.NAMESPACE, issuer, val, team)
await bot.kvstore.put(
namespace=self.NAMESPACE, entry_key=issuer, entry_value=val, team=team
)

async def remove(self, bot, team, issuer):
# throws exception if nothing to delete
await bot.kvstore.delete(self.NAMESPACE, issuer, team)
await bot.kvstore.delete(namespace=self.NAMESPACE, entry_key=issuer, team=team)

async def list(self, bot, team):
# returns all TOTP entryKeys (the issuers) in this team
res = await bot.kvstore.list_entrykeys(self.NAMESPACE, team)
res = await bot.kvstore.list_entrykeys(namespace=self.NAMESPACE, team=team)
if res.entry_keys:
return [e.entry_key for e in res.entry_keys]
else:
return []

async def now(self, bot, team, issuer):
res = await bot.kvstore.get(self.NAMESPACE, issuer, team)
res = await bot.kvstore.get(
namespace=self.NAMESPACE, entry_key=issuer, team=team
)
if bot.kvstore.is_present(res):
# if secret is present
secret = json.loads(res.entry_value)["secret"]
Expand Down