diff --git a/components/dashboard/src/service/json-rpc-authprovider-client.ts b/components/dashboard/src/service/json-rpc-authprovider-client.ts index 57c94cbe39d04c..449307f8a541b5 100644 --- a/components/dashboard/src/service/json-rpc-authprovider-client.ts +++ b/components/dashboard/src/service/json-rpc-authprovider-client.ts @@ -103,7 +103,10 @@ export class JsonRpcAuthProviderClient implements PromiseClient, ): Promise { - throw new ConnectError("unimplemented", Code.Unimplemented); + const aps = await getGitpodService().server.getAuthProviders(); + return new ListAuthProviderDescriptionsResponse({ + descriptions: aps.map((ap) => converter.toAuthProviderDescription(ap)), + }); } async updateAuthProvider(request: PartialMessage): Promise { diff --git a/components/gitpod-protocol/src/public-api-converter.ts b/components/gitpod-protocol/src/public-api-converter.ts index 27e90894436a6f..80206204b56bd3 100644 --- a/components/gitpod-protocol/src/public-api-converter.ts +++ b/components/gitpod-protocol/src/public-api-converter.ts @@ -6,7 +6,12 @@ import { Timestamp } from "@bufbuild/protobuf"; import { Code, ConnectError } from "@connectrpc/connect"; -import { AuthProvider, AuthProviderType, OAuth2Config } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; +import { + AuthProvider, + AuthProviderDescription, + AuthProviderType, + OAuth2Config, +} from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; import { Organization, OrganizationMember, @@ -31,6 +36,7 @@ import { ContextURL } from "./context-url"; import { ApplicationError, ErrorCode, ErrorCodes } from "./messaging/error"; import { AuthProviderEntry as AuthProviderProtocol, + AuthProviderInfo, CommitContext, EnvVarWithValue, Workspace as ProtocolWorkspace, @@ -379,11 +385,20 @@ export class PublicAPIConverter { return result; } + toAuthProviderDescription(ap: AuthProviderInfo): AuthProviderDescription { + const result = new AuthProviderDescription({ + id: ap.authProviderId, + host: ap.host, + type: this.toAuthProviderType(ap.authProviderType), + }); + return result; + } + toAuthProvider(ap: AuthProviderProtocol): AuthProvider { const result = new AuthProvider({ id: ap.id, host: ap.host, - type: this.toAuthProviderType(ap), + type: this.toAuthProviderType(ap.type), verified: ap.status === "verified", settingsUrl: ap.oauth?.settingsUrl, scopes: ap.oauth?.scope?.split(ap.oauth?.scopeSeparator || " ") || [], @@ -410,8 +425,8 @@ export class PublicAPIConverter { }); } - toAuthProviderType(ap: AuthProviderProtocol): AuthProviderType { - switch (ap.type) { + toAuthProviderType(type: string): AuthProviderType { + switch (type) { case "GitHub": return AuthProviderType.GITHUB; case "GitLab": diff --git a/components/server/src/api/auth-provider-service-api.ts b/components/server/src/api/auth-provider-service-api.ts index 266cf2b09f757d..e58cf50d4b56ae 100644 --- a/components/server/src/api/auth-provider-service-api.ts +++ b/components/server/src/api/auth-provider-service-api.ts @@ -23,7 +23,8 @@ import { DeleteAuthProviderResponse, } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; import { AuthProviderService } from "../auth/auth-provider-service"; -import { AuthProviderEntry } from "@gitpod/gitpod-protocol"; +import { AuthProviderEntry, AuthProviderInfo } from "@gitpod/gitpod-protocol"; +import { Unauthenticated } from "./unauthenticated"; @injectable() export class AuthProviderServiceAPI implements ServiceImpl { @@ -105,11 +106,22 @@ export class AuthProviderServiceAPI implements ServiceImpl { - throw new ConnectError("unimplemented", Code.Unimplemented); + const user = context.user; + const aps = user + ? await this.authProviderService.getAuthProviderDescriptions(user) + : await this.authProviderService.getAuthProviderDescriptionsUnauthenticated(); + + return new ListAuthProviderDescriptionsResponse({ + descriptions: aps.map((ap: AuthProviderInfo) => this.apiConverter.toAuthProviderDescription(ap)), + }); } async updateAuthProvider(