Skip to content

Commit

Permalink
refactor(backend): Rename & move IntegrationCredentialsStore to bac…
Browse files Browse the repository at this point in the history
…kend (#8648)

- Move `autogpt_libs.supabase_integration_credentials_store` into
`backend`
   - `.store` -> `backend.integrations.credentials_store`
   - `.types` -> added to `backend.data.model`
- Rename `SupabaseIntegrationCredentialsStore` to
`IntegrationCredentialsStore`

We wanted to get a few security things in quickly in #8403 and had to
make some compromises to do so. This picks those up and fixes them.

- Resolves #8540

### 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:
  <!-- Put your test plan here: -->

---------

Co-authored-by: Reinier van der Leer <[email protected]>
Co-authored-by: Aarushi <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2024
1 parent 63af42d commit 75f9b07
Show file tree
Hide file tree
Showing 42 changed files with 246 additions and 187 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
from typing import Literal

import replicate
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr
from replicate.helpers import FileOutput

from backend.data.block import Block, BlockCategory, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)


class ImageSize(str, Enum):
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/ai_music_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
from typing import Literal

import replicate
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
from enum import Enum
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.util.request import requests

TEST_CREDENTIALS = APIKeyCredentials(
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

import aiohttp
import discord
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)

DiscordCredentials = CredentialsMetaInput[Literal["discord"], Literal["api_key"]]

Expand Down
9 changes: 5 additions & 4 deletions autogpt_platform/backend/backend/blocks/github/_auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import (
from pydantic import SecretStr

from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
OAuth2Credentials,
)
from pydantic import SecretStr

from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.util.settings import Secrets

secrets = Secrets()
Expand Down
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/blocks/google/_auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import OAuth2Credentials
from pydantic import SecretStr

from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.data.model import CredentialsField, CredentialsMetaInput, OAuth2Credentials
from backend.util.settings import Secrets

# --8<-- [start:GoogleOAuthIsConfigured]
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/google_maps.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from typing import Literal

import googlemaps
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import BaseModel, SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)

TEST_CREDENTIALS = APIKeyCredentials(
id="01234567-89ab-cdef-0123-456789abcdef",
Expand Down
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/blocks/hubspot/_auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.data.model import APIKeyCredentials, CredentialsField, CredentialsMetaInput

HubSpotCredentials = APIKeyCredentials
HubSpotCredentialsInput = CredentialsMetaInput[
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/ideogram.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from enum import Enum
from typing import Any, Dict, Literal, Optional

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr
from requests.exceptions import RequestException

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.util.request import requests

TEST_CREDENTIALS = APIKeyCredentials(
Expand Down
3 changes: 1 addition & 2 deletions autogpt_platform/backend/backend/blocks/jina/_auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.model import CredentialsField, CredentialsMetaInput
from backend.data.model import APIKeyCredentials, CredentialsField, CredentialsMetaInput

JinaCredentials = APIKeyCredentials
JinaCredentialsInput = CredentialsMetaInput[
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, List, Literal, NamedTuple

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

if TYPE_CHECKING:
Expand All @@ -17,7 +16,12 @@
from groq import Groq

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.util import json
from backend.util.settings import BehaveAs, Settings

Expand Down
2 changes: 1 addition & 1 deletion autogpt_platform/backend/backend/blocks/medium.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from enum import Enum
from typing import List, Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import (
APIKeyCredentials,
BlockSecret,
CredentialsField,
CredentialsMetaInput,
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/pinecone.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import uuid
from typing import Any, Literal

from autogpt_libs.supabase_integration_credentials_store import APIKeyCredentials
from pinecone import Pinecone, ServerlessSpec

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)

PineconeCredentials = APIKeyCredentials
PineconeCredentialsInput = CredentialsMetaInput[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
from typing import Literal

import replicate
from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr
from replicate.helpers import FileOutput

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)

TEST_CREDENTIALS = APIKeyCredentials(
id="01234567-89ab-cdef-0123-456789abcdef",
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/search.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Literal
from urllib.parse import quote

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.blocks.helpers.http import GetRequest
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)


class GetWikipediaSummaryBlock(Block, GetRequest):
Expand Down
8 changes: 6 additions & 2 deletions autogpt_platform/backend/backend/blocks/talking_head.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import time
from typing import Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.util.request import requests

TEST_CREDENTIALS = APIKeyCredentials(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from typing import Any, Literal

from autogpt_libs.supabase_integration_credentials_store.types import APIKeyCredentials
from pydantic import SecretStr

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.util.request import requests

TEST_CREDENTIALS = APIKeyCredentials(
Expand Down
10 changes: 10 additions & 0 deletions autogpt_platform/backend/backend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def stop():
print("Server Stopped")


@main.command()
def gen_encrypt_key():
"""
Generate a new encryption key
"""
from cryptography.fernet import Fernet

print(Fernet.generate_key().decode())


@click.group()
def test():
"""
Expand Down
Empty file.
Loading

0 comments on commit 75f9b07

Please sign in to comment.