Skip to content

Commit

Permalink
Fix: Add support for "Extra Options" field
Browse files Browse the repository at this point in the history
Actually the plugin doesn't use the "Extra Options" value. This fix add this feature to the plugin with a tooltip to user knows how to fill this field.
  • Loading branch information
eduardomozart authored Feb 3, 2025
1 parent ead6290 commit 6a2be8e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions inc/provider.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ function showForm($ID, $options = []) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . __sso('Scope') . "</td>";
echo "<td><input type='text' style='width:96%' name='scope' value='" . $this->getScope() . "'></td>";
echo "<td>" . __sso('Extra Options') . "</td>";
echo "<td><input type='text' style='width:96%' name='extra_options' value='" . $this->fields["extra_options"] . "'></td>";
echo "<td>" . __sso('Extra Options');
echo "&nbsp;";
Html::showToolTip(nl2br(__sso('Allows you to specify custom parameters for the SSO provider <strong>Authorize URL</strong>. Example: <code>prompt=login</code> to force login or <code>prompt=select_account</code> to force account selection (supported URL settings may vary by provider). You can specify additional parameters with the "&" delimiter.')));
echo "</td>";
echo "<td><input type='text' style='width:96%' name='extra_options' value='" . $this->fields["extra_options"] . "'>";
echo "</td>";
echo "</tr>\n";

echo "<tr class='tab_bg_1 sso_url' $url_style>";
Expand Down Expand Up @@ -828,6 +832,18 @@ public function getScope() {
return $fields['scope'];
}

public function getExtraOptions() {
if (isset($this->fields['extra_options']) && !empty($this->fields['extra_options'])) {
// e.g. 'response_type=code&approval_prompt=auto'
parse_str($this->fields['extra_options'], $value);
// $value['response_type'] = 'code'
} else {
return false;
}

return $value;
}

public function getAuthorizeUrl() {
$type = $this->getClientType();

Expand Down Expand Up @@ -910,6 +926,10 @@ public function checkAuthorization() {
'approval_prompt' => 'auto',
'redirect_uri' => PluginSinglesignonToolbox::getCurrentURL(),
];
$extra_options = $this->getExtraOptions();
if (is_array($extra_options)) {
$params = array_merge($params, $extra_options);
}

$params = Plugin::doHookFunction("sso:authorize_params", $params);

Expand Down

0 comments on commit 6a2be8e

Please sign in to comment.