feat(recipe-studio): add authentication to API requests and backend routes
This commit is contained in:
parent
1334b24bea
commit
df553fc955
4 changed files with 11 additions and 7 deletions
|
|
@ -5,7 +5,9 @@ from __future__ import annotations
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from auth.authentication import get_current_subject
|
||||
|
||||
backend_path = Path(__file__).parent.parent.parent
|
||||
if str(backend_path) not in sys.path:
|
||||
|
|
@ -15,7 +17,7 @@ from .jobs import router as jobs_router
|
|||
from .seed import router as seed_router
|
||||
from .validate import router as validate_router
|
||||
|
||||
router = APIRouter()
|
||||
router = APIRouter(dependencies=[Depends(get_current_subject)])
|
||||
router.include_router(seed_router)
|
||||
router.include_router(validate_router)
|
||||
router.include_router(jobs_router)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { authFetch } from "@/features/auth";
|
||||
|
||||
const DEFAULT_BASE = "/api/data-recipe";
|
||||
|
||||
export const DATA_DESIGNER_API_BASE =
|
||||
|
|
@ -146,7 +148,7 @@ async function parseErrorResponse(response: Response): Promise<string> {
|
|||
}
|
||||
|
||||
async function postJson<T>(path: string, payload: unknown): Promise<T> {
|
||||
const response = await fetch(`${DATA_DESIGNER_API_BASE}${path}`, {
|
||||
const response = await authFetch(`${DATA_DESIGNER_API_BASE}${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -162,7 +164,7 @@ async function postJson<T>(path: string, payload: unknown): Promise<T> {
|
|||
}
|
||||
|
||||
async function getJson<T>(path: string): Promise<T> {
|
||||
const response = await fetch(`${DATA_DESIGNER_API_BASE}${path}`);
|
||||
const response = await authFetch(`${DATA_DESIGNER_API_BASE}${path}`);
|
||||
if (!response.ok) {
|
||||
throw new Error(await parseErrorResponse(response));
|
||||
}
|
||||
|
|
@ -273,7 +275,7 @@ export async function streamRecipeJobEvents(options: {
|
|||
query = `?after=${options.lastEventId}`;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
const response = await authFetch(
|
||||
`${DATA_DESIGNER_API_BASE}/jobs/${options.jobId}/events${query}`,
|
||||
{
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export function ExecutionSidebar({
|
|||
}: ExecutionSidebarProps): ReactElement {
|
||||
return (
|
||||
<aside className="w-72 shrink-0 border-r border-border/60 bg-card/20">
|
||||
<div className="flex items-center justify-between border-b border-border/60 px-3 py-2">
|
||||
<div className="flex items-center justify-between border-border/60 px-3 py-2">
|
||||
<p className="text-xs font-semibold uppercase text-muted-foreground">
|
||||
Executions
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ export function ExecutionsView({
|
|||
) : (
|
||||
<div className="space-y-4">
|
||||
{showProgressPanel && (
|
||||
<div className="space-y-3 rounded-2xl border border-border/60 bg-card/55 p-3">
|
||||
<div className="space-y-3 rounded-2xl border shadow-border border-border/60 bg-card/55 p-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<HugeiconsIcon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue