Skip to content

Commit 090a2ae

Browse files
wip
1 parent 17f79b3 commit 090a2ae

4 files changed

Lines changed: 7 additions & 11 deletions

File tree

packages/web/src/app/api/(server)/ee/mcp/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
112112
await mcpServer.connect(transport);
113113

114114
return transport.handleRequest(request);
115-
}, { requiredOAuthScopes: [SOURCEBOT_MCP_OAUTH_SCOPE] })
115+
}, { requiredOAuthScopes: ['mcp'] })
116116
);
117117

118118
if (isServiceError(response)) {
@@ -156,7 +156,7 @@ export const DELETE = apiHandler(async (request: NextRequest) => {
156156
}
157157

158158
return session.transport.handleRequest(request);
159-
}, { requiredOAuthScopes: [SOURCEBOT_MCP_OAUTH_SCOPE] })
159+
}, { requiredOAuthScopes: ['mcp'] })
160160
);
161161

162162
if (isServiceError(result)) {

packages/web/src/ee/features/oauth/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export const UNPERMITTED_SCHEMES = /^(javascript|data|vbscript):/i;
55

66
export const SOURCEBOT_OAUTH_SCOPES = [
77
"mcp"
8-
];
9-
export type SourcebotOauthScope = (typeof SOURCEBOT_OAUTH_SCOPES)[number];
8+
] as const;
9+
export type SourcebotOAuthScope = (typeof SOURCEBOT_OAUTH_SCOPES)[number];
1010

1111
export const SOURCEBOT_MCP_OAUTH_SCOPE = 'mcp';
1212
export const DEFAULT_SOURCEBOT_OAUTH_SCOPES = [SOURCEBOT_MCP_OAUTH_SCOPE] as const;

packages/web/src/ee/features/oauth/server.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import {
1111
OAUTH_REFRESH_TOKEN_PREFIX,
1212
} from '@sourcebot/shared';
1313
import crypto from 'crypto';
14-
import { DEFAULT_SOURCEBOT_OAUTH_SCOPES } from './constants';
15-
import { formatOAuthScopeString } from './utils';
16-
17-
const DEFAULT_SOURCEBOT_OAUTH_SCOPE_STRING = formatOAuthScopeString(DEFAULT_SOURCEBOT_OAUTH_SCOPES);
1814

1915
// Generates a random authorization code, hashes it, and stores it alongside the
2016
// PKCE code challenge. Returns the raw code to be sent to the client.
@@ -203,7 +199,7 @@ export async function verifyAndRotateRefreshToken({
203199

204200
const { token, hash: newTokenHash } = generateOAuthToken();
205201
const { token: refreshToken, hash: newRefreshHash } = generateOAuthRefreshToken();
206-
const scope = existing.scope || DEFAULT_SOURCEBOT_OAUTH_SCOPE_STRING;
202+
const scope = existing.scope;
207203
const tokenDpopJkt = existing.dpopJkt ?? dpopJkt;
208204

209205
await __unsafePrisma.$transaction([

packages/web/src/middleware/withAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { hasEntitlement, isAnonymousAccessEnabled } from "@/lib/entitlements";
1212
import { hasRequiredOAuthScopes, parseOAuthScopeString } from "@/ee/features/oauth/utils";
1313
import { DPOP_AUTH_SCHEME, DPOP_PROOF_HEADER, verifyDpopProof } from "@/ee/features/oauth/dpop";
1414
import { getCurrentRequest } from "@/lib/requestContext";
15-
import { SourcebotOauthScope } from "@/ee/features/oauth/constants";
15+
import { SourcebotOAuthScope } from "@/ee/features/oauth/constants";
1616

1717
const LAST_ACTIVE_AT_THRESHOLD_MS = 5 * 60 * 1000;
1818

@@ -33,7 +33,7 @@ type OptionalAuthContext =
3333
};
3434

3535
type AuthOptions = {
36-
requiredOAuthScopes?: readonly SourcebotOauthScope[];
36+
requiredOAuthScopes?: readonly SourcebotOAuthScope[];
3737
};
3838

3939
export const withAuth = async <T>(fn: (params: RequiredAuthContext) => Promise<T>, options: AuthOptions = {}) => {

0 commit comments

Comments
 (0)