osohq / gitclub

Realistic examples of using Oso in an application for authorization. Built for multiple different backends.
54 stars 16 forks source link

Pin MarkupSafe to 2.0.1 for compatibility with Jinja2 2.x. #48

Closed gsarjeant closed 5 months ago

gsarjeant commented 1 year ago

Fixes osohq/gitclub#47

This fixes the markupsafe errors in the flask-sqlalchemy and flask-sqlalchemy-oso backends while maintaining the current version constraint on Jinja2.

gsarjeant commented 1 year ago

Behavior before change:

❯ make run
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
Collecting flask~=1.1.4 (from -r requirements.txt (line 1))
  Using cached Flask-1.1.4-py2.py3-none-any.whl (94 kB)
Collecting SQLAlchemy~=1.3.20 (from -r requirements.txt (line 2))
  Using cached SQLAlchemy-1.3.24-cp310-cp310-macosx_12_0_arm64.whl
Collecting sqlalchemy-oso==0.25.1 (from -r requirements.txt (line 3))
  Using cached sqlalchemy_oso-0.25.1-py3-none-any.whl (18 kB)
Collecting packaging~=20.9 (from sqlalchemy-oso==0.25.1->-r requirements.txt (line 3))
  Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)
Collecting Werkzeug<2.0,>=0.15 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting Jinja2<3.0,>=2.10.1 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
Collecting itsdangerous<2.0,>=0.24 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting click<8.0,>=5.1 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting MarkupSafe>=0.23 (from Jinja2<3.0,>=2.10.1->flask~=1.1.4->-r requirements.txt (line 1))
  Obtaining dependency information for MarkupSafe>=0.23 from https://files.pythonhosted.org/packages/20/1d/713d443799d935f4d26a4f1510c9e61b1d288592fb869845e5cc92a1e055/MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl.metadata
  Using cached MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl.metadata (3.0 kB)
Collecting pyparsing>=2.0.2 (from packaging~=20.9->sqlalchemy-oso==0.25.1->-r requirements.txt (line 3))
  Obtaining dependency information for pyparsing>=2.0.2 from https://files.pythonhosted.org/packages/39/92/8486ede85fcc088f1b3dba4ce92dd29d126fd96b0008ea213167940a2475/pyparsing-3.1.1-py3-none-any.whl.metadata
  Using cached pyparsing-3.1.1-py3-none-any.whl.metadata (5.1 kB)
Using cached MarkupSafe-2.1.3-cp310-cp310-macosx_10_9_universal2.whl (17 kB)
Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)
Installing collected packages: Werkzeug, SQLAlchemy, pyparsing, MarkupSafe, itsdangerous, click, packaging, Jinja2, sqlalchemy-oso, flask
Successfully installed Jinja2-2.11.3 MarkupSafe-2.1.3 SQLAlchemy-1.3.24 Werkzeug-1.0.1 click-7.1.2 flask-1.1.4 itsdangerous-1.1.0 packaging-20.9 pyparsing-3.1.1 sqlalchemy-oso-0.25.1
touch .make.requirements-install
flask run
Traceback (most recent call last):
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/bin/flask", line 5, in <module>
    from flask.cli import main
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/jinja2/filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/Users/greg/repos/gsarjeant/gitclub/backends/flask-sqlalchemy/venv/lib/python3.10/site-packages/markupsafe/__init__.py)
make: *** [run] Error 1
gsarjeant commented 1 year ago

Behavior after change:

❯ make run
. venv/bin/activate
pip install -r requirements.txt
Collecting flask~=1.1.4 (from -r requirements.txt (line 1))
  Using cached Flask-1.1.4-py2.py3-none-any.whl (94 kB)
Collecting MarkupSafe==2.0.1 (from -r requirements.txt (line 2))
  Using cached MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl (18 kB)
Collecting SQLAlchemy~=1.3.20 (from -r requirements.txt (line 3))
  Using cached SQLAlchemy-1.3.24-cp310-cp310-macosx_12_0_arm64.whl
Collecting sqlalchemy-oso==0.25.1 (from -r requirements.txt (line 4))
  Using cached sqlalchemy_oso-0.25.1-py3-none-any.whl (18 kB)
Collecting packaging~=20.9 (from sqlalchemy-oso==0.25.1->-r requirements.txt (line 4))
  Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)
Collecting Werkzeug<2.0,>=0.15 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting Jinja2<3.0,>=2.10.1 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
Collecting itsdangerous<2.0,>=0.24 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting click<8.0,>=5.1 (from flask~=1.1.4->-r requirements.txt (line 1))
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting pyparsing>=2.0.2 (from packaging~=20.9->sqlalchemy-oso==0.25.1->-r requirements.txt (line 4))
  Obtaining dependency information for pyparsing>=2.0.2 from https://files.pythonhosted.org/packages/39/92/8486ede85fcc088f1b3dba4ce92dd29d126fd96b0008ea213167940a2475/pyparsing-3.1.1-py3-none-any.whl.metadata
  Using cached pyparsing-3.1.1-py3-none-any.whl.metadata (5.1 kB)
Using cached pyparsing-3.1.1-py3-none-any.whl (103 kB)
Installing collected packages: Werkzeug, SQLAlchemy, pyparsing, MarkupSafe, itsdangerous, click, packaging, Jinja2, sqlalchemy-oso, flask
Successfully installed Jinja2-2.11.3 MarkupSafe-2.0.1 SQLAlchemy-1.3.24 Werkzeug-1.0.1 click-7.1.2 flask-1.1.4 itsdangerous-1.1.0 packaging-20.9 pyparsing-3.1.1 sqlalchemy-oso-0.25.1
touch .make.requirements-install
flask run
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
^C