Require auth for github endpoints

This commit is contained in:
Nate Kelley 2025-09-11 09:57:16 -06:00
parent 9c1b86b171
commit 9c1a2f9c37
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 10 additions and 5 deletions

View File

@ -13,10 +13,12 @@ const app = new Hono<{
Variables: { Variables: {
busterUser: User; busterUser: User;
}; };
}>(); }>()
// Apply authentication middleware to all routes
.use('*', requireAuth);
// Get organization datasets endpoint // Get organization datasets endpoint
app.get('/', requireAuth, async (c) => { app.get('/', async (c) => {
const user = c.get('busterUser'); const user = c.get('busterUser');
const dataSourceId = c.req.query('dataSourceId'); const dataSourceId = c.req.query('dataSourceId');

View File

@ -34,6 +34,7 @@ const app = new Hono()
return c.json(response); return c.json(response);
}) })
// OAuth callback - no auth needed since GitHub redirects here
.get('/auth/callback', zValidator('query', AuthCallbackSchema), async (c) => { .get('/auth/callback', zValidator('query', AuthCallbackSchema), async (c) => {
const query = c.req.valid('query'); const query = c.req.valid('query');
const result = await authCallbackHandler({ const result = await authCallbackHandler({

View File

@ -42,17 +42,19 @@ const app = new Hono().get(
today.getFullYear() === updatedDate.getFullYear() && today.getFullYear() === updatedDate.getFullYear() &&
today.getMonth() === updatedDate.getMonth() && today.getMonth() === updatedDate.getMonth() &&
today.getDate() === updatedDate.getDate(); today.getDate() === updatedDate.getDate();
if (isToday) { if (isToday) {
return c.json(currentSuggestedPrompts); return c.json(currentSuggestedPrompts);
} }
} }
const timeoutMs = 10000; // 10 seconds timeout const timeoutMs = 10000; // 10 seconds timeout
const timeoutPromise = new Promise<never>((_, reject) => { const timeoutPromise = new Promise<never>((_, reject) => {
setTimeout(() => { setTimeout(() => {
reject(new Error('Request timeout after 10 seconds. Returning current suggested prompts.')); reject(
new Error('Request timeout after 10 seconds. Returning current suggested prompts.')
);
}, timeoutMs); }, timeoutMs);
}); });