Skip to content

Commit 6015aed

Browse files
authored
Merge pull request grokability#17209 from Godmartinz/saml_xml_update_bug
Fixed grokability#17089: SAML metadata now updating with new XML uploads
2 parents 7b04e30 + 8199cd2 commit 6015aed

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

app/Http/Controllers/SettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ public function getSamlSettings() : View
924924
* @since v5.0.0
925925
*/
926926
public function postSamlSettings(SettingsSamlRequest $request) : RedirectResponse
927-
{
927+
{
928928
if (is_null($setting = Setting::getSettings())) {
929929
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
930930
}

app/Http/Requests/SettingsSamlRequest.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function rules()
4141
public function withValidator($validator)
4242
{
4343
$validator->after(function ($validator) {
44+
$setting = Setting::getSettings();
4445
if ($this->input('saml_enabled') == '1') {
4546
$idpMetadata = $this->input('saml_idp_metadata');
4647
if (! empty($idpMetadata)) {
@@ -56,7 +57,7 @@ public function withValidator($validator)
5657
}
5758
}
5859

59-
$was_custom_x509cert = strpos(Setting::getSettings()->saml_custom_settings, 'sp_x509cert') !== false;
60+
$was_custom_x509cert = strpos($setting->saml_custom_settings, 'sp_x509cert') !== false;
6061

6162
$custom_x509cert = '';
6263
$custom_privateKey = '';
@@ -126,10 +127,14 @@ public function withValidator($validator)
126127
}
127128

128129
if (! (empty($x509cert) && empty($privateKey))) {
129-
$this->merge([
130-
'saml_sp_x509cert' => $x509cert,
131-
'saml_sp_privatekey' => $privateKey,
132-
]);
130+
// $this->merge([
131+
// 'saml_sp_x509cert' => $x509cert,
132+
// 'saml_sp_privatekey' => $privateKey,
133+
// ]);
134+
$setting->saml_sp_x509cert = $x509cert;
135+
$setting->saml_sp_privatekey = $privateKey;
136+
$setting->save();
137+
133138
}
134139
} else {
135140
$validator->errors()->add('saml_integration', 'openssl.cnf is missing/invalid');
@@ -145,15 +150,21 @@ public function withValidator($validator)
145150
}
146151

147152
if (! empty($x509certNew)) {
148-
$this->merge([
149-
'saml_sp_x509certNew' => $x509certNew,
150-
]);
153+
// $this->merge([
154+
// 'saml_sp_x509certNew' => $x509certNew,
155+
// ]);
156+
$setting->saml_sp_x509certNew = $x509certNew;
157+
$setting->save();
151158
}
152159
} else {
153-
$this->merge([
154-
'saml_sp_x509certNew' => '',
155-
]);
160+
// $this->merge([
161+
// 'saml_sp_x509certNew' => '',
162+
// ]);
163+
$setting->saml_sp_x509certNew = '';
164+
$setting->save();
156165
}
166+
167+
157168
});
158169
}
159170
}

resources/views/settings/saml.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<label for="saml_sp_x509cert">{{ trans('admin/settings/general.saml_sp_x509cert') }}</label>
8686
<x-input.textarea
8787
name="saml_sp_x509cert"
88+
id="saml_sp_x509cert"
8889
:value="$setting->saml_sp_x509cert"
8990
wrap="off"
9091
readonly
@@ -113,6 +114,7 @@
113114
<div class="col-md-9">
114115
<x-input.textarea
115116
name="saml_idp_metadata"
117+
id="saml_idp_metadata"
116118
:value="old('saml_idp_metadata', $setting->saml_idp_metadata)"
117119
placeholder="https://example.com/idp/metadata"
118120
wrap="off"
@@ -218,7 +220,7 @@
218220
var fr = new FileReader();
219221
220222
fr.onload = function(e) {
221-
$('#saml_idp_metadata').text(e.target.result);
223+
$('#saml_idp_metadata').val(e.target.result);
222224
}
223225
224226
fr.readAsText(this.files[0]);

0 commit comments

Comments
 (0)