mirror of
https://github.com/coder/code-server.git
synced 2026-09-11 18:23:23 +02:00
* Update Code to 1.136.1 * Do not click on tab during test file opens It will already be the selected tab, and if any other tab is already open (like the welcome tab), it will click that instead. We disable the welcome page so this is not supposed to actually matter, but that Setting appears not to be working. Also add the quick input widget selector in the disabled downloads test, since if the widget never shows up it would mistakenly pass.
108 lines
4.7 KiB
Diff
108 lines
4.7 KiB
Diff
Add a logout command and menu item
|
|
|
|
This will only show if you have authentication enabled.
|
|
|
|
This has e2e tests but are currently disabled and need to be fixed.
|
|
|
|
Index: code-server/lib/vscode/src/vs/base/common/product.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
|
|
+++ code-server/lib/vscode/src/vs/base/common/product.ts
|
|
@@ -100,6 +100,7 @@ export interface IProductConfiguration {
|
|
readonly codeServerVersion?: string
|
|
readonly rootEndpoint?: string
|
|
readonly updateEndpoint?: string
|
|
+ readonly logoutEndpoint?: string
|
|
|
|
readonly version: string;
|
|
readonly date?: string;
|
|
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
@@ -34,6 +34,7 @@ export function getRedactedServerParsedA
|
|
export const serverOptions: OptionDescriptions<Required<ServerParsedArgs>> = {
|
|
/* ----- code-server ----- */
|
|
'disable-update-check': { type: 'boolean' },
|
|
+ 'auth': { type: 'string' },
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
@@ -128,6 +129,7 @@ export const serverOptions: OptionDescri
|
|
export interface ServerParsedArgs {
|
|
/* ----- code-server ----- */
|
|
'disable-update-check'?: boolean;
|
|
+ 'auth'?: string;
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
@@ -402,6 +402,7 @@ export class WebClientServer {
|
|
codeServerVersion: this._productService.codeServerVersion,
|
|
rootEndpoint: rootBase,
|
|
updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
|
|
+ logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined,
|
|
embedderIdentifier: 'server-distro',
|
|
voiceWsUrl: this._productService.voiceWsUrl,
|
|
extensionsGallery: this._productService.extensionsGallery,
|
|
Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
@@ -1,11 +1,15 @@
|
|
import { Disposable } from "../../base/common/lifecycle.js";
|
|
import { localize } from '../../nls.js';
|
|
+import { MenuId, MenuRegistry } from '../../platform/actions/common/actions.js';
|
|
+import { CommandsRegistry } from '../../platform/commands/common/commands.js';
|
|
import { ILogService } from '../../platform/log/common/log.js';
|
|
import { INotificationService, Severity } from '../../platform/notification/common/notification.js';
|
|
import { IProductService } from '../../platform/product/common/productService.js';
|
|
import { IStorageService, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
|
|
|
|
export class CodeServerClient extends Disposable {
|
|
+ static LOGOUT_COMMAND_ID = 'code-server.logout';
|
|
+
|
|
constructor (
|
|
@ILogService private logService: ILogService,
|
|
@INotificationService private notificationService: INotificationService,
|
|
@@ -81,6 +85,10 @@ export class CodeServerClient extends Di
|
|
if (this.productService.updateEndpoint) {
|
|
this.checkUpdates(this.productService.updateEndpoint)
|
|
}
|
|
+
|
|
+ if (this.productService.logoutEndpoint) {
|
|
+ this.addLogoutCommand(this.productService.logoutEndpoint);
|
|
+ }
|
|
}
|
|
|
|
private checkUpdates(updateEndpoint: string) {
|
|
@@ -132,4 +140,25 @@ export class CodeServerClient extends Di
|
|
|
|
updateLoop();
|
|
}
|
|
+
|
|
+ private addLogoutCommand(logoutEndpoint: string) {
|
|
+ CommandsRegistry.registerCommand(CodeServerClient.LOGOUT_COMMAND_ID, () => {
|
|
+ const logoutUrl = new URL(logoutEndpoint, window.location.href);
|
|
+ // Cookies must be set with absolute paths and must use the same path to
|
|
+ // be unset (we set it on the root) so send the relative root and the
|
|
+ // current href so the backend can derive the absolute path to the root.
|
|
+ logoutUrl.searchParams.set('base', this.productService.rootEndpoint || ".");
|
|
+ logoutUrl.searchParams.set('href', window.location.href);
|
|
+ window.location.assign(logoutUrl);
|
|
+ });
|
|
+
|
|
+ for (const menuId of [MenuId.CommandPalette, MenuId.MenubarHomeMenu]) {
|
|
+ MenuRegistry.appendMenuItem(menuId, {
|
|
+ command: {
|
|
+ id: CodeServerClient.LOGOUT_COMMAND_ID,
|
|
+ title: localize('logout', "Sign out of {0}", 'code-server'),
|
|
+ },
|
|
+ });
|
|
+ }
|
|
+ }
|
|
}
|