File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -363,10 +363,18 @@ public function validate_form($form, &$err) {
363
363
* @param object $config
364
364
*/
365
365
public function process_config ($ config ) {
366
+ $ haschanged = false ;
367
+
366
368
foreach ($ this ->defaults as $ key => $ value ) {
367
- set_config ($ key , $ config ->$ key , 'auth_saml2 ' );
369
+ if ($ config ->$ key != $ this ->config ->$ key ) {
370
+ set_config ($ key , $ config ->$ key , 'auth_saml2 ' );
371
+ $ haschanged = true ;
372
+ }
368
373
}
369
- return true ;
374
+
375
+ if ($ haschanged ) {
376
+ $ file = $ this ->certdir . $ this ->spname . '.xml ' ;
377
+ @unlink ($ file );
370
378
}
371
379
372
380
/**
Original file line number Diff line number Diff line change @@ -35,9 +35,16 @@ function auth_saml2_get_sp_metadata() {
35
35
36
36
global $ saml2auth , $ CFG ;
37
37
38
- $ auth = new SimpleSAML_Auth_Simple ($ saml2auth ->spname );
39
- $ config = SimpleSAML_Configuration::getInstance ();
40
38
$ sourceId = $ saml2auth ->spname ;
39
+
40
+ $ file = $ saml2auth ->certdir . $ saml2auth ->spname . '.xml ' ;
41
+ if (file_exists ($ file )) {
42
+ $ xml = file_get_contents ($ file );
43
+ return $ xml ;
44
+ }
45
+
46
+ $ auth = new SimpleSAML_Auth_Simple ($ sourceId );
47
+ $ config = SimpleSAML_Configuration::getInstance ();
41
48
$ source = SimpleSAML_Auth_Source::getById ($ sourceId );
42
49
if ($ source === NULL ) {
43
50
throw new SimpleSAML_Error_NotFound ('Could not find authentication source with id ' . $ sourceId );
@@ -265,6 +272,9 @@ function auth_saml2_get_sp_metadata() {
265
272
/* Sign the metadata if enabled. */
266
273
$ xml = SimpleSAML_Metadata_Signer::sign ($ xml , $ spconfig ->toArray (), 'SAML 2 SP ' );
267
274
275
+ // Store the file so it is exactly the same next time.
276
+ file_put_contents ($ file , $ xml );
277
+
268
278
return $ xml ;
269
279
}
270
280
Original file line number Diff line number Diff line change 54
54
$ saml2auth = new auth_plugin_saml2 ();
55
55
$ error = create_certificates ($ saml2auth , $ dn , $ numberofdays );
56
56
57
+ // Also refresh the SP metadata as well.
58
+ $ file = $ saml2auth ->certdir . $ saml2auth ->spname . '.xml ' ;
59
+ @unlink ($ file );
60
+
57
61
if (empty ($ error )) {
58
62
redirect ("$ CFG ->wwwroot /admin/auth_config.php?auth=saml2 " );
59
63
}
You can’t perform that action at this time.
0 commit comments