mirror of https://github.com/buster-so/buster.git
Require auth for github endpoints
This commit is contained in:
parent
9c1b86b171
commit
9c1a2f9c37
|
@ -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');
|
||||||
|
|
||||||
|
|
|
@ -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({
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue