totp: rename tfa to totp

This commit is contained in:
Jens Langhammer
2018-12-14 10:09:57 +01:00
parent 52d1920914
commit fbf58801ec
17 changed files with 79 additions and 78 deletions

22
passbook/totp/utils.py Normal file
View File

@ -0,0 +1,22 @@
"""passbook Mod TOTP Utils"""
from django.conf import settings
from django.utils.http import urlencode
def otpauth_url(accountname, secret, issuer=None, digits=6):
"""Create otpauth according to
https://github.com/google/google-authenticator/wiki/Key-Uri-Format"""
accountname = accountname
issuer = issuer if issuer else getattr(settings, 'OTP_TOTP_ISSUER')
# Ensure that the secret parameter is the FIRST parameter of the URI, this
# allows Microsoft Authenticator to work.
query = [
('secret', secret),
('digits', digits),
('issuer', issuer),
]
return 'otpauth://totp/%s:%s?%s' % (issuer, accountname, urlencode(query))