Skip to content

Commit

Permalink
Add token based authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
parijke committed Feb 7, 2024
1 parent dc59841 commit bc9c3b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
5 changes: 1 addition & 4 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ [email protected]
jira_test_mode_storage_path='../var/issues.json'

# Jira settings
JIRA_HOST='https://jira.example.com'
# if TOKEN_BASED_AUTH set to true, ignore JIRA_USER and JIRA_PASS.
TOKEN_BASED_AUTH=true
PERSONAL_ACCESS_TOKEN='your-access-token-here'
# The basic authetication settings are supplied via env.j2

# Jira default issue settings
jira_issue_priority=Medium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit bc9c3b3

Please sign in to comment.