History

Remove implicit GitHub connection token from git sources

Rhys Sullivan committed 4 months ago

Commit da4f37c1 parent 628d2d71 file · +4 −17Browse files

Unified · Split

packages/plugins/apps/src/plugin/apps-plugin.ts+4−17
@@ -245,20 +245,9 @@ const appRegistrationErrorToDiagnostic = (error: unknown): SyncDiagnostic => { · 244 unmodified lines
245const tokenItemId = (slug: string): ProviderItemId =>245const tokenItemId = (slug: string): ProviderItemId =>
246 ProviderItemId.make(`apps/source-tokens/${slug}`);246 ProviderItemId.make(`apps/source-tokens/${slug}`);
247 247
248const gitHubConnectionToken = (ctx: PluginCtx<AppsStore>): Effect.Effect<string | null, unknown> =>248// A source authenticates only with its own explicitly provided token. No
249 Effect.gen(function* () {249// implicit credential sharing: a stored GitHub connection must never leak
250 const connections = yield* ctx.connections.list({250// into git fetches the user did not tie to it.
251 integration: IntegrationSlug.make("github"),
252 });
253 const connection = connections.find((item) => item.owner === "user") ?? connections[0];
254 if (!connection) return null;
255 return yield* ctx.connections.resolveValue({
256 owner: connection.owner,
257 integration: connection.integration,
258 name: connection.name,
259 });
260 });
261
262const gitTokenFor = (251const gitTokenFor = (
263 ctx: PluginCtx<AppsStore>,252 ctx: PluginCtx<AppsStore>,
264 config: Extract<AppSourceConfig, { readonly kind: "git" }>,253 config: Extract<AppSourceConfig, { readonly kind: "git" }>,
@@ -270,9 +259,7 @@ const gitTokenFor = ( · 5 unmodified lines
270 ProviderItemId.make(config.tokenItemId),259 ProviderItemId.make(config.tokenItemId),
271 );260 );
272 }261 }
273 const url = yield* parseGitSourceUrl(config.url).pipe(Effect.result);262 return null;
274 if (Result.isFailure(url) || url.success.hostname.toLowerCase() !== "github.com") return null;
275 return yield* gitHubConnectionToken(ctx);
276 });263 });
277 264
278const activeToolNamesFor = (265const activeToolNamesFor = (

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t