Skip to content

Commit

Permalink
Merge pull request #224 from eclecticiq/werkzeug21
Browse files Browse the repository at this point in the history
Make sure werkzeug <2.1 and >=2.1 work correctly with auth
  • Loading branch information
erwin-eiq committed Apr 13, 2022
2 parents 13ddcbd + 5e7a081 commit 78d6ec7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

0.2.4 (2022-04-13)
------------------
* Make sure werkzeug <2.1 and >=2.1 work correctly with auth system

0.2.3 (2021-12-22)
------------------
* Fix bug in multithreaded use of sqlite (`#210 <https://github.com/eclecticiq/OpenTAXII/issues/114>`_ thanks `@rohits144 <https://github.com/rohits144>`_ for the report)
Expand Down
4 changes: 2 additions & 2 deletions opentaxii/management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, request, jsonify, abort
from flask import Blueprint, abort, jsonify, request

from .local import context

Expand All @@ -7,7 +7,7 @@

@management.route('/auth', methods=['POST'])
def auth():
data = request.get_json() or request.form
data = request.get_json(silent=True) or request.form

username = data.get('username')
password = data.get('password')
Expand Down
6 changes: 3 additions & 3 deletions opentaxii/sqldb_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask import _app_ctx_stack
from threading import get_ident

from sqlalchemy import engine, orm
from sqlalchemy.orm.exc import UnmappedClassError

Expand Down Expand Up @@ -44,11 +45,10 @@ def create_scoped_session(self, options=None):

options = options or {}

scopefunc = _app_ctx_stack.__ident_func__
options.setdefault('query_cls', self.Query)

return orm.scoped_session(
self.create_session(options), scopefunc=scopefunc)
self.create_session(options), scopefunc=get_ident)

def create_session(self, options):
return orm.sessionmaker(bind=self.engine, **options)
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[tox]
skipsdist = True
envlist = py{36,37,38,39,py3,ston}-sqlalchemy{13,14}-{sqlite,mysql,mariadb,postgres}, flake8
envlist = py36-sqlalchemy{13,14}-werkzeuglt21-{sqlite,mysql,mariadb,postgres},
py{37,38,39,py3,ston}-sqlalchemy{13,14}-werkzeug{lt21,gte21}-{sqlite,mysql,mariadb,postgres},
flake8

[gh-actions]
python =
Expand All @@ -20,6 +22,8 @@ deps =
postgres-pypy3: -rrequirements-dev-postgres-pypy.txt
sqlalchemy13: sqlalchemy>=1.3,<1.4
sqlalchemy14: sqlalchemy>=1.4,<1.5
werkzeuglt21: werkzeug<2.1
werkzeuggte21: werkzeug>=2.1
setenv =
LC_ALL=en_US.UTF-8
sqlite: DBTYPE=sqlite
Expand Down

0 comments on commit 78d6ec7

Please sign in to comment.