You are here

README.txt in TFA Basic plugins 7

## Basic plugins for TFA module

Intent is to provide basic functionality of TFA Drupal module and to be an
example of TFA plugin development.

Please use the public issue queue for all feature and support requests:
https://www.drupal.org/project/issues/tfa_basic

### Plugins

 * TOTP
 A Time-based One Time Password plugin using PHP_Gansta\GoogleAuthenticator
 PHP library.

 * Trusted Browsers
 A TFA login plugin allowing browsers to be marked "trusted" so that subsequent
 logins will not require TFA for a 30 day window.

 * Recovery Codes
 Pre-generated one-time-use codes.

 * Twilio SMS
 Optional plugin for sending TFA codes via SMS messages. See SMS section below.

### Variables

 * tfa_basic_secret_key
 Secret key to to use as encryption key for TOTP seed encryption. Should be set
 in settings.php and not in the Drupal database.

 * tfa_basic_time_skew
 Number of 30 second chunks to allow TOTP keys between.

 * tfa_basic_name_prefix
 Prefix for TOTP QR code names. Suffix is account username.

 * tfa_basic_cookie_name
 Cookie name of TFA trusted browser cookie. Default is "TB".

 * tfa_basic_cookie_domain
 Cookie domain for TFA trusted browser cookie.

 * tfa_basic_trust_cookie_expiration
 How long before TFA cookies expire. Default is 30 days.

 * tfa_basic_accepted_code_expiration
 How long before accepted TOTP codes expire. Default is 1 day.

## Using qrcode.js library instead of Google images

By default the module uses Google's Chart API to create a QR code. That request
will leak the seed to google in the URL of an HTTP GET request which reduces
the security of the seed. The module also supports the qrcode.js project which
will create the QR code image without leaking information to third-party sites.

To enable qrcode.js you simply have to place the library in the
tfa_basic/includes directory. From the command line:

  cd tfa_basic/includes/
  git clone https://github.com/davidshimjs/qrcodejs.git

The qrcode.min.js file should be at tfa_basic/includes/qrcodejs/qrcode.min.js

No additional setup is necessary, if the file exists in the right location then
it will be used.

## Using SMS for TFA codes

Prerequisites:

 1. Set up a Twilio account and credit at twilio.com.
 2. Install Twilio PHP library.
 3. Provide account mobile phone number by:
   a. Creating an account textfield and configuring it for TFA use, or
   b. Implementing hook_tfa_basic_get_mobile_number_alter()

### Installing Twilio PHP library

TFA SMS plugin requires the Twilio PHP library for sending SMS codes. You can
install the Twilio PHP library manually or via the Drupal Libraries API.

Option 1, install Twilio PHP manually:

  cd tfa_basic/includes/
  git clone https://github.com/twilio/twilio-php.git

Such that the file tfa_basic/includes/twilio-php/Services/Twilio.php exists.

Option 2, install via Drupal Libraries API:

 1. Install Drupal Libraries API: https://www.drupal.org/project/libraries
 2. Download the Twilio PHP library from (http://www.twilio.com/docs/libraries).
 3. Extract the library in your sites/all/libraries folder and rename the
    directory to 'twilio'.

### Account mobile phone numbers

Accounts using SMS for TFA code delivery must have a mobile phone number able
set. By default, TFA Basic's SMS plugin has support for storing mobile numbers
in user account fields. Create a text field on an account and you can set its
use by the plugin on the TFA administration configuration page.

If you want to store the mobile number somewhere else you'll need to write a bit
of code to integrate with TFA Basic.

First, set the variable tfa_basic_phone_field to FALSE. This will inform TFA
Basic that you are using custom storage.

  drush vset tfa_basic_phone_field FALSE

Finally, implement hook_tfa_basic_get_mobile_number_alter() in a custom module.
The sole argument is an array with elements 'account' and 'number'. 'account' is
the Drupal user account object you can use in finding the mobile number.
'number' will be an empty string if there's no account field in use. You should
set the 'number' property to the mobile number you have stored.

When an account is enabling SMS delivery they have the option to change the
mobile number receiving SMS codes. If the number is changed you can implement
hook_tfa_basic_set_mobile_number_alter() in a custom module to update your
storage.

#### Handling numbers that are not NANP

* Implement hook_tfa_basic_valid_number_alter() for number validation
* Implement hook_tfa_basic_format_number_alter() for formatting number output

File

README.txt
View source
  1. ## Basic plugins for TFA module
  2. Intent is to provide basic functionality of TFA Drupal module and to be an
  3. example of TFA plugin development.
  4. Please use the public issue queue for all feature and support requests:
  5. https://www.drupal.org/project/issues/tfa_basic
  6. ### Plugins
  7. * TOTP
  8. A Time-based One Time Password plugin using PHP_Gansta\GoogleAuthenticator
  9. PHP library.
  10. * Trusted Browsers
  11. A TFA login plugin allowing browsers to be marked "trusted" so that subsequent
  12. logins will not require TFA for a 30 day window.
  13. * Recovery Codes
  14. Pre-generated one-time-use codes.
  15. * Twilio SMS
  16. Optional plugin for sending TFA codes via SMS messages. See SMS section below.
  17. ### Variables
  18. * tfa_basic_secret_key
  19. Secret key to to use as encryption key for TOTP seed encryption. Should be set
  20. in settings.php and not in the Drupal database.
  21. * tfa_basic_time_skew
  22. Number of 30 second chunks to allow TOTP keys between.
  23. * tfa_basic_name_prefix
  24. Prefix for TOTP QR code names. Suffix is account username.
  25. * tfa_basic_cookie_name
  26. Cookie name of TFA trusted browser cookie. Default is "TB".
  27. * tfa_basic_cookie_domain
  28. Cookie domain for TFA trusted browser cookie.
  29. * tfa_basic_trust_cookie_expiration
  30. How long before TFA cookies expire. Default is 30 days.
  31. * tfa_basic_accepted_code_expiration
  32. How long before accepted TOTP codes expire. Default is 1 day.
  33. ## Using qrcode.js library instead of Google images
  34. By default the module uses Google's Chart API to create a QR code. That request
  35. will leak the seed to google in the URL of an HTTP GET request which reduces
  36. the security of the seed. The module also supports the qrcode.js project which
  37. will create the QR code image without leaking information to third-party sites.
  38. To enable qrcode.js you simply have to place the library in the
  39. tfa_basic/includes directory. From the command line:
  40. cd tfa_basic/includes/
  41. git clone https://github.com/davidshimjs/qrcodejs.git
  42. The qrcode.min.js file should be at tfa_basic/includes/qrcodejs/qrcode.min.js
  43. No additional setup is necessary, if the file exists in the right location then
  44. it will be used.
  45. ## Using SMS for TFA codes
  46. Prerequisites:
  47. 1. Set up a Twilio account and credit at twilio.com.
  48. 2. Install Twilio PHP library.
  49. 3. Provide account mobile phone number by:
  50. a. Creating an account textfield and configuring it for TFA use, or
  51. b. Implementing hook_tfa_basic_get_mobile_number_alter()
  52. ### Installing Twilio PHP library
  53. TFA SMS plugin requires the Twilio PHP library for sending SMS codes. You can
  54. install the Twilio PHP library manually or via the Drupal Libraries API.
  55. Option 1, install Twilio PHP manually:
  56. cd tfa_basic/includes/
  57. git clone https://github.com/twilio/twilio-php.git
  58. Such that the file tfa_basic/includes/twilio-php/Services/Twilio.php exists.
  59. Option 2, install via Drupal Libraries API:
  60. 1. Install Drupal Libraries API: https://www.drupal.org/project/libraries
  61. 2. Download the Twilio PHP library from (http://www.twilio.com/docs/libraries).
  62. 3. Extract the library in your sites/all/libraries folder and rename the
  63. directory to 'twilio'.
  64. ### Account mobile phone numbers
  65. Accounts using SMS for TFA code delivery must have a mobile phone number able
  66. set. By default, TFA Basic's SMS plugin has support for storing mobile numbers
  67. in user account fields. Create a text field on an account and you can set its
  68. use by the plugin on the TFA administration configuration page.
  69. If you want to store the mobile number somewhere else you'll need to write a bit
  70. of code to integrate with TFA Basic.
  71. First, set the variable tfa_basic_phone_field to FALSE. This will inform TFA
  72. Basic that you are using custom storage.
  73. drush vset tfa_basic_phone_field FALSE
  74. Finally, implement hook_tfa_basic_get_mobile_number_alter() in a custom module.
  75. The sole argument is an array with elements 'account' and 'number'. 'account' is
  76. the Drupal user account object you can use in finding the mobile number.
  77. 'number' will be an empty string if there's no account field in use. You should
  78. set the 'number' property to the mobile number you have stored.
  79. When an account is enabling SMS delivery they have the option to change the
  80. mobile number receiving SMS codes. If the number is changed you can implement
  81. hook_tfa_basic_set_mobile_number_alter() in a custom module to update your
  82. storage.
  83. #### Handling numbers that are not NANP
  84. * Implement hook_tfa_basic_valid_number_alter() for number validation
  85. * Implement hook_tfa_basic_format_number_alter() for formatting number output