This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-02-25 11:29:40 +00:00
|
|
|
"""passbook OTP Utils"""
|
2018-11-16 08:10:35 +00:00
|
|
|
|
|
|
|
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"""
|
|
|
|
# Ensure that the secret parameter is the FIRST parameter of the URI, this
|
|
|
|
# allows Microsoft Authenticator to work.
|
|
|
|
query = [
|
2019-12-31 11:51:16 +00:00
|
|
|
("secret", secret),
|
|
|
|
("digits", digits),
|
|
|
|
("issuer", "passbook"),
|
2018-11-16 08:10:35 +00:00
|
|
|
]
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
return "otpauth://totp/%s:%s?%s" % (issuer, accountname, urlencode(query))
|