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
![]() |
|||
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
|
|||
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 |