Skip to content

Sync homepage directive with JWT path #187

Closed
campb303 opened this issue Feb 9, 2021 · 4 comments
Closed

Sync homepage directive with JWT path #187

campb303 opened this issue Feb 9, 2021 · 4 comments
Assignees
Labels
bug An issue that results in webqueue2 breaking
Projects

Comments

@campb303
Copy link
Collaborator

campb303 commented Feb 9, 2021

#171 will implement arbitrary subdirectory loading by prepending links and routes with the value from the homepage directive in package.json at build time.

For refresh tokens to work in arbitrary subfolders, the JWT_REFRESH_COOKIE_PATH of Flask JWT Extended needs to contain the same value as the homepage directive. Otherwise, users can login but cannot refresh their tokens.

@campb303 campb303 added api bug An issue that results in webqueue2 breaking labels Feb 9, 2021
@campb303 campb303 added this to the v1-proof-of-concept milestone Feb 9, 2021
@campb303
Copy link
Collaborator Author

campb303 commented Mar 8, 2021

With the API moving to its own repo and being installed as a standalone package, this should be managed via environment variable files. Does the dotenv support loading files from specific paths? If so, the same environment variable from the frontend can be used to sync this together.

A potential fallback is that this configuration is managed through deployment scripts.

@campb303 campb303 added this to To do in v1.0 Mar 8, 2021
@benne238
Copy link
Collaborator

benne238 commented Mar 8, 2021

dotenv

Pulled directly from https://pypi.org/project/python-dotenv/ :

Add the following code to your settings.py:

# settings.py
from dotenv import load_dotenv
load_dotenv()

# OR, the same with increased verbosity
load_dotenv(verbose=True)

# OR, explicitly providing path to '.env'
from pathlib import Path  # Python 3.6+ only
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)

It looks like when calling load_dotenv, it is possible to specify the path to the .env file, in the example above, it just so happens to be the same directory that settings.py is in: ./.env.

This particular example uses settings.py as the script that loads the .env file, but I think It is far more useful to us if setup.py makes use of load_dotenv, this way some of the variables from the frontend and the backend can be synchrounous

Possible issues

There will have to be .env file present on the target device in order for the setup.py to work. While this is an assumption, if it is something that can be reasonably maintained and be present every time the package needs to be installed, then there shouldn't be issues when trying to install the package. However, the .env file must be present, otherwise, the package installation will fail, or the package will have to rely on a set of default values, neither option being significantly better than the other.

@campb303
Copy link
Collaborator Author

Using dotenv in setup.py isn't reliable because dotenv isn't part of the standard library. Instead, the configuration options for the API should be exposed in a similar fashion to Flask apps. dotenv can be used by the client to set these exposed values.

@campb303
Copy link
Collaborator Author

Moved to ECN/webqueue2-api#14

v1.0 automation moved this from To do to Done Mar 17, 2021
Sign in to join this conversation on GitHub.
Labels
bug An issue that results in webqueue2 breaking
Projects
No open projects
v1.0
  
Done
Development

No branches or pull requests

2 participants