瀏覽代碼

Fixed when use proxy

Edgard 6 年之前
父節點
當前提交
702c400f0d
共有 2 個文件被更改,包括 18 次插入9 次删除
  1. 1 9
      front/callback.php
  2. 17 0
      inc/provider.class.php

+ 1 - 9
front/callback.php

@@ -21,15 +21,7 @@ if (!$signon_provider->fields['is_active']) {
    Html::displayErrorAndDie(__sso("Provider not active."), true);
 }
 
-$httpClient = new GuzzleHttp\Client([
-   'verify' => false,
-      ]);
-
-$collaborators = [
-   'httpClient' => $httpClient,
-];
-
-$signon_provider->prepareProviderInstance([], $collaborators);
+$signon_provider->prepareProviderInstance();
 
 $signon_provider->checkAuthorization();
 

+ 17 - 0
inc/provider.class.php

@@ -544,11 +544,28 @@ class PluginSinglesignonProvider extends CommonDBTM {
     * @return \League\OAuth2\Client\Provider\AbstractProvider
     */
    public static function createInstance($type = 'generic', array $options = [], array $collaborators = []) {
+      global $CFG_GLPI;
 
       if (!isset($options['scope'])) {
          $options['scope'] = [];
       }
 
+      $clientOptions = ['verify' => false];
+
+      if (!empty($CFG_GLPI["proxy_name"])) {
+         $clientOptions['proxy'] = $CFG_GLPI["proxy_name"] . ":" . $CFG_GLPI["proxy_port"];
+
+         if (!empty($CFG_GLPI["proxy_user"])) {
+            $clientOptions['proxy'] = $CFG_GLPI["proxy_user"] . ":" .
+                  Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY) .
+                  "@" . $clientOptions['proxy'];
+         }
+      }
+
+      $httpClient = new GuzzleHttp\Client($clientOptions);
+
+      $collaborators['httpClient'] = $httpClient;
+
       switch ($type) {
          case 'facebook':
             if (!isset($options['graphApiVersion'])) {