Skip to content

Commit acf264e

Browse files
committed
fix for #53
Per Google's otpauth:// URI spec (https://github.com/google/google-authenticator/wiki/Key-Uri-Format#issuer), the issuer in the URI path and the issuer parameter are equivalent. Per #53, Authy does not correctly parse the latter. Therefore, we include only the former (issuer in the URI path) for maximum compatibility.
1 parent 318cb71 commit acf264e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_generate_totp_uri():
8989
'timeskew': 0,
9090
}
9191
test_secret = b'ZqeD\xd9wg]"\x12\x1f7\xc7v6"\xf0\x13\\i'
92-
expected_uri = urlparse.urlparse('otpauth://totp/VIP%20Access:SYMC26070843?secret=LJYWKRGZO5TV2IQSD434O5RWELYBGXDJ&issuer=VIP%20Access&digits=6&algorithm=SHA1&period=30&image=https://raw.githubusercontent.com/dlenski/python-vipaccess/master/vipaccess.png')
92+
expected_uri = urlparse.urlparse('otpauth://totp/VIP%20Access:SYMC26070843?secret=LJYWKRGZO5TV2IQSD434O5RWELYBGXDJ&digits=6&algorithm=SHA1&period=30&image=https://raw.githubusercontent.com/dlenski/python-vipaccess/master/vipaccess.png')
9393
generated_uri = urlparse.urlparse(generate_otp_uri(test_token, test_secret))
9494
assert_equal(expected_uri.scheme, generated_uri.scheme)
9595
assert_equal(expected_uri.netloc, generated_uri.netloc)
@@ -113,7 +113,7 @@ def test_generate_hotp_uri():
113113
'timeskew': 0,
114114
}
115115
test_secret = b'\x9a\x13\xcd2!\xad\xbd\x97R\xfcEE\xb6\x92e\xb4\x14\xb0\xfem'
116-
expected_uri = urlparse.urlparse('otpauth://hotp/VIP%20Access:UBHE57586348?digits=6&algorithm=SHA1&counter=1&issuer=VIP%20Access&secret=TIJ42MRBVW6ZOUX4IVC3NETFWQKLB7TN&image=https://raw.githubusercontent.com/dlenski/python-vipaccess/master/vipaccess.png')
116+
expected_uri = urlparse.urlparse('otpauth://hotp/VIP%20Access:UBHE57586348?digits=6&algorithm=SHA1&counter=1&secret=TIJ42MRBVW6ZOUX4IVC3NETFWQKLB7TN&image=https://raw.githubusercontent.com/dlenski/python-vipaccess/master/vipaccess.png')
117117
generated_uri = urlparse.urlparse(generate_otp_uri(test_token, test_secret))
118118
assert_equal(expected_uri.scheme, generated_uri.scheme)
119119
assert_equal(expected_uri.netloc, generated_uri.netloc)

vipaccess/provision.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ def generate_otp_uri(token, secret, issuer='VIP Access', image='https://raw.gith
185185
secret=secret,
186186
digits=token.get('digits', 6),
187187
algorithm=token.get('algorithm', 'SHA1').upper(),
188-
issuer=issuer,
189188
image=image,
189+
# Per Google's otpauth:// URI spec (https://github.com/google/google-authenticator/wiki/Key-Uri-Format#issuer),
190+
# the issuer in the URI path and the issuer parameter are equivalent.
191+
# Per #53, Authy does not correctly parse the latter.
192+
# Therefore, we include only the former (issuer in the URI path) for maximum compatibility.
193+
# issuer=issuer,
190194
)
191195
if token.get('counter') is not None: # HOTP
192196
data['counter'] = token['counter']

0 commit comments

Comments
 (0)