-
Notifications
You must be signed in to change notification settings - Fork 42
Fixing dashboard #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fixing dashboard #335
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c9cf63a
Refactor state management routes to replace current states with runs …
NiveditJain 9ff2acc
Enhance errored state handling and state status management
NiveditJain c55271d
Add Run model and enhance run management functionality
NiveditJain 652f840
Refactor state management to utilize new run models
NiveditJain a3143e1
Update route tags from "state" to "runs" for improved clarity in API …
NiveditJain f67f1d3
changed to table
NiveditJain 544a591
Refactor dashboard to enhance security and API structure
NiveditJain 017b1e3
Refactor dashboard for enhanced security and environment configuration
NiveditJain 8cc8de3
Update dashboard to enhance API functionality and remove deprecated c…
NiveditJain 89c8e9f
Update get_run_status to handle multiple errored states
NiveditJain dba60fa
Refactor GraphVisualization and state models for improved clarity and…
NiveditJain 86efd58
Refactor state management and enhance run functionality
NiveditJain f0e3a83
Enhance CORS test setup by adding project root to sys.path
NiveditJain 54fe722
Add ruff directive to ignore E402 in test_cors.py
NiveditJain cb791bf
gemini review
NiveditJain bb0d8b0
Update Docker Compose setup documentation for environment variable is…
NiveditJain d66892c
Add tests for get_run_details_by_run_id_route in test_routes.py
NiveditJain 14693d4
Update API base URL environment variable for consistency
NiveditJain a506f20
Update authentication description and fix formatting in create-runtim…
NiveditJain faf33a7
Fix retry state creation logic in errored_state.py
NiveditJain d61438b
Remove unnecessary blank lines in SECURITY.md for improved readability
NiveditJain 02e7d30
fix: add namespace_name index to runs collection
NiveditJain 9db988e
Fix assertions in test cases for errored state and get runs
NiveditJain 755341f
Add tests for new routes in test_routes.py
NiveditJain 8e03aae
Enhance tests for get_run_details_by_run_id_route in test_routes.py
NiveditJain 9b31ba2
Add comprehensive tests for get_runs_route in test_routes.py
NiveditJain de24319
Refactor imports in test_routes.py for clarity
NiveditJain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Security Architecture | ||
|
|
||
| ## Overview | ||
|
|
||
| This dashboard has been refactored to use **Server-Side Rendering (SSR)** for enhanced security. All API calls to the state-manager are now handled server-side, keeping sensitive information like API keys secure. | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Architecture Changes | ||
|
|
||
| ### Before (Client-Side) | ||
| - API key was visible in browser | ||
| - Direct calls to state-manager from client | ||
| - Security risk in production environments | ||
|
|
||
| ### After (Server-Side) | ||
| - API key stored securely in environment variables | ||
| - All API calls go through Next.js API routes | ||
| - Client never sees sensitive credentials | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| ### Server-Side (NOT exposed to browser) | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```bash | ||
| EXOSPHERE_STATE_MANAGER_URI=http://localhost:8000 | ||
| EXOSPHERE_API_KEY=exosphere@123 | ||
| ``` | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Client-Side (exposed to browser) | ||
| ```bash | ||
| NEXT_PUBLIC_DEFAULT_NAMESPACE=your-namespace | ||
| ``` | ||
|
|
||
| ## API Routes | ||
|
|
||
| The following server-side API routes handle all communication with the state-manager: | ||
|
|
||
| - `/api/runs` - Fetch paginated runs | ||
| - `/api/graph-structure` - Get graph visualization data | ||
| - `/api/namespace-overview` - Get namespace summary data | ||
| - `/api/graph-template` - Manage graph templates | ||
|
|
||
| ## Security Benefits | ||
|
|
||
| 1. **API Key Protection**: API keys are never exposed to the client | ||
| 2. **Server-Side Validation**: All requests are validated server-side | ||
| 3. **Environment Isolation**: Sensitive config separated from client code | ||
| 4. **Production Ready**: Secure for deployment in production environments | ||
|
|
||
| ## Setup Instructions | ||
|
|
||
| 1. Copy `env.example` to `.env.local` | ||
| 2. **Optional**: Override the default API key in `EXOSPHERE_API_KEY` (defaults to `exosphere@123`, same as `STATE_MANAGER_SECRET` in the state manager container) | ||
| 3. **Authentication**: The `EXOSPHERE_API_KEY` value is checked for equality with the `STATE_MANAGER_SECRET` value when making API requests to the state-manager | ||
| 4. Configure your state-manager URI in `EXOSPHERE_STATE_MANAGER_URI` | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 5. Set your default namespace in `NEXT_PUBLIC_DEFAULT_NAMESPACE` | ||
|
|
||
| ## Development vs Production | ||
|
|
||
| - **Development**: Uses localhost URLs and development API keys | ||
| - **Production**: Uses production URLs and secure API keys | ||
| - **Environment**: Automatically detects and uses appropriate configuration | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Never commit `.env.local`** to version control | ||
| 2. **Use strong, unique API keys** for production | ||
| 3. **Rotate API keys** regularly | ||
| 4. **Monitor API usage** for security anomalies | ||
| 5. **Use HTTPS** in production environments | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| # State Manager Frontend Environment Configuration | ||
| # State Manager Environment Configuration | ||
|
|
||
| # API Configuration | ||
| NEXT_PUBLIC_EXOSPHERE_STATE_MANAGER_URL=http://localhost:8000 | ||
| # Server-side API Configuration (NOT exposed to client) | ||
| EXOSPHERE_STATE_MANAGER_URI=http://localhost:8000 | ||
| EXOSPHERE_API_KEY=exosphere@123 | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Development Configuration | ||
| NEXT_PUBLIC_DEV_MODE=true | ||
| # Client-side Configuration (exposed to browser) | ||
| NEXT_PUBLIC_DEFAULT_NAMESPACE=your-namespace | ||
|
|
||
| # Optional: Override default configuration | ||
| # NEXT_PUBLIC_DEFAULT_NAMESPACE=your-namespace | ||
| # NEXT_PUBLIC_DEFAULT_API_KEY=your-api-key | ||
| # NEXT_PUBLIC_DEFAULT_RUNTIME_NAME=your-runtime | ||
| # NEXT_PUBLIC_DEFAULT_GRAPH_NAME=your-graph | ||
| # Development Configuration | ||
| NODE_ENV=development | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
|
|
||
| const API_BASE_URL = process.env.EXOSPHERE_STATE_MANAGER_URI || 'http://localhost:8000'; | ||
| const API_KEY = process.env.EXOSPHERE_API_KEY; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| try { | ||
| const { searchParams } = new URL(request.url); | ||
| const namespace = searchParams.get('namespace'); | ||
| const runId = searchParams.get('runId'); | ||
|
|
||
| if (!namespace || !runId) { | ||
| return NextResponse.json({ error: 'Namespace and runId are required' }, { status: 400 }); | ||
| } | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (!API_KEY) { | ||
| return NextResponse.json({ error: 'API key not configured' }, { status: 500 }); | ||
| } | ||
|
|
||
| const response = await fetch(`${API_BASE_URL}/v0/namespace/${namespace}/states/run/${runId}/graph`, { | ||
| headers: { | ||
| 'X-API-Key': API_KEY, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`State manager API error: ${response.status} ${response.statusText}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data); | ||
| } catch (error) { | ||
| console.error('Error fetching graph structure:', error); | ||
| return NextResponse.json( | ||
| { error: 'Failed to fetch graph structure' }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
|
|
||
| const API_BASE_URL = process.env.EXOSPHERE_STATE_MANAGER_URI || 'http://localhost:8000'; | ||
| const API_KEY = process.env.EXOSPHERE_API_KEY; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| try { | ||
| const { searchParams } = new URL(request.url); | ||
| const namespace = searchParams.get('namespace'); | ||
| const graphName = searchParams.get('graphName'); | ||
|
|
||
| if (!namespace || !graphName) { | ||
| return NextResponse.json({ error: 'Namespace and graphName are required' }, { status: 400 }); | ||
| } | ||
|
|
||
| if (!API_KEY) { | ||
| return NextResponse.json({ error: 'API key not configured' }, { status: 500 }); | ||
| } | ||
|
|
||
| const response = await fetch(`${API_BASE_URL}/v0/namespace/${namespace}/graph/${graphName}`, { | ||
| headers: { | ||
| 'X-API-Key': API_KEY, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`State manager API error: ${response.status} ${response.statusText}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data); | ||
| } catch (error) { | ||
| console.error('Error fetching graph template:', error); | ||
| return NextResponse.json( | ||
| { error: 'Failed to fetch graph template' }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
NiveditJain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export async function PUT(request: NextRequest) { | ||
| try { | ||
| const { searchParams } = new URL(request.url); | ||
| const namespace = searchParams.get('namespace'); | ||
| const graphName = searchParams.get('graphName'); | ||
|
|
||
| if (!namespace || !graphName) { | ||
| return NextResponse.json({ error: 'Namespace and graphName are required' }, { status: 400 }); | ||
| } | ||
|
|
||
| if (!API_KEY) { | ||
| return NextResponse.json({ error: 'API key not configured' }, { status: 500 }); | ||
| } | ||
|
|
||
| const body = await request.json(); | ||
|
|
||
| const response = await fetch(`${API_BASE_URL}/v0/namespace/${namespace}/graph/${graphName}`, { | ||
| method: 'PUT', | ||
| headers: { | ||
| 'X-API-Key': API_KEY, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`State manager API error: ${response.status} ${response.statusText}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| return NextResponse.json(data); | ||
| } catch (error) { | ||
| console.error('Error updating graph template:', error); | ||
| return NextResponse.json( | ||
| { error: 'Failed to update graph template' }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.