repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | from typing import Optional |
| #2 | from uuid import UUID |
| #3 | |
| #4 | from app.models import App, Memory, MemoryState |
| #5 | from sqlalchemy.orm import Session |
| #6 | |
| #7 | |
| #8 | def check_memory_access_permissions( |
| #9 | db: Session, |
| #10 | memory: Memory, |
| #11 | app_id: Optional[UUID] = None |
| #12 | ) -> bool: |
| #13 | """ |
| #14 | Check if the given app has permission to access a memory based on: |
| #15 | 1. Memory state (must be active) |
| #16 | 2. App state (must not be paused) |
| #17 | 3. App-specific access controls |
| #18 | |
| #19 | Args: |
| #20 | db: Database session |
| #21 | memory: Memory object to check access for |
| #22 | app_id: Optional app ID to check permissions for |
| #23 | |
| #24 | Returns: |
| #25 | bool: True if access is allowed, False otherwise |
| #26 | """ |
| #27 | # Check if memory is active |
| #28 | if memory.state != MemoryState.active: |
| #29 | return False |
| #30 | |
| #31 | # If no app_id provided, only check memory state |
| #32 | if not app_id: |
| #33 | return True |
| #34 | |
| #35 | # Check if app exists and is active |
| #36 | app = db.query(App).filter(App.id == app_id).first() |
| #37 | if not app: |
| #38 | return False |
| #39 | |
| #40 | # Check if app is paused/inactive |
| #41 | if not app.is_active: |
| #42 | return False |
| #43 | |
| #44 | # Check app-specific access controls |
| #45 | from app.routers.memories import get_accessible_memory_ids |
| #46 | accessible_memory_ids = get_accessible_memory_ids(db, app_id) |
| #47 | |
| #48 | # If accessible_memory_ids is None, all memories are accessible |
| #49 | if accessible_memory_ids is None: |
| #50 | return True |
| #51 | |
| #52 | # Check if memory is in the accessible set |
| #53 | return memory.id in accessible_memory_ids |
| #54 |