Skip to content

Commit 3997fe6

Browse files
author
Sander Ronde
committed
Bring back password & cookie settings but don't recommend them
1 parent d7b6db4 commit 3997fe6

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ To set up the extension, you'll need to set up authentication. This can be done
1010

1111
- `gerrit.auth.username` - This is your username on gerrit. You can find this next to the `Username` field under "HTTP Credentials".
1212
- `gerrit.auth.url` - This is automatically inferred from your `.gitreview` file (if you have one). If you don't have one or it doesn't work, set this URL to the HTTP URL of your gerrit instance. This will be the URL your visit in the browser.
13-
- `gerrit.auth.password` (encrypted secret) - This is your HTTP password. You can generate one by clicking "Generate new password" on Gerrit and copying it.
14-
- `gerrit.auth.extraCookies` (encrypted secret) - This is your authentication cookie. Use this if your administrator has disabled the use of HTTP credentials. You can find it by going to gerrit in your browser, opening the developer tools, and finding the value of the cookie named `GerritAccount`.
13+
- `gerrit.auth.password` - Your HTTP password (stored as an encrypted secret when entered via the command). You can generate one by clicking "Generate new password" on Gerrit and copying it.
14+
- Authentication cookie - Use this if your administrator has disabled HTTP credentials. Enter it via the command (stored securely) or set `gerrit.auth.cookie` in settings. You can find it by going to gerrit in your browser, opening the developer tools, and copying the value of the cookie named `GerritAccount`.
15+
- `gerrit.auth.extraCookies` - Other cookies besides the authentication cookie to send on every request.
16+
17+
You can also set `gerrit.auth.password` and `gerrit.auth.cookie` in settings; these are not recommended because they are stored in plain text. Prefer "Gerrit: Enter credentials" for secure storage. Using the settings is still supported for cases like devcontainers.
1518

1619
Additionally the extension requires the python package [git-review](https://pypi.org/project/git-review/) to be installed.
1720

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,16 @@
10371037
"title": "Gerrit username",
10381038
"description": "Gerrit login username"
10391039
},
1040+
"gerrit.auth.password": {
1041+
"type": "string",
1042+
"title": "Gerrit HTTP password",
1043+
"description": "Not recommended: stored in plain text in settings. Prefer the command \"Gerrit: Enter credentials\" so the password is stored securely. This setting is still supported for scenarios where the command is not practical (e.g. devcontainers)."
1044+
},
1045+
"gerrit.auth.cookie": {
1046+
"type": "string",
1047+
"title": "Gerrit access token (or authentication cookie)",
1048+
"description": "Not recommended: stored in plain text in settings. Prefer the command \"Gerrit: Enter credentials\" so the value is stored securely. This can be the access token from Gerrit Settings → HTTP Credentials or the GerritAccount cookie. This setting is still supported for scenarios where the command is not practical (e.g. devcontainers)."
1049+
},
10401050
"gerrit.extraCookies": {
10411051
"type": "object",
10421052
"title": "Extra Gerrit cookies",

src/commands/defs.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,22 @@ export const config = {
745745
description: 'Gerrit login username',
746746
},
747747
},
748+
'gerrit.auth.password': {
749+
jsonDefinition: {
750+
type: 'string',
751+
title: 'Gerrit HTTP password',
752+
description:
753+
'Not recommended: stored in plain text in settings. Prefer the command "Gerrit: Enter credentials" so the password is stored securely. This setting is still supported for scenarios where the command is not practical (e.g. devcontainers).',
754+
},
755+
},
756+
'gerrit.auth.cookie': {
757+
jsonDefinition: {
758+
type: 'string',
759+
title: 'Gerrit access token (or authentication cookie)',
760+
description:
761+
'Not recommended: stored in plain text in settings. Prefer the command "Gerrit: Enter credentials" so the value is stored securely. This can be the access token from Gerrit Settings → HTTP Credentials or the GerritAccount cookie. This setting is still supported for scenarios where the command is not practical (e.g. devcontainers).',
762+
},
763+
},
748764
'gerrit.extraCookies': {
749765
jsonDefinition: {
750766
type: 'object',

src/lib/credentials/enterCredentials.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ async function enterCookieCredentials(gerritRepo: Repository): Promise<void> {
268268
const cookieStep = new MultiStepEntry({
269269
placeHolder: '34-char-long alphanumeric string',
270270
prompt: (stepper) =>
271-
`Enter your Gerrit authentication cookie (go to ${
271+
`Enter your Gerrit access token (or the GerritAccount cookie value: go to ${
272272
stepper.values[0] ?? 'www.yourgerrithost.com'
273-
} and copy the value of the GerritAccount cookie)`,
273+
} and copy the GerritAccount cookie from your browser)`,
274274
value: async (stepper) =>
275275
(await GerritSecrets.getForUrlOrWorkspace(
276276
'cookie',
@@ -312,7 +312,8 @@ async function enterCookieCredentials(gerritRepo: Repository): Promise<void> {
312312
} else if (!(await connection.authenticated)) {
313313
return {
314314
isValid: false,
315-
message: 'Authentication failed, invalid cookie,',
315+
message:
316+
'Authentication failed, invalid access token or cookie.',
316317
buttons: [viewCurlCmd],
317318
};
318319
}
@@ -352,7 +353,9 @@ export async function enterCredentials(gerritRepo: Repository): Promise<void> {
352353
label: 'Enter username and password',
353354
},
354355
{
355-
label: 'Enter cookie',
356+
label: 'Access token (or cookie)',
357+
description:
358+
'Same value as GerritAccount cookie or from Gerrit Settings → HTTP Credentials',
356359
},
357360
] as const,
358361
{

src/lib/vscode/config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ export function initConfigListener(): void {
4949
});
5050
}
5151

52-
/** @deprecated */
52+
/**
53+
* Configuration that includes auth settings stored in plain text (not recommended).
54+
* Prefer "Gerrit: Enter credentials" for secure storage; these settings are still
55+
* supported for cases like devcontainers where the command is not practical.
56+
*/
5357
export function getConfigurationWithLegacy(): TypedWorkspaceConfiguration<
5458
ConfigSettings & {
55-
/** @deprecated */
59+
/** Not recommended: stored in plain text. Prefer the credentials command for secure storage. */
5660
'gerrit.auth.password'?: string;
57-
/** @deprecated */
61+
/** Not recommended: stored in plain text. Prefer the credentials command for secure storage. */
5862
'gerrit.auth.cookie'?: string;
5963
}
6064
> {

0 commit comments

Comments
 (0)