feat: allow disabling extensions at installation level
This commit is contained in:
parent
f12f52db2d
commit
e1c5e970c4
|
@ -4,6 +4,7 @@ FLASK_ENV=development
|
||||||
LNBITS_SITE_TITLE=LNbits
|
LNBITS_SITE_TITLE=LNbits
|
||||||
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
|
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
|
||||||
LNBITS_DATA_FOLDER="/your_custom_data_folder"
|
LNBITS_DATA_FOLDER="/your_custom_data_folder"
|
||||||
|
LNBITS_DISABLED_EXTENSIONS="amilk,events"
|
||||||
LNBITS_SERVICE_FEE="0.0"
|
LNBITS_SERVICE_FEE="0.0"
|
||||||
LNBITS_WITH_ONION=0
|
LNBITS_WITH_ONION=0
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,11 @@ from .core import core_app, migrations as core_migrations
|
||||||
from .helpers import ExtensionManager
|
from .helpers import ExtensionManager
|
||||||
|
|
||||||
|
|
||||||
|
disabled_extensions = getenv("LNBITS_DISABLED_EXTENSIONS", "").split(",")
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
||||||
valid_extensions = [ext for ext in ExtensionManager().extensions if ext.is_valid]
|
valid_extensions = [ext for ext in ExtensionManager(disabled=disabled_extensions).extensions if ext.is_valid]
|
||||||
|
|
||||||
|
|
||||||
# optimization & security
|
# optimization & security
|
||||||
|
|
|
@ -17,14 +17,15 @@ class Extension(NamedTuple):
|
||||||
|
|
||||||
|
|
||||||
class ExtensionManager:
|
class ExtensionManager:
|
||||||
def __init__(self):
|
def __init__(self, *, disabled: list = []):
|
||||||
|
self._disabled = disabled
|
||||||
self._extension_folders: List[str] = [x[1] for x in os.walk(os.path.join(LNBITS_PATH, "extensions"))][0]
|
self._extension_folders: List[str] = [x[1] for x in os.walk(os.path.join(LNBITS_PATH, "extensions"))][0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extensions(self) -> List[Extension]:
|
def extensions(self) -> List[Extension]:
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for extension in self._extension_folders:
|
for extension in [ext for ext in self._extension_folders if ext not in self._disabled]:
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(LNBITS_PATH, "extensions", extension, "config.json")) as json_file:
|
with open(os.path.join(LNBITS_PATH, "extensions", extension, "config.json")) as json_file:
|
||||||
config = json.load(json_file)
|
config = json.load(json_file)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user