Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions oidc/class/oidc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class OIDC extends FOGController
'issuer',
'clientId'
];
/**
* clientId ends in "id" without being a foreign key.
*
* FOGController::save() reads a key ending in "id" as an integer id
* unless the model says otherwise. A client id is a string the provider
* chooses -- "fog-web", or a GUID on Entra -- so without this every
* create failed with "Required database field is empty: clientId" about
* a field that was filled in. Needs fogproject#1153.
*
* @var array
*/
protected $databaseFieldsNotInt = [
'clientId'
];
/**
* Validate before storing.
*
Expand Down
23 changes: 23 additions & 0 deletions tests/oidc-provider-safety.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,29 @@ function () {
);
}

/*
* clientId must stay declared as a string.
*
* FOGController::save() reads any key ending in "id" as an integer foreign
* key unless the model opts out, and clientId is required -- so dropping the
* opt-out does not degrade anything, it makes creating a provider impossible,
* reported as "Required database field is empty: clientId" about a field the
* admin filled in. That is a whole feature off, so it is pinned here rather
* than left to be rediscovered. Needs fogproject#1153.
*/
$declared = [];
if (property_exists('OIDC', 'databaseFieldsNotInt')) {
$notInt = new \ReflectionProperty('OIDC', 'databaseFieldsNotInt');
$notInt->setAccessible(true);
$declared = array_map('strtolower', (array)$notInt->getValue(new OIDC()));
}
if (!in_array('clientid', $declared, true)) {
fail(
'OIDC does not declare clientId in $databaseFieldsNotInt, so '
. 'save() will reject every provider whose client id is not a number'
);
}

if (count($fails) > 0) {
fwrite(STDERR, 'FAIL: ' . count($fails) . " problem(s):\n");
foreach ($fails as $f) {
Expand Down
Loading