Completed
Push — master ( b97427...e235cc )
by Raffael
30:35 queued 26:08
created

Installation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2019 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Webauthn\Migration\Delta;
13
14
use Balloon\App\Idp\Storage\Db as OAuth2Storage;
15
use Balloon\Migration\Delta\DeltaInterface;
16
use MongoDB\Database;
17
18
class Installation implements DeltaInterface
19
{
20
    /**
21
     * MongoDB.
22
     *
23
     * @var Database
24
     */
25
    protected $db;
26
27
    /**
28
     * OAuth2 storage.
29
     *
30
     * @var OAuth2Storage
31
     */
32
    protected $storage;
33
34
    /**
35
     * Construct.
36
     */
37
    public function __construct(OAuth2Storage $storage, Database $db)
38
    {
39
        $this->storage = $storage;
40
        $this->db = $db;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function start(): bool
47
    {
48
        $this->storage->setClientDetails('balloon-client-web', null, null, 'password refresh_token password_mfa webauthn webauthn_mfa');
49
        $this->storage->setClientDetails('balloon-client-desktop', null, null, 'password refresh_token password_mfa webauthn webauthn_mfa');
50
        $this->db->creation_challenges->createIndex(['created' => 1], ['expireAfterSeconds' => 60]);
51
        $this->db->request_challenges->createIndex(['created' => 1], ['expireAfterSeconds' => 60]);
52
53
        return true;
54
    }
55
}
56