Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira API Communication Add Proxy #136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions application/forms/Config/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ protected function assemble()
'label' => $this->translate('Scheme'),
'description' => $this->translate('Protocol used by Jira (http / https)'),
]
)->addElement(
'text',
'proxy',
[
'label' => $this->translate('Proxy Server'),
'description' => $this->translate(
'Proxy Server used to connect to Jira if needed, '
. 'format <hostname or IP>:<port>'
),
'required' => false,
]
);

$this->addElement(
Expand Down
11 changes: 9 additions & 2 deletions library/Jira/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@

protected $enumCustomFields;

public function __construct($baseUrl, $username, $password)
protected $proxy;

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

public function __construct($baseUrl, $username, $password, $proxy)

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.
{
$this->username = $username;
$this->password = $password;
$this->baseUrlForLink = $baseUrl;
$this->baseUrl = \rtrim($baseUrl, '/') . '/rest';
$this->proxy = $proxy;
$this->serverInfo = $this->get('serverInfo')->getResult();
}

Expand All @@ -62,7 +65,7 @@
$user = $config->get('api', 'username');
$pass = $config->get('api', 'password');

$api = new static($url, $user, $pass);
$api = new static($url, $user, $pass, $proxy);

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Undefined variable: $proxy

return $api;
}
Expand Down Expand Up @@ -448,6 +451,10 @@
CURLOPT_SSL_VERIFYPEER => false,
);

if ($this->proxy) {
$opts[CURLOPT_PROXY] = $this->proxy;
}

curl_setopt_array($curl, $opts);
// TODO: request headers, validate status code

Expand Down