Skip to content

Commit

Permalink
Add configurable workgroup api timeout and increase it (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Apr 22, 2024
1 parent 2eaa5d0 commit 82c2098
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/install/stanford_samlauth.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ role_mapping:
workgroup_api:
cert: ''
key: ''
timeout: 30
mapping: {}
3 changes: 3 additions & 0 deletions config/schema/stanford_samlauth.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ stanford_samlauth.settings:
key:
type: string
label: Path to Workgroup API Key file
timeout:
type: integer
label: API Request timeout limit
reevaluate:
type: string
label: Reevaluation rule
Expand Down
3 changes: 2 additions & 1 deletion src/Service/WorkgroupApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ public function isSunetValid(string $sunet): bool {
* API response or false if fails.
*/
protected function callApi(string $workgroup = NULL, string $sunet = NULL): ?array {
$config = $this->configFactory->get('stanford_samlauth.settings');
$options = [
'cert' => $this->getCert(),
'ssl_key' => $this->getKey(),
'verify' => TRUE,
'timeout' => 5,
'timeout' => $config->get('role_mapping.workgroup_api.timeout') ?: 30,
'query' => [
'type' => $workgroup ? 'workgroup' : 'user',
'id' => $workgroup ?: $sunet,
Expand Down
10 changes: 10 additions & 0 deletions stanford_samlauth.install
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ function stanford_samlauth_install() {
->set('match_noredirect_pages', "/jsonapi\r\n/jsonapi/*\r\n/subrequests")
->save();
}

/**
* Add request timeout config value.
*/
function stanford_samlauth_update_1001() {
\Drupal::configFactory()
->getEditable('stanford_samlauth.settings')
->set('role_mapping.workgroup_api.timeout', 30)
->save();
}

0 comments on commit 82c2098

Please sign in to comment.