Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #1373 #1375

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5,10 +7,20 @@

key = get_config("ENCRYPTION_KEY")
if key is None:
raise Exception("Encryption key not found in config file.")

Check warning on line 10 in superagi/helper/encyption_helper.py

View check run for this annotation

Codecov / codecov/patch

superagi/helper/encyption_helper.py#L10

Added line #L10 was not covered by tests

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

Check warning on line 13 in superagi/helper/encyption_helper.py

View check run for this annotation

Codecov / codecov/patch

superagi/helper/encyption_helper.py#L13

Added line #L13 was not covered by tests

# 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
Loading