SAMLMemberExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 4 1
1
<?php
2
3
namespace SilverStripe\SAML\Extensions;
4
5
use SilverStripe\Forms\FieldList;
6
use SilverStripe\Forms\ReadonlyField;
7
use SilverStripe\ORM\DataExtension;
8
9
/**
10
 * Class SAMLMemberExtension
11
 *
12
 * Adds mappings from IdP claim rules to SilverStripe {@link Member} fields.
13
 *
14
 * @package activedirectory
15
 */
16
class SAMLMemberExtension extends DataExtension
17
{
18
    /**
19
     * @var array
20
     */
21
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
22
        // Pointer to the session object held by the IdP
23
        'SAMLSessionIndex' => 'Varchar(255)',
24
        // Unique user identifier, same field is used by LDAPMemberExtension
25
        'GUID' => 'Varchar(50)',
26
    ];
27
28
    /**
29
     * These are used by {@link SAMLController} to map specific IdP claim rules
30
     * to {@link Member} fields. Availability of these claim rules are defined
31
     * on the IdP.
32
     *
33
     * @var array
34
     * @config
35
     */
36
    private static $claims_field_mappings = [
0 ignored issues
show
introduced by
The private property $claims_field_mappings is not used, and could be removed.
Loading history...
37
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname' => 'FirstName',
38
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname' => 'Surname',
39
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' => 'Email'
40
    ];
41
42
    /**
43
     * @param FieldList $fields
44
     */
45
    public function updateCMSFields(FieldList $fields)
46
    {
47
        $fields->replaceField('GUID', ReadonlyField::create('GUID'));
48
        $fields->removeFieldFromTab('Root', 'SAMLSessionIndex');
49
    }
50
}
51