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