mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-04 18:33:10 +02:00
PREFER_SECURE_URLS, get rid of FORCE_HTTPS hacks.
This commit is contained in:
committed by
fiatjaf
parent
39cd96594e
commit
098089af75
@@ -5,8 +5,6 @@ from lnurl.types import LnurlPayMetadata
|
|||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
from lnbits.settings import FORCE_HTTPS
|
|
||||||
|
|
||||||
|
|
||||||
class PayLink(NamedTuple):
|
class PayLink(NamedTuple):
|
||||||
id: str
|
id: str
|
||||||
@@ -23,8 +21,7 @@ class PayLink(NamedTuple):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def lnurl(self) -> Lnurl:
|
def lnurl(self) -> Lnurl:
|
||||||
scheme = "https" if FORCE_HTTPS else None
|
url = url_for("lnurlp.api_lnurl_response", link_id=self.id, _external=True)
|
||||||
url = url_for("lnurlp.api_lnurl_response", link_id=self.id, _external=True, _scheme=scheme)
|
|
||||||
return lnurl_encode(url)
|
return lnurl_encode(url)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -7,7 +7,6 @@ from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl
|
|||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
from lnbits.core.services import create_invoice
|
from lnbits.core.services import create_invoice
|
||||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||||
from lnbits.settings import FORCE_HTTPS
|
|
||||||
|
|
||||||
from lnbits.extensions.lnurlp import lnurlp_ext
|
from lnbits.extensions.lnurlp import lnurlp_ext
|
||||||
from .crud import (
|
from .crud import (
|
||||||
@@ -102,8 +101,7 @@ async def api_lnurl_response(link_id):
|
|||||||
if not link:
|
if not link:
|
||||||
return jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}), HTTPStatus.OK
|
return jsonify({"status": "ERROR", "reason": "LNURL-pay not found."}), HTTPStatus.OK
|
||||||
|
|
||||||
scheme = "https" if FORCE_HTTPS else None
|
url = url_for("lnurlp.api_lnurl_callback", link_id=link.id, _external=True)
|
||||||
url = url_for("lnurlp.api_lnurl_callback", link_id=link.id, _external=True, _scheme=scheme)
|
|
||||||
|
|
||||||
resp = LnurlPayResponse(
|
resp = LnurlPayResponse(
|
||||||
callback=url,
|
callback=url,
|
||||||
|
@@ -3,7 +3,6 @@ from lnurl import Lnurl, LnurlWithdrawResponse, encode as lnurl_encode
|
|||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
import shortuuid # type: ignore
|
import shortuuid # type: ignore
|
||||||
from lnbits.settings import FORCE_HTTPS
|
|
||||||
|
|
||||||
|
|
||||||
class WithdrawLink(NamedTuple):
|
class WithdrawLink(NamedTuple):
|
||||||
@@ -35,7 +34,6 @@ class WithdrawLink(NamedTuple):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def lnurl(self) -> Lnurl:
|
def lnurl(self) -> Lnurl:
|
||||||
scheme = "https" if FORCE_HTTPS else None
|
|
||||||
if self.is_unique:
|
if self.is_unique:
|
||||||
usescssv = self.usescsv.split(",")
|
usescssv = self.usescsv.split(",")
|
||||||
tohash = self.id + self.unique_hash + usescssv[self.number]
|
tohash = self.id + self.unique_hash + usescssv[self.number]
|
||||||
@@ -45,18 +43,15 @@ class WithdrawLink(NamedTuple):
|
|||||||
unique_hash=self.unique_hash,
|
unique_hash=self.unique_hash,
|
||||||
id_unique_hash=multihash,
|
id_unique_hash=multihash,
|
||||||
_external=True,
|
_external=True,
|
||||||
_scheme=scheme,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
url = url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash, _external=True, _scheme=scheme)
|
url = url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash, _external=True)
|
||||||
|
|
||||||
return lnurl_encode(url)
|
return lnurl_encode(url)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lnurl_response(self) -> LnurlWithdrawResponse:
|
def lnurl_response(self) -> LnurlWithdrawResponse:
|
||||||
scheme = "https" if FORCE_HTTPS else None
|
url = url_for("withdraw.api_lnurl_callback", unique_hash=self.unique_hash, _external=True)
|
||||||
|
|
||||||
url = url_for("withdraw.api_lnurl_callback", unique_hash=self.unique_hash, _external=True, _scheme=scheme)
|
|
||||||
return LnurlWithdrawResponse(
|
return LnurlWithdrawResponse(
|
||||||
callback=url,
|
callback=url,
|
||||||
k1=self.k1,
|
k1=self.k1,
|
||||||
|
@@ -24,5 +24,6 @@ LNBITS_SITE_TITLE = env.str("LNBITS_SITE_TITLE", default="LNbits")
|
|||||||
|
|
||||||
WALLET = wallet_class()
|
WALLET = wallet_class()
|
||||||
DEFAULT_WALLET_NAME = env.str("LNBITS_DEFAULT_WALLET_NAME", default="LNbits wallet")
|
DEFAULT_WALLET_NAME = env.str("LNBITS_DEFAULT_WALLET_NAME", default="LNbits wallet")
|
||||||
FORCE_HTTPS = env.bool("LNBITS_FORCE_HTTPS", default=True)
|
PREFER_SECURE_URLS = env.bool("LNBITS_FORCE_HTTPS", default=True)
|
||||||
|
|
||||||
SERVICE_FEE = env.float("LNBITS_SERVICE_FEE", default=0.0)
|
SERVICE_FEE = env.float("LNBITS_SERVICE_FEE", default=0.0)
|
||||||
|
Reference in New Issue
Block a user