From e9f8eb9af0c4f42dd4e68ae05580f77dc352aaf4 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Wed, 3 Jun 2015 02:05:11 +0800 Subject: Describe provisioning URI in the document. --- docs/hazmat/primitives/twofactor.rst | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/twofactor.rst b/docs/hazmat/primitives/twofactor.rst index dd3e0250..dace6f7d 100644 --- a/docs/hazmat/primitives/twofactor.rst +++ b/docs/hazmat/primitives/twofactor.rst @@ -74,6 +74,14 @@ codes (HMAC). :raises cryptography.hazmat.primitives.twofactor.InvalidToken: This is raised when the supplied HOTP does not match the expected HOTP. + .. method:: get_provisioning_uri(account_name, counter, issuer=None) + + :param str account_name: The display name of account, such as + ``'Alice Smith'`` or ``'alice@example.com'``. + :param str issuer: The optional display name of issuer. + :param int counter: The current value of counter. + :return str: An URI string. + Throttling ~~~~~~~~~~ @@ -171,3 +179,33 @@ similar to the following code. :param int time: The time value to validate against. :raises cryptography.hazmat.primitives.twofactor.InvalidToken: This is raised when the supplied TOTP does not match the expected TOTP. + + .. method:: get_provisioning_uri(account_name, issuer=None) + + :param str account_name: The display name of account, such as + ``'Alice Smith'`` or ``'alice@example.com'``. + :param str issuer: The optional display name of issuer. + :return str: An URI string. + +Provisioning URI +~~~~~~~~~~~~~~~~ + +The provisioning URI of HOTP and TOTP is not actual the part of RFC 4226 and +RFC 6238, but a `spec of Google Authenticator `_. It is +wide supported by web sites and mobile applications which using Two-Factor +authentication. + +For generating a provisioning URI, you could use the ``get_provisioning_uri`` +method of HOTP/TOTP instances. + +.. code-block:: python + + counter = 5 + account_name = 'alice@example.com' + issuer_name = 'Example Inc' + + hotp_uri = hotp.get_provisioning_uri(account_name, counter, issuer_name) + totp_uri = totp.get_provisioning_uri(account_name, issuer_name) + +A common usage is encoding the provisioning URI into QR code and guiding users +to scan it with Two-Factor authentication applications in their mobile devices. -- cgit v1.2.3 From d4e0a839ef676a2ed05140f98ef3630deb0fdd61 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Wed, 3 Jun 2015 17:30:11 +0800 Subject: Remove a default argument and rename a private function. --- docs/hazmat/primitives/twofactor.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/twofactor.rst b/docs/hazmat/primitives/twofactor.rst index dace6f7d..016c30eb 100644 --- a/docs/hazmat/primitives/twofactor.rst +++ b/docs/hazmat/primitives/twofactor.rst @@ -74,11 +74,12 @@ codes (HMAC). :raises cryptography.hazmat.primitives.twofactor.InvalidToken: This is raised when the supplied HOTP does not match the expected HOTP. - .. method:: get_provisioning_uri(account_name, counter, issuer=None) + .. method:: get_provisioning_uri(account_name, counter, issuer) :param str account_name: The display name of account, such as ``'Alice Smith'`` or ``'alice@example.com'``. - :param str issuer: The optional display name of issuer. + :param issuer: The optional display name of issuer. + :type issuer: `string` or `None` :param int counter: The current value of counter. :return str: An URI string. @@ -180,11 +181,12 @@ similar to the following code. :raises cryptography.hazmat.primitives.twofactor.InvalidToken: This is raised when the supplied TOTP does not match the expected TOTP. - .. method:: get_provisioning_uri(account_name, issuer=None) + .. method:: get_provisioning_uri(account_name, issuer) :param str account_name: The display name of account, such as ``'Alice Smith'`` or ``'alice@example.com'``. - :param str issuer: The optional display name of issuer. + :param issuer: The optional display name of issuer. + :type issuer: `string` or `None` :return str: An URI string. Provisioning URI -- cgit v1.2.3 From 0d9dbbe40d95cc623df218ebf74ef66f3bc1c758 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Wed, 3 Jun 2015 20:37:39 +0800 Subject: add license header and fix grammar errors. --- docs/hazmat/primitives/twofactor.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/twofactor.rst b/docs/hazmat/primitives/twofactor.rst index 016c30eb..e149da02 100644 --- a/docs/hazmat/primitives/twofactor.rst +++ b/docs/hazmat/primitives/twofactor.rst @@ -194,8 +194,8 @@ Provisioning URI The provisioning URI of HOTP and TOTP is not actual the part of RFC 4226 and RFC 6238, but a `spec of Google Authenticator `_. It is -wide supported by web sites and mobile applications which using Two-Factor -authentication. +widely supported by web sites and mobile applications which are using +Two-Factor authentication. For generating a provisioning URI, you could use the ``get_provisioning_uri`` method of HOTP/TOTP instances. -- cgit v1.2.3 From 840a99b253e11554c166ccd7de22b553db627ee3 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Wed, 3 Jun 2015 23:58:10 +0800 Subject: Move the external link to page bottom. --- docs/hazmat/primitives/twofactor.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/twofactor.rst b/docs/hazmat/primitives/twofactor.rst index e149da02..f49d02f9 100644 --- a/docs/hazmat/primitives/twofactor.rst +++ b/docs/hazmat/primitives/twofactor.rst @@ -193,9 +193,8 @@ Provisioning URI ~~~~~~~~~~~~~~~~ The provisioning URI of HOTP and TOTP is not actual the part of RFC 4226 and -RFC 6238, but a `spec of Google Authenticator `_. It is -widely supported by web sites and mobile applications which are using -Two-Factor authentication. +RFC 6238, but a `spec of Google Authenticator`_. It is widely supported by web +sites and mobile applications which are using Two-Factor authentication. For generating a provisioning URI, you could use the ``get_provisioning_uri`` method of HOTP/TOTP instances. @@ -211,3 +210,5 @@ method of HOTP/TOTP instances. A common usage is encoding the provisioning URI into QR code and guiding users to scan it with Two-Factor authentication applications in their mobile devices. + +.. _`spec of Google Authenticator`: https://github.com/google/google-authenticator/wiki/Key-Uri-Format -- cgit v1.2.3