| 1 |
# Copyright 2021-2024 by J. Christopher Wagner (jwag). All rights reserved. |
| 2 |
|
| 3 |
import typing as t |
| 4 |
|
| 5 |
from flask import current_app |
| 6 |
from werkzeug.local import LocalProxy |
| 7 |
|
| 8 |
if t.TYPE_CHECKING: # pragma: no cover |
| 9 |
from passlib.context import CryptContext |
| 10 |
from .core import Security, UserDatastore |
| 11 |
|
| 12 |
# Convenient references |
| 13 |
_security: "Security" = LocalProxy( # type: ignore |
| 14 |
lambda: current_app.extensions["security"] |
| 15 |
) |
| 16 |
|
| 17 |
_datastore: "UserDatastore" = LocalProxy(lambda: _security.datastore) # type: ignore |
| 18 |
|
| 19 |
_pwd_context: "CryptContext" = LocalProxy(lambda: _security.pwd_context) # type: ignore |
| 20 |
|
| 21 |
_hashing_context: "CryptContext" = LocalProxy( # type: ignore |
| 22 |
lambda: _security.hashing_context |
| 23 |
) |
| 24 |
|
| 25 |
DecoratedView = t.Callable[..., t.Any] |