From 6acbb206e03d10a318fc9d81a8137cf686dc2efb Mon Sep 17 00:00:00 2001 From: Paul Rijke Date: Tue, 13 Feb 2024 09:59:06 +0100 Subject: [PATCH] Add default to dist file (#621) Add token based authentication The login of Jira changes from basic auth to token login. This change implements this change. --- .env.dist | 5 ++--- .../DashboardBundle/Resources/config/services.yml | 3 +-- .../Jira/Factory/JiraServiceFactory.php | 14 +++++--------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.env.dist b/.env.dist index ef060141c..21086a24f 100644 --- a/.env.dist +++ b/.env.dist @@ -101,9 +101,8 @@ mail_no_reply=no-reply@surfconext.nl jira_test_mode_storage_path='../var/issues.json' # Jira settings -JIRA_HOST='https://jira.example.com' -JIRA_USER=sp-dashboard -JIRA_PASS=secret +jira_host='https://your_jira_host.nl' +jira_personal_access_token='your_jira_personal_access_token' # Jira default issue settings jira_issue_priority=Medium diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml index 84b7a5936..391b95bdf 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml @@ -555,8 +555,7 @@ services: Surfnet\ServiceProviderDashboard\Infrastructure\Jira\Factory\JiraServiceFactory: arguments: - '%env(jira_host)%' - - '%env(jira_username)%' - - '%env(jira_password)%' + - '%env(jira_personal_access_token)%' - '@logger' Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Form\Entity\AclListType: diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Jira/Factory/JiraServiceFactory.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Jira/Factory/JiraServiceFactory.php index 439f4bb5e..2573ab75c 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Jira/Factory/JiraServiceFactory.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Jira/Factory/JiraServiceFactory.php @@ -24,26 +24,22 @@ class JiraServiceFactory { - /** - * @var ArrayConfiguration - */ - private $config; + private ArrayConfiguration $config; public function __construct( string $host, - string $username, - string $password, + string $personalAccessToken, private readonly LoggerInterface $logger ) { // Create a IssueService with a Jira connection built in. $this->config = new ArrayConfiguration([ 'jiraHost' => $host, - 'jiraUser' => $username, - 'jiraPassword' => $password + 'useTokenBasedAuth' => true, + 'personalAccessToken' => $personalAccessToken, ]); } - public function buildIssueService() + public function buildIssueService(): IssueService { return new IssueService($this->config, $this->logger); }