You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fetch the settings from e.g. a framework config and [invoke the `TwoFactorQRCodeOptions` instance](https://php-qrcode.readthedocs.io/en/v5.0.x/Usage/Advanced-usage.html#configuration-via-qroptions) with it.
47
-
Please note that this object combines the settings for [`AuthenticatorOptions`](https://github.com/chillerlan/php-authenticator?tab=readme-ov-file#authenticatoroptions) and [`QROptions`](https://php-qrcode.readthedocs.io/en/v5.0.x/Usage/Configuration-settings.html).
46
+
Fetch the settings from e.g. a framework config and [invoke the `TwoFactorQRCodeOptions` instance](https://php-qrcode.readthedocs.io/en/v6.0.x/Usage/Advanced-usage.html#configuration-via-qroptions) with it.
47
+
Please note that this object combines the settings for [`AuthenticatorOptions`](https://github.com/chillerlan/php-authenticator?tab=readme-ov-file#authenticatoroptions) and [`QROptions`](https://php-qrcode.readthedocs.io/en/v6.0.x/Usage/Configuration-settings.html).
48
+
Alternatively, you can just pass an `iterable` of options to the `TwoFactorQRCode` constructor.
48
49
49
50
```php
50
-
use chillerlan\TwoFactorQRCode\{TwoFactorQRCode, TwoFactorQRCodeOptions};
51
+
use chillerlan\TwoFactorQRCode\TwoFactorQRCode;
51
52
52
53
$options = [
53
54
'secret_length' => 128,
54
55
'adjacent' => 2,
55
56
];
56
57
57
-
$twoFactorQRCodeOptions = new TwoFactorQRCodeOptions($options);
58
-
$twoFactorQRCode = new TwoFactorQRCode($twoFactorQRCodeOptions);
58
+
$twoFactorQRCode = new TwoFactorQRCode($options);
59
59
```
60
60
61
61
#### User registration
@@ -100,7 +100,6 @@ The user has lost access to their authenticator, send them to a form separate fr
100
100
- Verify the given backup OTP against the stored counter value.
101
101
- After verification, increase the counter, create a new backup code and save the new counter value.
102
102
- Present the new backup code to the user and make them triple check that they have carefully saved it.
103
-
- Redirect the user to wherever they can manage their 2FA settings and retrieve their secret once again.
|`createSecret(int\|null $length = null)`|`string`| Creates a cryptograpically secure random secret and returns it as Base32 encoded string |
165
-
|`setSecret(string $encodedSecret)`|`static`| Sets a secret phrase from an encoded representation |
166
-
|`getSecret()`|`string`| Returns an encoded representation of the current secret phrase |
167
-
|`setRawSecret(string $rawSecret)`|`static`| Sets a secret phrase from a raw binary representation |
168
-
|`getRawSecret()`|`string`| Returns the raw representation of the current secret phrase |
169
-
|`verifyOTP(string $otp, int\|null $timestamp = null)`|`bool`| Verifies a one-time password (TOTP) with an optional unix timestamp |
170
-
|`createBackupCode(int $counter)`|`string`| Creates a counter-based one-time password (HOTP) from the given counter value |
171
-
|`verifyBackupCode(string $otp, int $counter)`|`bool`| Verifies a counter-based backup code (HOTP) against the given counter value |
172
-
|`getQRCode(string $label, string $issuer)`|`string`| Creates a QR Code for use with a mobile authenticator application (TOTP) with the given label and issuer name |
|`__construct(SettingsContainerInterface\|TwoFactorQRCodeOptions \|iterable $options = new TwoFactorQRCodeOptions)`| - ||
172
+
|`createSecret(int\|null $length = null)`|`string`| Creates a cryptograpically secure random secret and returns it as Base32 encoded string |
173
+
|`setSecret(string $encodedSecret)`|`static`| Sets a secret phrase from an encoded representation |
174
+
|`getSecret()`|`string`| Returns an encoded representation of the current secret phrase |
175
+
|`setRawSecret(string $rawSecret)`|`static`| Sets a secret phrase from a raw binary representation |
176
+
|`getRawSecret()`|`string`| Returns the raw representation of the current secret phrase |
177
+
|`verifyOTP(string $otp, int\|null $timestamp = null)`|`bool`| Verifies a one-time password (TOTP) with an optional unix timestamp |
178
+
|`createBackupCode(int $counter)`|`string`| Creates a counter-based one-time password (HOTP) from the given counter value |
179
+
|`verifyBackupCode(string $otp, int $counter)`|`bool`| Verifies a counter-based backup code (HOTP) against the given counter value |
180
+
|`getQRCode(string $label, string $issuer)`|`string`| Creates a QR Code for use with a mobile authenticator application (TOTP) with the given label and issuer name |
0 commit comments