From f080c75d6a08a4cd33f78c3881aa9209f6576ea3 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 19 Oct 2023 10:57:52 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20add=20paddi?= =?UTF-8?q?ng=20to=20SECRET=5FKEY=20before=20initializing=20Fernet=20to=20?= =?UTF-8?q?ensure=20it=20has=20the=20correct=20length?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/services/auth/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/services/auth/utils.py b/src/backend/langflow/services/auth/utils.py index 7a27f794d..22fac05a3 100644 --- a/src/backend/langflow/services/auth/utils.py +++ b/src/backend/langflow/services/auth/utils.py @@ -297,10 +297,17 @@ def authenticate_user( return user if verify_password(password, user.password) else None +def add_padding(s): + # Calculate the number of padding characters needed + padding_needed = 4 - len(s) % 4 + return s + "=" * padding_needed + + def get_fernet(settings_service=Depends(get_settings_service)): SECRET_KEY = settings_service.auth_settings.SECRET_KEY # It's important that your secret key is 32 url-safe base64-encoded bytes - fernet = Fernet(SECRET_KEY) + padded_secret_key = add_padding(SECRET_KEY) + fernet = Fernet(padded_secret_key) return fernet From 218788d5dfb83c59825bdccf215770d45b6ffe98 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 19 Oct 2023 10:59:44 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore(Makefile):=20exclude?= =?UTF-8?q?=20alembic=20directory=20from=20ruff=20linting=20to=20avoid=20u?= =?UTF-8?q?nnecessary=20errors=20=F0=9F=94=A7=20chore(Makefile):=20add=20e?= =?UTF-8?q?xclusion=20of=20alembic=20directory=20from=20ruff=20linting=20t?= =?UTF-8?q?o=20improve=20linting=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 798dcfa00..af1765feb 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ endif format: poetry run black . - poetry run ruff . --fix + poetry run ruff . --fix --exclude src/backend/langflow/alembic cd src/frontend && npm run format lint: