| 1 |
Additional Second Factors |
| 2 |
========================= |
| 3 |
|
| 4 |
Starting with version 2.0.6, LemonLDAP::NG lets you configure multiple |
| 5 |
instances of second factor authentication modules, in a manner similar |
| 6 |
to the :doc:`Combination module<authcombination>`. |
| 7 |
|
| 8 |
Only the following Second Factor modules are compatible with this |
| 9 |
feature: |
| 10 |
|
| 11 |
- :doc:`E-Mail<mail2f>` |
| 12 |
- :doc:`External<external2f>` |
| 13 |
- :doc:`REST<rest2f>` |
| 14 |
|
| 15 |
Using this option, lets you give your users a wider range of possible |
| 16 |
second factors. They could decide between using their work email or home |
| 17 |
email. And as an administrator you may now plug in more than one Second |
| 18 |
Factor solution through :doc:`REST<rest2f>` or |
| 19 |
:doc:`external commands<external2f>`. |
| 20 |
|
| 21 |
Configuration |
| 22 |
------------- |
| 23 |
|
| 24 |
You can find the configuration for this feature in |
| 25 |
``General parameters`` » ``Second factors`` » |
| 26 |
``Additional second factors`` |
| 27 |
|
| 28 |
- ``Name``: the technical name of this second factor, it should be all |
| 29 |
lowercase, and it is used as a sort key when second factors are |
| 30 |
displayed to the user |
| 31 |
- ``Type``: what type of second factor you want to use |
| 32 |
- ``Label``: what title to display in the 2F choice screen |
| 33 |
- ``Logo`` : URL path of a logo to display in the 2F choice screen |
| 34 |
- ``Level``: authentication level that will be set if this 2F is used |
| 35 |
- ``Activation rule``: If you leave this field empty, this second factor will |
| 36 |
always be enabled. You may use a perl expression to decide when this |
| 37 |
second factor is available. |
| 38 |
|
| 39 |
- ``$homeMail`` : this second factor will only trigger if the |
| 40 |
``$homeMail`` session key exists |
| 41 |
- ``defined $hGroups->{'admin'}`` : this second factor will only |
| 42 |
trigger if the user is in the ``admin`` group |
| 43 |
- ``Registrable``: allow users to register their own contact information, see :ref:`below<sfextraregister>` |
| 44 |
- ``Registration rule``: The rule that decides when users can register this |
| 45 |
second factor. Leave it empty to use the same rule as the activation rule |
| 46 |
above |
| 47 |
|
| 48 |
After adding your second factors, don't forget to add overload |
| 49 |
parameters to them. You usually should at least give them different |
| 50 |
logos so that the user can tell the difference between two second |
| 51 |
factors of the same type. |
| 52 |
|
| 53 |
See the :doc:`parameters list<parameterlist>` page for a full list of |
| 54 |
parameters you may overload. Here are the most useful ones: |
| 55 |
|
| 56 |
* E-Mail |
| 57 |
* ``mail2fLogo`` |
| 58 |
* ``mailSessionKey`` |
| 59 |
* ``mail2fCodeRegex`` |
| 60 |
* ``mail2fSubject`` |
| 61 |
* ``mail2fBody`` |
| 62 |
* External |
| 63 |
* ``ext2fLogo`` |
| 64 |
* ``ext2fCodeActivation`` |
| 65 |
* ``ext2FSendCommand`` |
| 66 |
* ``ext2FValidateCommand`` |
| 67 |
* REST |
| 68 |
* ``rest2fLogo`` |
| 69 |
* ``rest2fVerifyUrl`` |
| 70 |
* ``rest2fVerifyArgs`` (must be a JSON object) |
| 71 |
* ``rest2fInitUrl`` |
| 72 |
* ``rest2fInitArgs`` (must be a JSON object) |
| 73 |
|
| 74 |
.. _sfextraregister: |
| 75 |
|
| 76 |
Registration |
| 77 |
------------ |
| 78 |
|
| 79 |
.. versionadded:: 2.0.16 |
| 80 |
|
| 81 |
Enabling registration for an additional second factor allows the user to register their own E-Mail address, SMS number, etc. |
| 82 |
|
| 83 |
This is only compatible with the :doc:`Mail <mail2f>`, :doc:`REST <rest2f>` and :doc:`External command <external2f>` modules. These modules will received the registered contact information through the ``destination`` variable, which you can use in ``ext2FSendCommand`` or ``rest2fInitArgs``. |
| 84 |
|
| 85 |
Template customization |
| 86 |
~~~~~~~~~~~~~~~~~~~~~~ |
| 87 |
|
| 88 |
When using the "registration" option for additional second factors, all second factor types will use ``generic2fregister.tpl`` for registration and ``ext2fcheck.tpl``. If you want to display different things (messages, forms, etc.) to the user for different second factor types, you can use the ``PREFIX`` variable in your templates. |
| 89 |
|
| 90 |
For example, if you defined a `homePhone` and `homeMail` extra second factor and want to overload the prompt message, replace |
| 91 |
|
| 92 |
.. code:: html |
| 93 |
|
| 94 |
<label for="generic">① <span trspan="genericRegisterPrompt">Enter your contact information</span></label> |
| 95 |
|
| 96 |
by: |
| 97 |
|
| 98 |
.. code:: |
| 99 |
|
| 100 |
<label for="generic">① <span trspan="<TMPL_VAR NAME="PREFIX">Prompt">Enter your contact information</span></label> |
| 101 |
|
| 102 |
And then set define ``homePhonePrompt`` and ``homeMailPrompt`` translation keys. |
| 103 |
|
| 104 |
You can also test for a particular second factor type |
| 105 |
|
| 106 |
.. code:: html |
| 107 |
|
| 108 |
<TMPL_IF NAME="PREFIX_homePhone"> |
| 109 |
Some info specific to the homePhone 2FA type |
| 110 |
</TMPL_IF> |
| 111 |
|
| 112 |
Regex validation |
| 113 |
~~~~~~~~~~~~~~~~ |
| 114 |
|
| 115 |
When using the "registration" option for additional second factors, you might want to specify a validation regexp for the registered value: check that the phone number is properly formatted, that the e-mail address does not use a forbidden domain, etc. |
| 116 |
|
| 117 |
In order to do this, you can define additional overload parameters: |
| 118 |
|
| 119 |
* ``generic2fFormatRegex``: the regexp you want to use |
| 120 |
* ``generic2fFormatErrorLabel``: the message label you want to show the user when this regexp fails. By default, ``generic2fFormatError`` is used. |
| 121 |
|
| 122 |
Don't forget to :ref:`define a human readable translation for this label <intlmessages>` |