Skip to content

Commit ddb03f0

Browse files
committed
wip
1 parent 26c291c commit ddb03f0

File tree

3 files changed

+7
-51
lines changed

3 files changed

+7
-51
lines changed

src/auth/discovery.ts

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,11 @@ export function createTokenHandler(oauthProvider: any) {
160160
}
161161

162162
/**
163-
* Token introspection endpoint - proxies to external OAuth provider
163+
* Token introspection endpoint - simplified for OAuth proxy pattern
164164
*/
165165
export function createIntrospectionHandler(oauthProvider?: any) {
166166
return async (req: Request, res: Response) => {
167167
try {
168-
const config = getConfig();
169168
const { token } = req.body;
170169

171170
if (!token) {
@@ -175,54 +174,10 @@ export function createIntrospectionHandler(oauthProvider?: any) {
175174
});
176175
}
177176

178-
if (config.AUTH_MODE === "full") {
179-
// Proxy introspection to external OAuth provider
180-
try {
181-
const introspectionParams = new URLSearchParams({
182-
token,
183-
token_type_hint: "access_token"
184-
});
185-
186-
const introspectionResponse = await fetch(`${config.OAUTH_ISSUER}/oauth/introspect`, {
187-
method: "POST",
188-
headers: {
189-
"Content-Type": "application/x-www-form-urlencoded",
190-
"Authorization": `Basic ${Buffer.from(`${config.OAUTH_CLIENT_ID}:${config.OAUTH_CLIENT_SECRET}`).toString('base64')}`
191-
},
192-
body: introspectionParams
193-
});
194-
195-
if (!introspectionResponse.ok) {
196-
logger.warn("External OAuth introspection failed", {
197-
status: introspectionResponse.status
198-
});
199-
return res.json({ active: false });
200-
}
201-
202-
const introspectionData = await introspectionResponse.json();
203-
204-
logger.info("Token introspection proxied to external provider", {
205-
token: token.substring(0, 10) + "...",
206-
active: introspectionData.active
207-
});
208-
209-
res.json(introspectionData);
210-
} catch (error) {
211-
logger.warn("External OAuth introspection error", {
212-
error: error instanceof Error ? error.message : error
213-
});
214-
res.json({ active: false });
215-
}
216-
} else {
217-
// Fallback - use our own token validator
218-
logger.info("Token introspection requested", { token: token.substring(0, 10) + "..." });
219-
res.json({
220-
active: true,
221-
scope: "read",
222-
client_id: "mcp-client",
223-
exp: Math.floor(Date.now() / 1000) + 3600
224-
});
225-
}
177+
logger.info("Token introspection requested", { token: token.substring(0, 10) + "..." });
178+
179+
// Return inactive for OAuth proxy pattern - external IdP handles actual validation
180+
res.json({ active: false });
226181

227182
} catch (error) {
228183
logger.error("Token introspection error", {

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const configSchema = z.object({
1616
OAUTH_AUDIENCE: z.string().optional(),
1717
OAUTH_CLIENT_ID: z.string().optional(),
1818
OAUTH_CLIENT_SECRET: z.string().optional(),
19+
OAUTH_CALLBACK_PATH: z.string().default("/callback"),
1920
});
2021

2122
export type Config = z.infer<typeof configSchema>;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ if (config.AUTH_MODE === "full") {
123123

124124
// OAuth 2.1 proxy endpoints - these proxy to the external OAuth provider
125125
app.get("/oauth/authorize", createAuthorizeHandler(oauthProvider));
126-
app.get("/oauth/callback", createCallbackHandler());
126+
app.get(config.OAUTH_CALLBACK_PATH, createCallbackHandler());
127127
app.post("/oauth/token", createTokenHandler(oauthProvider));
128128
app.post("/oauth/introspect", createIntrospectionHandler(oauthProvider));
129129
app.post("/oauth/revoke", createRevocationHandler());

0 commit comments

Comments
 (0)