Debian Codegraph @

doc/sources/admin/totp2f.rst

raw
1 TOTP 2nd Factor Authentication
2 ==============================
3
4 `Time based One Time
5 Password <https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm>`__
6 (TOTP) is an algorithm that computes a one-time password from a shared
7 secret key and the current time. This is currently use by `Google
8 Authenticator <https://en.wikipedia.org/wiki/Google_Authenticator>`__ or
9 `FreeOTP <https://freeotp.github.io/>`__.
10
11 LLNG can propose users to register this kind of software to increase
12 authentication level.
13
14
15 .. tip::
16
17 Note that it's a second factor, not an authentication module.
18 Users are authenticated both by login form and TOTP.
19
20 Prerequisites and dependencies
21 ------------------------------
22
23 This feature uses libconvert-base32-perl. Before enable it, on Debian
24 you must install libconvert-base32-perl by :
25
26 ::
27
28 apt update
29 apt install libconvert-base32-perl
30
31 Or from CPAN repository :
32
33 ::
34
35 cpanm Convert::Base32
36
37 Configuration
38 -------------
39
40 In the manager (advanced parameters), you just have to enable it:
41
42 - **Activation**: set it to "on"
43 - **Self registration**: set it to "on" if users are authorized to
44 generate themselves a TOTP secret
45 - **Allow users to remove TOTP**: If enabled, users can unregister
46 TOTP
47 - **Issuer name** (Optional): default to portal hostname
48 - **Time step**: size of the time-step window for TOTP algorithm (default: 30)
49
50 .. warning::
51
52 Many mobile applications only support the default value
53
54 - **Number of digits**: number of digits in codes (default: 6)
55
56 .. warning::
57
58 Many mobile applications only support the default value
59
60 - **Algorithm**: hash function to use for TOTP algorithm (default: SHA-1)
61
62 .. warning::
63
64 Many mobile applications only support the default value
65
66 - **Range of attempts**: number of additional intervals to test (default: 1).
67 Use this settings if your server and phone clocks are not perfectly in sync,
68 at the cost of weaker security.
69
70 .. note::
71
72 Range is tested backward and forward to prevent
73 positive or negative clock drift.
74
75 - **Authentication level**: you can overwrite here auth level for TOTP
76 registered users. Leave it blank keeps auth level provided by first
77 authentication module *(default: 2 for user/password based modules)*.
78 **It is recommended to set an higher value here if you want to give
79 access to some apps only for enrolled users**
80 - **Label** (Optional): label that should be displayed to the user on
81 the choice screen
82 - **Logo** (Optional): logo file *(in static/<skin> directory)*
83 - **Lifetime** (Optional): Unlimited by default. Set a Time To Live in seconds.
84 TTL is checked at each login process if set. If TTL is expired,
85 relative TOTP is removed.
86 - **Encrypt TOTP secrets**: By default, the TOTP secret key is stored in the
87 persistent session database in cleartext. Set this option to encrypt all
88 newly-generated secrets. More details :ref:`below<totp-encryption>`
89 - **Logo** (Optional): logo file *(in static/<skin> directory)*
90 - **Label** (Optional): label that should be displayed to the user on
91 the choice screen
92
93
94 .. attention::
95
96 If you want to use a custom rule for "activation" and want to keep self-registration,
97 you must add the following condition to the custom activation rule::
98
99 and has2f('TOTP')
100
101 Without this condition, TOTP will be asked even for users who didn't register one.
102 This is automatically done when "activation" is simply set to "on".
103
104
105 Enrollment
106 ----------
107
108 If you've enabled self registration, users can register their keys by
109 using https://portal/2fregisters
110
111 Assistance
112 ----------
113
114 If a user loses its key, you can remove it from manager Second Factor
115 module.// // To enable manager Second Factor Administration Module, set
116 ``enabledModules`` key in your ``lemonldap-ng.ini`` file :// //
117
118 .. code-block:: ini
119
120 [portal]
121 enabledModules = conf, sessions, notifications, 2ndFA
122
123 .. _totp-encryption:
124
125 Encryption of TOTP secrets
126 --------------------------
127
128 During registration of a TOTP device, a secret key is exchanged between the
129 mobile device and the server, generally through the use of a QR-Code. Once the
130 exchange is done, secret keys must never leave the device or the server.
131
132 Administrators may want to protect TOTP secrets by encrypting them in the
133 persistent session database, in order to prevent them from leaking through
134 backups or unauthorized database access.
135
136 Setting the *Encrypt TOTP secrets* option will automatically encrypt newly
137 generated secrets.
138
139 The *Encrypt TOTP secrets* options only affects *NEW* secrets, meaning that:
140
141 * A cleartext TOTP secret will be accepted even if the option is on
142 * An already encrypted TOTP secret will be accepted even if the option if off
143
144 The ``encryptTotpSecrets`` script can be used to encrypt previously registered TOTP
145 secrets so that they can be protected as well.
146
147 Encryption key
148 ~~~~~~~~~~~~~~
149
150 By default, the key used for encryption is the global one, set in
151
152 *General Parameters* » *Advanced Parameters* » *Security* » *Key*
153
154 However, if you store your configuration and persistent sessions in the same
155 database, this defeats the point of encryption entirely.
156
157 It is recommended to set the TOTP encryption key in ``/etc/lemonldap-ng/lemonldap-ng.ini`` instead::
158
159 [all]
160 totp2fKey=changeme
161
162 Developer corner
163 ----------------
164
165 If you have another TOTP registration interface, you have to set these
166 keys in Second Factor Devices array (JSON) in your user-database. Then
167 map it to the \_2fDevices attribute (see
168 :doc:`exported variables<exportedvars>`):
169
170 .. code::
171
172 [{"name" : "MyTOTP" , "type" : "TOTP" , "_secret" : "########" , "epoch":"1524078936"}, ...]
173