Skip to content

Commit 924caed

Browse files
committed
Fix get* config methods
1 parent 4128151 commit 924caed

5 files changed

Lines changed: 39 additions & 39 deletions

File tree

lib/Auth/Process/AttributeAddFromLDAP.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ public function __construct(array $config, $reserved)
7575
parent::__construct($config, $reserved);
7676

7777
// Get filter specific config options
78-
$this->binary_attributes = $this->config->getArray('attributes.binary', []);
79-
$this->search_attributes = $this->config->getArrayize('attributes', []);
78+
$this->binary_attributes = $this->config->getOptionalArray('attributes.binary', []);
79+
$this->search_attributes = $this->config->getOptionalArrayize('attributes', []);
8080
if (empty($this->search_attributes)) {
81-
$new_attribute = $this->config->getString('attribute.new', '');
81+
$new_attribute = $this->config->getOptionalString('attribute.new', '');
8282
$this->search_attributes[$new_attribute] = $this->config->getString('search.attribute');
8383
}
8484
$this->search_filter = $this->config->getString('search.filter');
8585

8686
// get the attribute policy
87-
$this->attr_policy = $this->config->getString('attribute.policy', 'merge');
87+
$this->attr_policy = $this->config->getOptionalString('attribute.policy', 'merge');
8888
}
8989

9090

lib/Auth/Process/AttributeAddUsersGroups.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public function process(array &$request): void
5151
$this->title . 'Attempting to get the users groups...'
5252
);
5353

54-
$this->additional_filters = $this->config->getArray('additional_filters', []);
55-
$this->escape = $this->config->getBoolean('escape', true);
54+
$this->additional_filters = $this->config->getOptionalArray('additional_filters', []);
55+
$this->escape = $this->config->getOptionalBoolean('escape', true);
5656

5757
// Reference the attributes, just to make the names shorter
5858
$attributes = &$request['Attributes'];
@@ -176,7 +176,7 @@ protected function getGroupsOpenLdap(array $attributes): array
176176
$map = &$this->attribute_map;
177177

178178
// Print group search string and search for all group names
179-
$openldap_base = $this->config->getString('ldap.basedn', 'ou=groups,dc=example,dc=com');
179+
$openldap_base = $this->config->getOptionalString('ldap.basedn', 'ou=groups,dc=example,dc=com');
180180
Logger::debug(
181181
$this->title . "Searching for groups in ldap.basedn " . $openldap_base . " with filter (" .
182182
$map['memberof'] . "=" . $attributes[$map['username']][0] . ") and attributes " . $map['member']

lib/Auth/Process/BaseFilter.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ public function __construct(array &$config, $reserved)
204204
$this->config = \SimpleSAML\Configuration::loadFromArray($config, 'ldap:AuthProcess');
205205

206206
// Set all the filter values, setting defaults if needed
207-
$this->base_dn = $this->config->getArrayizeString('ldap.basedn', '');
208-
$this->product = $this->config->getString('ldap.product', '');
207+
$this->base_dn = $this->config->getOptionalArrayizeString('ldap.basedn', '');
208+
$this->product = $this->config->getOptionalString('ldap.product', '');
209209

210210
// Cleanup the directory service, so that it is easier for
211211
// child classes to determine service name consistently
@@ -221,14 +221,14 @@ public function __construct(array &$config, $reserved)
221221

222222
// Setup the attribute map which will be used to search LDAP
223223
$this->attribute_map = [
224-
'dn' => $this->config->getString('attribute.dn', 'distinguishedName'),
225-
'groups' => $this->config->getString('attribute.groups', 'groups'),
226-
'member' => $this->config->getString('attribute.member', 'member'),
227-
'memberof' => $this->config->getString('attribute.memberof', 'memberOf'),
228-
'name' => $this->config->getString('attribute.groupname', 'name'),
229-
'return' => $this->config->getString('attribute.return', 'distinguishedName'),
230-
'type' => $this->config->getString('attribute.type', 'objectClass'),
231-
'username' => $this->config->getString('attribute.username', 'sAMAccountName')
224+
'dn' => $this->config->getOptionalString('attribute.dn', 'distinguishedName'),
225+
'groups' => $this->config->getOptionalString('attribute.groups', 'groups'),
226+
'member' => $this->config->getOptionalString('attribute.member', 'member'),
227+
'memberof' => $this->config->getOptionalString('attribute.memberof', 'memberOf'),
228+
'name' => $this->config->getOptionalString('attribute.groupname', 'name'),
229+
'return' => $this->config->getOptionalString('attribute.return', 'distinguishedName'),
230+
'type' => $this->config->getOptionalString('attribute.type', 'objectClass'),
231+
'username' => $this->config->getOptionalString('attribute.username', 'sAMAccountName')
232232
];
233233

234234
// Log the attribute map
@@ -238,8 +238,8 @@ public function __construct(array &$config, $reserved)
238238

239239
// Setup the object type map which is used to determine a DNs' type
240240
$this->type_map = [
241-
'group' => $this->config->getString('type.group', 'group'),
242-
'user' => $this->config->getString('type.user', 'user')
241+
'group' => $this->config->getOptionalString('type.group', 'group'),
242+
'user' => $this->config->getOptionalString('type.user', 'user')
243243
];
244244

245245
// Log the type map
@@ -265,13 +265,13 @@ protected function getLdap(): Ldap
265265

266266
// Get the connection specific options
267267
$hostname = $this->config->getString('ldap.hostname');
268-
$port = $this->config->getInteger('ldap.port', 389);
269-
$enable_tls = $this->config->getBoolean('ldap.enable_tls', false);
270-
$debug = $this->config->getBoolean('ldap.debug', false);
271-
$referrals = $this->config->getBoolean('ldap.referrals', true);
272-
$timeout = $this->config->getInteger('ldap.timeout', 0);
273-
$username = $this->config->getString('ldap.username', null);
274-
$password = $this->config->getString('ldap.password', null);
268+
$port = $this->config->getOptionalInteger('ldap.port', 389);
269+
$enable_tls = $this->config->getOptionalBoolean('ldap.enable_tls', false);
270+
$debug = $this->config->getOptionalBoolean('ldap.debug', false);
271+
$referrals = $this->config->getOptionalBoolean('ldap.referrals', true);
272+
$timeout = $this->config->getOptionalInteger('ldap.timeout', 0);
273+
$username = $this->config->getOptionalString('ldap.username', null);
274+
$password = $this->config->getOptionalString('ldap.password', null);
275275

276276
// Log the LDAP connection
277277
\SimpleSAML\Logger::debug(

lib/Auth/Source/LdapMulti.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(array $info, array $config)
6767
}
6868

6969
if ($name === 'include_organization_in_username') {
70-
$this->includeOrgInUsername = $cfgHelper->getBoolean(
70+
$this->includeOrgInUsername = $cfgHelper->getOptionalBoolean(
7171
'include_organization_in_username',
7272
false
7373
);

lib/ConfigHelper.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,23 @@ public function __construct(array $config, string $location)
140140
$config = Configuration::loadFromArray($config, $location);
141141

142142
$this->hostname = $config->getString('hostname');
143-
$this->enableTLS = $config->getBoolean('enable_tls', false);
144-
$this->debug = $config->getBoolean('debug', false);
145-
$this->timeout = $config->getInteger('timeout', 0);
146-
$this->port = $config->getInteger('port', 389);
147-
$this->referrals = $config->getBoolean('referrals', true);
148-
$this->searchEnable = $config->getBoolean('search.enable', false);
149-
$this->privRead = $config->getBoolean('priv.read', false);
143+
$this->enableTLS = $config->getOptionalBoolean('enable_tls', false);
144+
$this->debug = $config->getOptionalBoolean('debug', false);
145+
$this->timeout = $config->getOptionalInteger('timeout', 0);
146+
$this->port = $config->getOptionalInteger('port', 389);
147+
$this->referrals = $config->getOptionalBoolean('referrals', true);
148+
$this->searchEnable = $config->getOptionalBoolean('search.enable', false);
149+
$this->privRead = $config->getOptionalBoolean('priv.read', false);
150150

151151
if ($this->searchEnable) {
152-
$this->searchUsername = $config->getString('search.username', null);
152+
$this->searchUsername = $config->getOptionalString('search.username', null);
153153
if ($this->searchUsername !== null) {
154154
$this->searchPassword = $config->getString('search.password');
155155
}
156156

157157
$this->searchBase = $config->getArrayizeString('search.base');
158-
$this->searchScope = $config->getString('search.scope', 'subtree');
159-
$this->searchFilter = $config->getString('search.filter', null);
158+
$this->searchScope = $config->getOptionalString('search.scope', 'subtree');
159+
$this->searchFilter = $config->getOptionalString('search.filter', null);
160160
$this->searchAttributes = $config->getArray('search.attributes');
161161
} else {
162162
$this->dnPattern = $config->getString('dnpattern');
@@ -168,8 +168,8 @@ public function __construct(array $config, string $location)
168168
$this->privPassword = $config->getString('priv.password');
169169
}
170170

171-
$this->attributes = $config->getArray('attributes', null);
172-
$this->binaryAttributes = $config->getArray('attributes.binary', []);
171+
$this->attributes = $config->getOptionalArray('attributes', null);
172+
$this->binaryAttributes = $config->getOptionalArray('attributes.binary', []);
173173
}
174174

175175

0 commit comments

Comments
 (0)