Add IMultifactorMethod
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 2 Nov 2020 13:55:08 +0000 (14:55 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 16 Nov 2020 16:25:03 +0000 (17:25 +0100)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/objectTypeDefinition.xml
com.woltlab.wcf/templates/accountSecurity.tpl
wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php [new file with mode: 0644]

index 3ad90f17004c612a58701f39c51d9a9eaf1cfcbf..334c8d3e92a93f7f162384d6cd0626b08efd929c 100644 (file)
                        <name>com.woltlab.wcf.multifactor.totp</name>
                        <definitionname>com.woltlab.wcf.multifactor</definitionname>
                        <icon>mobile</icon>
-                       <!-- TODO: classname -->
+                       <classname>wcf\system\user\multifactor\TotpMultifactorMethod</classname>
                </type>
                <!-- /multi factor -->
                <!-- deprecated -->
index aa476c34d9854b45be4905904b46a2f81a940bd0..35ea56d5281467d86cfb6c2ee6b54b9df497b2e5 100644 (file)
                </definition>
                <definition>
                        <name>com.woltlab.wcf.multifactor</name>
-                       <!-- TODO: interfacename -->
+                       <interfacename>wcf\system\user\multifactor\IMultifactorMethod</interfacename>
                </definition>
        </import>
        <delete>
index 12bc297d72c1f0d932f098a59582180709657b70..20a3954b47bfcd065b24260bff2ebe17df9fd04d 100644 (file)
@@ -16,7 +16,7 @@
                                        <div class="containerHeadline">
                                                <h3>{lang}wcf.user.security.multifactor.{$method->objectType}{/lang}</h3>
                                                
-                                               {$method|var_dump}
+                                               {$method->getProcessor()->getStatusText($__wcf->user)}
                                        </div>
                                </div>
                        </li>
diff --git a/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php
new file mode 100644 (file)
index 0000000..33ec715
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace wcf\system\user\multifactor;
+use wcf\data\user\User;
+
+/**
+ * Handles multifactor authentication for a specific authentication method.
+ *
+ * @author     Tim Duesterhus
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\System\User\Multifactor
+ * @since      5.4
+ */
+interface IMultifactorMethod {
+       /**
+        * Returns a human readable status text regarding the set-up status for the given user.
+        * 
+        * An example text could be: "5 backup codes remaining".
+        */
+       public function getStatusText(User $user): string;
+}
diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php
new file mode 100644 (file)
index 0000000..6c16f7f
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+namespace wcf\system\user\multifactor;
+use wcf\data\user\User;
+
+/**
+ * Implementation of the Time-based One-time Password Algorithm (RFC 6238).
+ *
+ * @author     Tim Duesterhus
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\System\User\Multifactor
+ * @since      5.4
+ */
+class TotpMultifactorMethod implements IMultifactorMethod {
+       /**
+        * Returns the number of devices the user set up.
+        */
+       public function getStatusText(User $user): string {
+               // TODO: Return a proper text.
+               return random_int(10000, 99999)." devices configured";
+       }
+}