Buckets:

download
raw
1.89 kB
"""Git credential broker for GitHub App-backed workspaces."""
from typing import Optional
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from .auth import installation_token
github_git_credentials_router = APIRouter(prefix='/v1/agent', tags=['agent'])
class GitCredentialRequest(BaseModel):
operation: str = 'get'
protocol: Optional[str] = None
host: Optional[str] = None
path: Optional[str] = None
@github_git_credentials_router.post('/workspaces/{workspace_id}/git/credentials')
async def issue_git_credentials(workspace_id: str, request: GitCredentialRequest):
"""Mint short-lived GitHub credentials for the worker helper."""
from .. import database as db
from ..git_service import get_git_credentials
workspace = await db.db_get_workspace(workspace_id)
if not workspace:
raise HTTPException(status_code=404, detail='Workspace not found')
credentials = await get_git_credentials(workspace_id)
if credentials and credentials.get('token'):
return {'username': 'x-access-token', 'password': credentials['token'], 'expires_at': credentials.get('expires_at'), 'token_type': credentials.get('token_type', 'pat'), 'host': request.host, 'path': request.path}
agent_config = workspace.get('agent_config') or {}
github_app = (
((agent_config.get('git_auth') or {}).get('github_app'))
or ((workspace.get('git_auth') or {}).get('github_app'))
or {}
)
installation_id = github_app.get('installation_id')
if not installation_id:
raise HTTPException(status_code=404, detail='No Git credentials available for workspace')
token, expires_at = await installation_token(int(installation_id))
return {'username': 'x-access-token', 'password': token, 'expires_at': expires_at, 'token_type': 'github_app', 'host': request.host, 'path': request.path}

Xet Storage Details

Size:
1.89 kB
·
Xet hash:
bb4b7c4e7b89aa4c8ab44e6a10c8c0c47d8c0fc08a3fa11e66c3c1b39fd25a91

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.