Skip to content

Commit f10b605

Browse files
authored
Merge pull request #157 from jadyndev/master
feat: Add support for client certs
2 parents 5781141 + 515048d commit f10b605

File tree

8 files changed

+4424
-4079
lines changed

8 files changed

+4424
-4079
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Requirements
3636
* An already running instance of [Firefly III](https://www.firefly-iii.org/)
3737
* It must be reachable over the network by PHP from the computer you run this import app
3838
* A _Personal Access Token_ which you can generate on the Profile page in Firefly III
39+
* _Optional_ TLS client certificate.
3940

4041

4142
Tips

app/ChooseAccount.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function () {
3535
$bank_accounts = $list_accounts_handler->get_finished_action()->getAccounts();
3636
$firefly_accounts_request = new GetAccountsRequest($session->get('firefly_url'), $session->get('firefly_access_token'));
3737
$firefly_accounts_request->setType(GetAccountsRequest::ASSET);
38+
$firefly_accounts_request->setCert($session->get('firefly_cert'));
3839
$firefly_accounts = $firefly_accounts_request->get();
3940

4041
$requested_bank_index = -1;

app/CollectData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function CollectData()
5353
}
5454
$session->set('firefly_url', $configuration->firefly_url);
5555
$session->set('firefly_access_token', $configuration->firefly_access_token);
56+
$session->set('firefly_cert', $configuration->firefly_cert);
5657
$session->set('skip_transaction_review', $configuration->skip_transaction_review);
5758
$session->set('bank_account_iban' , $configuration->bank_account_iban);
5859
$session->set('firefly_account_id', $configuration->firefly_account_id);

app/ConfigurationFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Configuration {
1313
public $bank_fints_persistence;
1414
public $firefly_url;
1515
public $firefly_access_token;
16+
public $firefly_cert;
1617
public $skip_transaction_review;
1718
public $bank_account_iban;
1819
public $firefly_account_id;
@@ -41,6 +42,7 @@ static function load_from_file($fileName)
4142
}
4243
$configuration->firefly_url = $contentArray["firefly_url"];
4344
$configuration->firefly_access_token = $contentArray["firefly_access_token"];
45+
$configuration->firefly_cert = $contentArray["firefly_cert"];
4446
$configuration->skip_transaction_review = filter_var($contentArray["skip_transaction_review"], FILTER_VALIDATE_BOOLEAN);
4547
if (isset($contentArray["choose_account_automation"])) {
4648
$configuration->bank_account_iban = $contentArray["choose_account_automation"]["bank_account_iban"];

app/RunImportBatched.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function RunImport($transactions)
1616
$transactions,
1717
$session->get('firefly_url'),
1818
$session->get('firefly_access_token'),
19+
$session->get('firefly_cert'),
1920
$session->get('firefly_account'),
2021
$session->get('description_regex_match', ""),
2122
$session->get('description_regex_replace', "")

app/TransactionsToFireflySender.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ class TransactionsToFireflySender
2020
* @param int $firefly_account_id
2121
*/
2222
public function __construct(array $transactions, string $firefly_url, string $firefly_access_token,
23-
int $firefly_account_id,
23+
string|array|null $firefly_cert, int $firefly_account_id,
2424
string $regex_match, string $regex_replace)
2525
{
2626
$this->transactions = $transactions;
2727
$this->firefly_url = $firefly_url;
2828
$this->firefly_access_token = $firefly_access_token;
29+
$this->firefly_cert = $firefly_cert;
2930
$this->firefly_account_id = $firefly_account_id;
3031
$this->regex_match = $regex_match;
3132
$this->regex_replace = $regex_replace;
3233

3334
$firefly_accounts_request = new GetAccountsRequest($this->firefly_url, $this->firefly_access_token);
3435
$firefly_accounts_request->setType(GetAccountsRequest::ASSET);
36+
$firefly_accounts_request->setCert($this->firefly_cert);
3537
$this->firefly_accounts = $firefly_accounts_request->get();
3638
}
3739

@@ -128,6 +130,7 @@ public function send_transactions()
128130
foreach ($this->transactions as $transaction) {
129131
$request = new PostTransactionRequest($this->firefly_url, $this->firefly_access_token);
130132

133+
$request->setCert($this->firefly_cert);
131134
$request->setBody(
132135
self::transform_transaction_to_firefly_request_body($transaction, $this->firefly_account_id, $this->firefly_accounts, $this->regex_match, $this->regex_replace)
133136
);
@@ -150,6 +153,7 @@ public function send_transactions()
150153
private $transactions;
151154
private $firefly_url;
152155
private $firefly_access_token;
156+
private $firefly_cert;
153157
private $firefly_account_id;
154158
private $firefly_accounts;
155159
private $regex_match;

0 commit comments

Comments
 (0)