Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
8 / 12
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
RecoveryCodesAuthenticationRequest
66.67% covered (warning)
66.67%
8 / 12
50.00% covered (danger)
50.00%
1 / 2
2.15
0.00% covered (danger)
0.00%
0 / 1
 describeCredentials
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getFieldInfo
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * @license GPL-2.0-or-later
4 */
5
6namespace MediaWiki\Extension\OATHAuth\Auth;
7
8use MediaWiki\Auth\AuthenticationRequest;
9use MediaWiki\Language\RawMessage;
10
11/**
12 * AuthManager value object for the Recovery Codes second factor of authentication:
13 * a pre-generated recovery code (aka scratch token) that is created whenever an OATH
14 * user enables at least one form of 2FA (TOTP, WebAuthn, etc.) and is regenerated upon
15 * each successful usage of a recovery code.
16 */
17class RecoveryCodesAuthenticationRequest extends AuthenticationRequest {
18    public string $RecoveryCode;
19
20    /** @inheritDoc */
21    public function describeCredentials() {
22        return [
23            'provider' => wfMessage( 'oathauth-describe-provider' ),
24            'account' => new RawMessage( '$1', [ $this->username ] ),
25        ] + parent::describeCredentials();
26    }
27
28    /** @inheritDoc */
29    public function getFieldInfo() {
30        return [
31            'RecoveryCode' => [
32                'type' => 'string',
33                'label' => wfMessage( 'oathauth-auth-recovery-code-label' ),
34                'help' => wfMessage( 'oathauth-auth-recovery-code-help' ),
35                'optional' => true
36            ]
37        ];
38    }
39}