1<?php
2
3/**
4 * @author Michael Blumenstein <M.Flower@gmx.de>
5 * @copyright Copyright (c) 2019 Michael Blumenstein <M.Flower@gmx.de>
6 *
7 * Two-factor webauthn
8 *
9 * This code is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License, version 3,
11 * as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License, version 3,
19 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20 *
21 *
22 * Software Credits
23 *
24 * The development of this software was made possible using the following components:
25 *
26 * twofactor_u2f (https://github.com/nextcloud/twofactor_u2f) by Christoph Wurst (https://github.com/ChristophWurst)
27 * Licensed Under: AGPL
28 * This project used the great twofactor provider u2f created by Christoph Wurst as a template.
29 *
30 * webauthn-framework (https://github.com/web-auth/webauthn-framework) by Florent Morselli (https://github.com/Spomky)
31 * Licensed Under: MIT
32 * The webauthn-framework provided most of the code and documentation for implementing the webauthn authentication.
33 */
34
35namespace OCA\TwoFactorWebauthn\Settings;
36
37use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
38use OCP\Template;
39
40class Personal implements IPersonalProviderSettings
41{
42
43    /** @var array */
44    private $devices;
45
46    public function __construct(array $devices) {
47        $this->devices = $devices;
48    }
49
50    /**
51     * @return Template
52     *
53     * @since 15.0.0
54     */
55    public function getBody(): Template {
56        $template = new Template('twofactor_webauthn', 'personal');
57        $template->assign('state', json_encode($this->devices));
58        return $template;
59    }
60}