This commit is contained in:
Yusur 2025-06-19 14:58:30 +02:00
parent bc4ea9b101
commit 1c2bd11212
2 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,9 @@
# Changelog
## 0.3.4
- Bug fixes in `.flask_sqlalchemy`
## 0.3.3
- Fixed leftovers in `snowflake` module from unchecked code copying — i.e. `SnowflakeGen.generate_one()` used to require an unused typ= parameter

View file

@ -35,6 +35,7 @@ class FlaskAuthSrc(AuthSrc):
def get_session(self) -> Session:
return self.db.session
def get_token(self):
if request.authorization:
return request.authorization.token
def get_signature(self) -> bytes:
sig = request.headers.get('authorization-signature', None)
@ -51,6 +52,9 @@ def require_auth(cls: type[DeclarativeBase], db: SQLAlchemy) -> Callable[Any, Ca
This looks for a token in the Authorization header, validates it, loads the
appropriate object, and injects it as the user= parameter.
NOTE: the actual decorator to be used on routes is **auth_required()**,
NOT require_auth() which is the **constructor** for it.
cls is a SQLAlchemy table.
db is a flask_sqlalchemy.SQLAlchemy() binding.