Skip to content

Commit d6629f3

Browse files
authored
[server] Unimplemented user service on internal port (#16999)
1 parent a439080 commit d6629f3

File tree

7 files changed

+136
-0
lines changed

7 files changed

+136
-0
lines changed

components/server/BUILD.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ packages:
1818
- components/supervisor-api/typescript-grpcweb:lib
1919
- components/usage-api/typescript:lib
2020
- components/ide-service-api/typescript:lib
21+
- components/public-api/typescript:lib
2122
config:
2223
packaging: offline-mirror
2324
yarnLock: ${coreYarnLockBase}/yarn.lock
@@ -57,6 +58,7 @@ packages:
5758
- components/supervisor-api/typescript-grpcweb:lib
5859
- components/usage-api/typescript:lib
5960
- components/ide-service-api/typescript:lib
61+
- components/public-api/typescript:lib
6062
- :dbtest
6163
config:
6264
packaging: library
@@ -83,6 +85,7 @@ packages:
8385
- components/supervisor-api/typescript-grpcweb:lib
8486
- components/usage-api/typescript:lib
8587
- components/ide-service-api/typescript:lib
88+
- components/public-api/typescript:lib
8689
config:
8790
packaging: library
8891
yarnLock: ${coreYarnLockBase}/yarn.lock

components/server/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
],
2929
"dependencies": {
3030
"@authzed/authzed-node": "^0.10.0",
31+
"@bufbuild/connect": "^0.8.1",
32+
"@bufbuild/connect-express": "^0.8.1",
3133
"@gitbeaker/node": "^35.7.0",
3234
"@gitpod/content-service": "0.1.5",
3335
"@gitpod/gitpod-db": "0.1.5",
@@ -36,6 +38,7 @@
3638
"@gitpod/gitpod-protocol": "0.1.5",
3739
"@gitpod/ide-service-api": "0.1.5",
3840
"@gitpod/image-builder": "0.1.5",
41+
"@gitpod/public-api": "0.1.5",
3942
"@gitpod/supervisor-api-grpcweb": "0.1.5",
4043
"@gitpod/usage-api": "0.1.5",
4144
"@gitpod/ws-manager": "0.1.5",

components/server/src/api/user.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { injectable } from "inversify";
8+
import { ServiceImpl, ConnectError, Code } from "@bufbuild/connect";
9+
import { UserService as UserServiceInterface } from "@gitpod/public-api/lib/gitpod/experimental/v1/user_connectweb";
10+
import {
11+
GetAuthenticatedUserRequest,
12+
ListSSHKeysRequest,
13+
CreateSSHKeyRequest,
14+
GetSSHKeyRequest,
15+
DeleteSSHKeyRequest,
16+
GetGitTokenRequest,
17+
BlockUserRequest,
18+
GetAuthenticatedUserResponse,
19+
ListSSHKeysResponse,
20+
CreateSSHKeyResponse,
21+
GetSSHKeyResponse,
22+
DeleteSSHKeyResponse,
23+
GetGitTokenResponse,
24+
BlockUserResponse,
25+
} from "@gitpod/public-api/lib/gitpod/experimental/v1/user_pb";
26+
27+
@injectable()
28+
export class APIUserService implements ServiceImpl<typeof UserServiceInterface> {
29+
public async getAuthenticatedUser(req: GetAuthenticatedUserRequest): Promise<GetAuthenticatedUserResponse> {
30+
throw new ConnectError("unimplemented", Code.Unimplemented);
31+
}
32+
33+
public async listSSHKeys(req: ListSSHKeysRequest): Promise<ListSSHKeysResponse> {
34+
throw new ConnectError("unimplemented", Code.Unimplemented);
35+
}
36+
37+
public async createSSHKey(req: CreateSSHKeyRequest): Promise<CreateSSHKeyResponse> {
38+
throw new ConnectError("unimplemented", Code.Unimplemented);
39+
}
40+
41+
public async getSSHKey(req: GetSSHKeyRequest): Promise<GetSSHKeyResponse> {
42+
throw new ConnectError("unimplemented", Code.Unimplemented);
43+
}
44+
45+
public async deleteSSHKey(req: DeleteSSHKeyRequest): Promise<DeleteSSHKeyResponse> {
46+
throw new ConnectError("unimplemented", Code.Unimplemented);
47+
}
48+
49+
public async getGitToken(req: GetGitTokenRequest): Promise<GetGitTokenResponse> {
50+
throw new ConnectError("unimplemented", Code.Unimplemented);
51+
}
52+
53+
public async blockUser(req: BlockUserRequest): Promise<BlockUserResponse> {
54+
throw new ConnectError("unimplemented", Code.Unimplemented);
55+
}
56+
}

components/server/src/container-module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import { IamSessionApp } from "./iam/iam-session-app";
113113
import { spicedbClientFromEnv, SpiceDBClient } from "./authorization/spicedb";
114114
import { Authorizer, PermissionChecker } from "./authorization/perms";
115115
import { EnvVarService } from "./workspace/env-var-service";
116+
import { APIUserService } from "./api/user";
116117

117118
export const productionContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
118119
bind(Config).toConstantValue(ConfigFile.fromFile());
@@ -313,4 +314,7 @@ export const productionContainerModule = new ContainerModule((bind, unbind, isBo
313314
.toDynamicValue(() => spicedbClientFromEnv())
314315
.inSingletonScope();
315316
bind(PermissionChecker).to(Authorizer).inSingletonScope();
317+
318+
// grpc / Connect API
319+
bind(APIUserService).toSelf().inSingletonScope();
316320
});

components/server/src/server.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ import { WebhookEventGarbageCollector } from "./projects/webhook-event-garbage-c
5252
import { LivenessController } from "./liveness/liveness-controller";
5353
import { IamSessionApp } from "./iam/iam-session-app";
5454
import { LongRunningMigrationService } from "@gitpod/gitpod-db/lib/long-running-migration/long-running-migration";
55+
import { expressConnectMiddleware } from "@bufbuild/connect-express";
56+
import { UserService as UserServiceDefinition } from "@gitpod/public-api/lib/gitpod/experimental/v1/user_connectweb";
57+
import { APIUserService } from "./api/user";
58+
import { ConnectRouter } from "@bufbuild/connect";
5559

5660
@injectable()
5761
export class Server<C extends GitpodClient, S extends GitpodServer> {
@@ -93,6 +97,9 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
9397
protected iamSessionApp?: express.Application;
9498
protected iamSessionAppServer?: http.Server;
9599

100+
@inject(APIUserService) protected readonly apiUserService: APIUserService;
101+
protected apiServer?: http.Server;
102+
96103
protected readonly eventEmitter = new EventEmitter();
97104
protected app?: express.Application;
98105
protected httpServer?: http.Server;
@@ -307,6 +314,7 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
307314
.catch((err) => log.error("webhook-event-gc: error during startup", err));
308315

309316
this.app = app;
317+
310318
log.info("server initialized.");
311319
}
312320

@@ -388,6 +396,20 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
388396
});
389397
}
390398

399+
{
400+
const apiApp = express();
401+
apiApp.use(
402+
expressConnectMiddleware({
403+
routes: (router: ConnectRouter) => {
404+
router.service(UserServiceDefinition, this.apiUserService);
405+
},
406+
}),
407+
);
408+
this.apiServer = apiApp.listen(9877, () => {
409+
log.info(`Connect API server listening on: ${<AddressInfo>this.apiServer!.address()}`);
410+
});
411+
}
412+
391413
this.debugApp.start();
392414
}
393415

@@ -397,6 +419,7 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
397419
await this.stopServer(this.monitoringHttpServer);
398420
await this.stopServer(this.installationAdminHttpServer);
399421
await this.stopServer(this.httpServer);
422+
await this.stopServer(this.apiServer);
400423
this.disposables.dispose();
401424
log.info("server stopped.");
402425
}

gitpod-ws.code-workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
{ "path": "components/ws-proxy" },
2626
{ "path": "components/public-api" },
2727
{ "path": "components/public-api-server" },
28+
{ "path": "components/public-api/typescript" },
2829
{ "path": "components/gitpod-db" },
2930
{ "path": "test" },
3031
{ "path": "dev/blowtorch" },

yarn.lock

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,11 +1238,33 @@
12381238
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"
12391239
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
12401240

1241+
"@bufbuild/connect-express@^0.8.1":
1242+
version "0.8.1"
1243+
resolved "https://registry.yarnpkg.com/@bufbuild/connect-express/-/connect-express-0.8.1.tgz#54eb548896fad2488bc9cd16b968713e0799c955"
1244+
integrity sha512-DZkPfMYmL1doR8XaeQdwHI0YmKyWz7sG9HaZYEOcBoag+lnlbqXGaakx5gbMnE1OSX7qkSVEqrv7kB/B1tSXOQ==
1245+
dependencies:
1246+
"@bufbuild/connect" "0.8.1"
1247+
"@bufbuild/connect-node" "^0.8.1"
1248+
"@types/express" "^4.17.17"
1249+
1250+
"@bufbuild/connect-node@^0.8.1":
1251+
version "0.8.1"
1252+
resolved "https://registry.yarnpkg.com/@bufbuild/connect-node/-/connect-node-0.8.1.tgz#db371506a9c54cac78b0b73b25dd531d86dbe45a"
1253+
integrity sha512-yIdXWekNaKDBFVWY6S6L0js6Szh2fhunmVxxCd5taOL4KekO5joIfuA9eLuunTDlp1ie0fPPm7Dc5KlxWgOn0Q==
1254+
dependencies:
1255+
"@bufbuild/connect" "0.8.1"
1256+
headers-polyfill "^3.1.2"
1257+
12411258
"@bufbuild/connect-web@^0.2.1":
12421259
version "0.2.1"
12431260
resolved "https://registry.yarnpkg.com/@bufbuild/connect-web/-/connect-web-0.2.1.tgz#a7ee2914bf1b77d640fc4ee3c3a89d626f3015fa"
12441261
integrity sha512-L580cL9VZCXcjwXMCvIvdFBqdQofVBQcL+jmSis7m8ZxPj5NQ4p7fUhQRTsZMWHkyWINdlZnr7WsHQL0BT7wPQ==
12451262

1263+
"@bufbuild/[email protected]", "@bufbuild/connect@^0.8.1":
1264+
version "0.8.1"
1265+
resolved "https://registry.yarnpkg.com/@bufbuild/connect/-/connect-0.8.1.tgz#71afa90bf56bb833a7f3e2a492e6f9f83c2bebeb"
1266+
integrity sha512-cQA0jstYcLknJecTE7KbU4ePNBqiCNviBEcUCbFLve3x+vcSmtoH6jb8z39MeBqFy42ZoWhTGGc3RNCeOx2QUA==
1267+
12461268
"@bufbuild/[email protected]", "@bufbuild/protobuf@^0.1.1":
12471269
version "0.1.1"
12481270
resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-0.1.1.tgz#163dee03af49e82d300dfa2bf60c8c0f04c80b4c"
@@ -2880,6 +2902,15 @@
28802902
"@types/qs" "*"
28812903
"@types/range-parser" "*"
28822904

2905+
"@types/express-serve-static-core@^4.17.33":
2906+
version "4.17.33"
2907+
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz#de35d30a9d637dc1450ad18dd583d75d5733d543"
2908+
integrity sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==
2909+
dependencies:
2910+
"@types/node" "*"
2911+
"@types/qs" "*"
2912+
"@types/range-parser" "*"
2913+
28832914
"@types/express-session@*", "@types/[email protected]":
28842915
version "1.17.4"
28852916
resolved "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.4.tgz"
@@ -2897,6 +2928,16 @@
28972928
"@types/qs" "*"
28982929
"@types/serve-static" "*"
28992930

2931+
"@types/express@^4.17.17":
2932+
version "4.17.17"
2933+
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.17.tgz#01d5437f6ef9cfa8668e616e13c2f2ac9a491ae4"
2934+
integrity sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==
2935+
dependencies:
2936+
"@types/body-parser" "*"
2937+
"@types/express-serve-static-core" "^4.17.33"
2938+
"@types/qs" "*"
2939+
"@types/serve-static" "*"
2940+
29002941
"@types/fs-extra@^9.0.12":
29012942
version "9.0.13"
29022943
resolved "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz"
@@ -9355,6 +9396,11 @@ he@^1.2.0:
93559396
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
93569397
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
93579398

9399+
headers-polyfill@^3.1.2:
9400+
version "3.1.2"
9401+
resolved "https://registry.yarnpkg.com/headers-polyfill/-/headers-polyfill-3.1.2.tgz#9a4dcb545c5b95d9569592ef7ec0708aab763fbe"
9402+
integrity sha512-tWCK4biJ6hcLqTviLXVR9DTRfYGQMXEIUj3gwJ2rZ5wO/at3XtkI4g8mCvFdUF9l1KMBNCfmNAdnahm1cgavQA==
9403+
93589404
heapdump@^0.3.15:
93599405
version "0.3.15"
93609406
resolved "https://registry.npmjs.org/heapdump/-/heapdump-0.3.15.tgz"

0 commit comments

Comments
 (0)