Skip to content

Commit 28975ff

Browse files
Marcel Grolmsjohannesjo
Marcel Grolms
authored andcommitted
Reimplemented support for Jira Personal Access Tokens (PAT)
Introduced a new option to use Personal Access Tokens (PAT) for Jira authentication. Updated relevant configurations, models, and request headers to support this feature. This enhances security and provides an alternative to basic authentication.
1 parent 07c3222 commit 28975ff

File tree

5 files changed

+197
-10
lines changed

5 files changed

+197
-10
lines changed

electron/jira.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ export const setupRequestHeadersForImages = (jiraCfg: JiraCfg): void => {
9191
// thankfully only the last attached listener will be used
9292
// @see: https://electronjs.org/docs/api/web-request
9393
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
94-
details.requestHeaders.authorization = `Basic ${encoded}`;
94+
if (jiraCfg.usePAT) {
95+
details.requestHeaders.authorization = `Bearer ${jiraCfg.password}`;
96+
} else {
97+
details.requestHeaders.authorization = `Basic ${encoded}`;
98+
}
9599
callback({ requestHeaders: details.requestHeaders });
96100
});
97101
};

package-lock.json

+171-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/features/issue/providers/jira/jira-api.service.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,17 @@ export class JiraApiService {
540540
headers: {
541541
// eslint-disable-next-line @typescript-eslint/naming-convention
542542
'Content-Type': 'application/json',
543-
...{
544-
Cookie: '',
545-
authorization: `Basic ${this._b64EncodeUnicode(
546-
`${cfg.userName}:${cfg.password}`,
547-
)}`,
548-
},
543+
...(cfg.usePAT
544+
? {
545+
Cookie: '',
546+
authorization: `Bearer ${cfg.password}`,
547+
}
548+
: {
549+
Cookie: '',
550+
authorization: `Basic ${this._b64EncodeUnicode(
551+
`${cfg.userName}:${cfg.password}`,
552+
)}`,
553+
}),
549554
},
550555
};
551556
}

src/app/features/issue/providers/jira/jira.const.ts

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const DEFAULT_JIRA_CFG: JiraCfg = {
1414
host: null,
1515
userName: null,
1616
password: null,
17+
usePAT: false,
1718

1819
searchJqlQuery: '',
1920

@@ -196,6 +197,14 @@ export const JIRA_CONFIG_FORM_SECTION: ConfigFormSection<IssueProviderJira> = {
196197
// label: T.F.JIRA.FORM_CRED.ALLOW_SELF_SIGNED,
197198
// },
198199
// },
200+
{
201+
key: 'usePAT',
202+
type: 'checkbox',
203+
templateOptions: {
204+
required: false,
205+
label: T.F.JIRA.FORM_CRED.USE_PAT,
206+
},
207+
},
199208

200209
...ISSUE_PROVIDER_COMMON_FORM_FIELDS,
201210

src/app/features/issue/providers/jira/jira.model.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface JiraCfg extends BaseIssueProviderCfg {
2222
host: string | null;
2323
userName: string | null;
2424
password?: string | null;
25+
usePAT: boolean;
2526

2627
isAllowSelfSignedCertificate: boolean;
2728
searchJqlQuery: string;

0 commit comments

Comments
 (0)