Skip to content

Commit

Permalink
fix for #1373 (#1376)
Browse files Browse the repository at this point in the history
* use get_config

* add a check on the key
  • Loading branch information
Fluder-Paradyne authored Nov 29, 2023
1 parent f3de47a commit ab1620d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
PLAIN_OUTPUT: True
REDIS_URL: "localhost:6379"
IS_TESTING: True
ENCRYPTION_KEY: "dummy key"
ENCRYPTION_KEY: "abcdefghijklmnopqrstuvwxyz123456"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
4 changes: 2 additions & 2 deletions config_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ GITHUB_CLIENT_ID:
GITHUB_CLIENT_SECRET:
FRONTEND_URL: "http://localhost:3000"

#ENCRPYTION KEY
ENCRYPTION_KEY: secret
#ENCRPYTION KEY, Replace this with your own key for production
ENCRYPTION_KEY: abcdefghijklmnopqrstuvwxyz123456

#WEAVIATE

Expand Down
12 changes: 12 additions & 0 deletions superagi/helper/encyption_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import base64

from cryptography.fernet import Fernet, InvalidToken, InvalidSignature
from superagi.config.config import get_config
# Generate a key
Expand All @@ -6,9 +8,19 @@
key = get_config("ENCRYPTION_KEY")
if key is None:
raise Exception("Encryption key not found in config file.")

if len(key) != 32:
raise ValueError("Encryption key must be 32 bytes long.")

# Encode the key to UTF-8
key = key.encode(
"utf-8"
)

# base64 encode the key
key = base64.urlsafe_b64encode(key)

# Create a cipher suite
cipher_suite = Fernet(key)


Expand Down

0 comments on commit ab1620d

Please sign in to comment.