feat(backend): Make agent store data to be publicly accessible by non authenticated user (#9710)

This PR publicly exposes all the agents listed in the store to the
internet.

### Changes 🏗️

Remove the auth requirement for an agent to download the agent.

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] Accessing
`http://localhost:8006/api/store/download/agents/{agentId}` without
authorization key.
This commit is contained in:
Zamil Majdy
2025-03-28 14:11:48 +07:00
committed by GitHub
parent c6703dd891
commit 071ae3cb1f
2 changed files with 7 additions and 4 deletions

View File

@@ -1005,7 +1005,7 @@ async def get_my_agents(
async def get_agent(
user_id: str,
user_id: str | None,
store_listing_version_id: str,
) -> GraphModel:
"""Get agent using the version ID and store listing version ID."""

View File

@@ -7,6 +7,7 @@ import autogpt_libs.auth.depends
import autogpt_libs.auth.middleware
import fastapi
import fastapi.responses
from autogpt_libs.auth.depends import auth_middleware, get_user_id
import backend.data.block
import backend.data.graph
@@ -639,9 +640,7 @@ async def generate_image(
tags=["store", "public"],
)
async def download_agent_file(
user_id: typing.Annotated[
str, fastapi.Depends(autogpt_libs.auth.depends.get_user_id)
],
request: fastapi.Request,
store_listing_version_id: str = fastapi.Path(
..., description="The ID of the agent to download"
),
@@ -658,6 +657,10 @@ async def download_agent_file(
Raises:
HTTPException: If the agent is not found or an unexpected error occurs.
"""
try:
user_id = get_user_id(await auth_middleware(request))
except fastapi.HTTPException:
user_id = None
graph_data = await backend.server.v2.store.db.get_agent(
user_id=user_id,