ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilShibbolethSettings.php
Go to the documentation of this file.
1 <?php
2 
9 {
13  private const PREFIX = 'shib_';
17  private const DEFAULT_IDP_LIST = "urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai";
21  private const DEFAULT_LOGIN_BUTTON = "assets/images/auth/shib_login_button.svg";
25  private const DEFAULT_ORGANISATION_SELECTION = "external_wayf";
26 
27  public const ACCOUNT_CREATION_ENABLED = "enabled";
28  public const ACCOUNT_CREATION_WITH_APPROVAL = "with_approval";
29  public const ACCOUNT_CREATION_DISABLED = "disabled";
30 
31  protected ilSetting $settings;
32  protected array $data = [];
33 
35  protected array $user_fields = [
36  'firstname' => true,
37  'lastname' => true,
38  'email' => true,
39  'title' => false,
40  'gender' => false,
41  'institution' => false,
42  'department' => false,
43  'zipcode' => false,
44  'city' => false,
45  'country' => false,
46  'street' => false,
47  'phone_office' => false,
48  'phone_home' => false,
49  'phone_mobile' => false,
50  'language' => false,
51  'matriculation' => false,
52  ];
53 
54  public function __construct()
55  {
56  global $DIC;
57 
58  $this->settings = $DIC->settings();
59  $this->read();
60  }
61 
65  public function getUserFields(): array
66  {
67  return $this->user_fields;
68  }
69 
70  public function read(): void
71  {
72  $filtered_data = array_filter(
73  $this->settings->getAll(),
74  static fn($value, string $key): bool => str_starts_with($key, self::PREFIX),
75  ARRAY_FILTER_USE_BOTH
76  );
77 
78  array_walk($filtered_data, function ($v, string $k): void {
79  $this->data[str_replace(self::PREFIX, '', $k)] = $v === '' ? null : $v;
80  });
81  }
82 
83  public function get(string $a_keyword, ?string $a_default_value = null): string
84  {
85  $a_keyword = str_replace(self::PREFIX, '', $a_keyword);
86 
87  return (string) ($this->data[$a_keyword] ?? $a_default_value);
88  }
89 
90  public function getAll(): array
91  {
92  return $this->data;
93  }
94 
95  public function set(string $a_key, string $a_val): void
96  {
97  $a_key = str_replace(self::PREFIX, '', $a_key);
98  $this->data[$a_key] = $a_val;
99  }
100 
101  public function store(): void
102  {
103  foreach ($this->data as $key => $value) {
104  $this->settings->set(self::PREFIX . $key, (string) $value);
105  }
106  }
107 
108  public function getDefaultRole(): int
109  {
110  return $this->data['user_default_role'] ?? 4;
111  }
112 
113  public function setDefaultRole(int $role_id): void
114  {
115  $this->data['user_default_role'] = $role_id;
116  }
117 
118  public function getIdPList(): string
119  {
120  return $this->data['idp_list'] ?? self::DEFAULT_IDP_LIST;
121  }
122 
123  public function setIdPList(string $list): void
124  {
125  $this->data['idp_list'] = $list;
126  }
127 
128  public function getLoginButton(): string
129  {
130  return $this->data['login_button'] ?? self::DEFAULT_LOGIN_BUTTON;
131  }
132 
133  public function setLoginButton(string $login_button): void
134  {
135  $this->data['login_button'] = $login_button;
136  }
137 
138  public function getOrganisationSelectionType(): string
139  {
140  return $this->data['hos_type'] ?? self::DEFAULT_ORGANISATION_SELECTION;
141  }
142 
143  public function setOrganisationSelectionType(string $type): void
144  {
145  $this->data['hos_type'] = $type;
146  }
147 
148  public function isActive(): bool
149  {
150  return (bool) ($this->data['active'] ?? false);
151  }
152 
153  public function setActive(bool $status): void
154  {
155  $this->data['active'] = $status;
156  }
157 
158  public function isLocalAuthAllowed(): bool
159  {
160  return (bool) ($this->data['auth_allow_local'] ?? false);
161  }
162 
163  public function setAllowLocalAuth(bool $status): void
164  {
165  $this->data['auth_allow_local'] = $status;
166  }
167 
168  public function getAccountCreation(): string
169  {
170  return $this->data['account_creation'] ?? self::ACCOUNT_CREATION_ENABLED;
171  }
172 
173  public function setAccountCreation(string $value): void
174  {
175  $this->data['account_creation'] = $value;
176  }
177 
178  public function getFederationName(): string
179  {
180  return ($this->data['federation_name'] ?? '');
181  }
182 
183  public function setFederationName(string $federation): void
184  {
185  $this->data['federation_name'] = $federation;
186  }
187 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setFederationName(string $federation)
global $DIC
Definition: shib_login.php:22
setLoginButton(string $login_button)
Class ilShibbolethSettings.