Skip to content

Commit 236f31e

Browse files
jeanp413roboquat
authored andcommitted
Validate scopes per client
1 parent d8f51d3 commit 236f31e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/server/src/oauth-server/db.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function createVSCodeClient(protocol: "vscode" | "vscode-insiders"): OAuthClient
6767
{ name: "function:getGitpodTokenScopes" },
6868
{ name: "function:getLoggedInUser" },
6969
{ name: "function:accessCodeSyncStorage" },
70+
{ name: "function:getOwnerToken" },
71+
{ name: "function:getWorkspace" },
72+
{ name: "function:getWorkspaces" },
7073
{ name: "resource:default" },
7174
],
7275
};

components/server/src/oauth-server/repository.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export const inMemoryScopeRepository: OAuthScopeRepository = {
4848
client: OAuthClient,
4949
user_id?: string,
5050
): Promise<OAuthScope[]> {
51-
return scopes;
51+
const clientScopes = client.scopes.map((s) => s.name);
52+
if (scopes.every((s) => clientScopes.includes(s.name))) {
53+
return scopes;
54+
}
55+
56+
throw new Error("Requested scopes not allowed");
5257
},
5358
};

0 commit comments

Comments
 (0)