diff --git a/Keycloak.php b/Keycloak.php index 624970d..01e59bc 100644 --- a/Keycloak.php +++ b/Keycloak.php @@ -40,7 +40,14 @@ public function getEndpoint(string $endpoint) { if (!isset($this->discovery)) { $plugin = plugin_load('helper', 'oauthkeycloak'); - $json = file_get_contents($plugin->getConf('openidurl')); + + $context = stream_context_create([ + 'ssl' => [ + 'verify_peer' => $plugin->getConf('verify-peer') + ] + ]); + $json = file_get_contents($plugin->getConf('openidurl'), false, $context); + if (!$json) throw new \Exception('Failed accessing ' . $plugin->getConf('openidurl')); $this->discovery = json_decode($json, true); } diff --git a/conf/default.php b/conf/default.php index b4b5185..6a0d594 100644 --- a/conf/default.php +++ b/conf/default.php @@ -8,6 +8,7 @@ $conf['secret'] = ''; $conf['openidurl'] = ''; +$conf['verify-peer'] = 1; $conf['label'] = 'Keycloak'; $conf['color'] = '#333333'; diff --git a/conf/metadata.php b/conf/metadata.php index f94d3e3..a945fc2 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -8,6 +8,7 @@ $meta['secret'] = array('password'); $meta['openidurl'] = array('string'); +$meta['verify-peer'] = array('onoff','_caution' => 'security'); $meta['label'] = array('string'); $meta['color'] = array('string'); diff --git a/lang/en/settings.php b/lang/en/settings.php index 8b9419b..da624f8 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -9,6 +9,7 @@ $lang['key'] = 'Client ID'; $lang['secret'] = 'Cient Secret'; $lang['openidurl'] = 'OpenID Connect Auto Discovery URL'; +$lang['verify-peer'] = 'Verification of SSL certificate is required.'; $lang['label'] = 'Label to display on the login button'; $lang['color'] = 'Color to use with the login button';