Skip to content

Commit 1fe3551

Browse files
authored
Merge pull request #1086 from skiadas/main
Clarify the usage of ALLOW_INSECURE_LOGIN
2 parents 3b7c0f4 + cc10c86 commit 1fe3551

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

bases/rsptx/web2py_server/applications/runestone/models/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ def _create_access_token(data: dict, expires=None, scopes=None) -> bytes:
703703
# if the ALLOW_INSECURE_LOGIN environment variable is set then do not set
704704
# the httponly, samesite, or secure attributes on the cookie.
705705
# This is useful for testing purposes, but should not be used in production.
706-
707-
if not os.environ.get("ALLOW_INSECURE_LOGIN", request.is_local):
706+
allow_insecure = os.environ.get("ALLOW_INSECURE_LOGIN", "False").lower() in ["yes", "true"]
707+
if not allow_insecure:
708708
response.cookies["access_token"]["httponly"] = True
709709
response.cookies["access_token"]["samesite"] = "None"
710710
response.cookies["access_token"]["secure"] = True

docs/source/environmental_vars.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ There are a number of other variables - none of them are important unless you ar
5252
* ``RUNESTONE_HOST`` *(d)* - this is the canonical host name of the server. It is used to generate links to the server. For development you should just set it to ``localhost``. In production it should be something like ``runestone.academy`` or ``runestone.academy:8000`` if you are running on a non-standard port.
5353
* ``LOAD_BALANCER_HOST`` *(d)* - this is the canonical host name of the server when you are running in production with several workers. It is used to generate links to the server. For development purposes you should not set this variable. In production it should be something like ``runestone.academy`` or ``runestone.academy:8000`` if you are running on a non-standard port. You would typically only need to set this or RUNESTONE_HOST.
5454
* ``NUM_SERVERS`` *(d)* - this is the number of workers you are running. It will default to 1 if not set. This is only important if you are running in production mode, behind a load balancer.
55-
* ``ALLOW_INSECURE_LOGIN`` *(d)* - this is a flag that allows users to log in without HTTPS. This should only be used for development purposes and not in production. This can be set to ``yes`` or ``true`` in the ``docker-compose.yml`` file for the ``runestone`` service. If you are running in production mode, you should **not** set this variable. Note, LTI will not work if this is set.
56-
* ``LTI1P3_PRIVATE_KEY`` *(d)* - this is the private key used for LTI 1.3 authentication. It should be a long random string. You can generate one by running ``openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:2048``.
55+
* ``ALLOW_INSECURE_LOGIN`` *(d)* - this is a flag that allows users to log in without HTTPS. This should only be used for development purposes and not in production. This can be set to ``yes`` or ``true`` in the ``.env``. If you are running in production mode, you should keep this variable set to False. Note, LTI will not work if this is set.
56+
* ``LTI1P3_PRIVATE_KEY`` *(d)* - this is the private key used for LTI 1.3 authentication. It should be a long random string. You can generate one by running ``openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:2048``.
5757
* ``LTI1P3_PUBLIC_KEY`` *(d)* - this is the public key used for LTI 1.3 authentication. You can generate one by running ``openssl rsa -in private.key -pubout -out public.key``. This is used to verify the signature of the LTI 1.3 authentication request.
58-
* ``FERNET_SECRET`` *(d)* - this is the secret used for encrypting and decrypting data. It is required for encrypted columns. You can generate one by running ``openssl rand -base64 32``.
58+
* ``FERNET_SECRET`` *(d)* - this is the secret used for encrypting and decrypting data. It is required for encrypted columns. You can generate one by running ``openssl rand -base64 32``.
5959

6060
.. note:: Host Side Development Notes
6161

sample.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ LTI1P3_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----
8282
MAKE YOUR OWN KEY PAIR AND PASTE PUBLIC KEY HERE
8383
-----END PUBLIC KEY-----"
8484

85-
# Insecure Login
85+
# Insecure Login. Set to True or Yes to enable.
8686
# Warning! Only use this for development, if you are running a server over http
87-
# that is not localhost
88-
# ALLOW_INSECURE_LOGIN = yes
87+
# that is not localhost.
88+
ALLOW_INSECURE_LOGIN = False
8989

9090
# this is used by web2py to decide on how to set the session cookie settings.
9191
# In production you will want to change this to https://
@@ -113,4 +113,4 @@ UVICORN_WORKERS=5
113113
GUNICORN_CMD_ARGS="--workers=3 --log-level 'debug'"
114114

115115
# Set the log level - for production set this to info or higher
116-
LOG_LEVEL=DEBUG
116+
LOG_LEVEL=DEBUG

0 commit comments

Comments
 (0)