Skip to content

Commit cce9a8a

Browse files
committed
fix(jwt): display jwt env variable error to user
1 parent 9582fa5 commit cce9a8a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ export TG_DECRYPT_SALT=<encryption_salt>
135135
export TESTGEN_USERNAME=<username>
136136
export TESTGEN_PASSWORD=<password>
137137

138+
# Set an arbitrary base64-encoded string to be used for signing authentication tokens
139+
export TG_JWT_HASHING_KEY=<base64_key>
140+
138141
# Set an accessible path for storing application logs
139142
export TESTGEN_LOG_FILE_PATH=<path_for_logs>
140143
```

docs/local_development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Create a `local.env` file with the following environment variables, replacing th
6464
export TESTGEN_DEBUG=yes
6565
export TESTGEN_LOG_TO_FILE=no
6666
export TG_ANALYTICS=no
67+
export TG_JWT_HASHING_KEY=<base64_key>
6768
export TESTGEN_USERNAME=<username>
6869
export TESTGEN_PASSWORD=<password>
6970
export TG_DECRYPT_SALT=<decrypt_salt>

testgen/ui/services/user_session_service.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ def _get_jwt_hashing_key() -> bytes:
2424
try:
2525
return base64.b64decode(settings.JWT_HASHING_KEY_B64.encode("ascii"))
2626
except Exception as e:
27-
raise ValueError(
28-
"Error reading the JWT signing key from settings. Make sure you have a valid base 64 "
29-
"string assigned to the TG_JWT_HASHING_KEY environment variable."
30-
) from e
27+
st.error(
28+
"Error reading the JWT signing key from settings.\n\n Make sure you have a valid "
29+
"base64 string assigned to the TG_JWT_HASHING_KEY environment variable."
30+
)
31+
st.stop()
3132

3233

3334
def load_user_session() -> None:

0 commit comments

Comments
 (0)