mirror of https://gitlab.com/litecord/litecord.git
Compare commits
No commits in common. "bb8621ba7259ba6232542ea99474224a04cb486c" and "febdee5bd93c6e49885b76db8311cf7f05ee017f" have entirely different histories.
bb8621ba72
...
febdee5bd9
|
|
@ -48,9 +48,6 @@ class Config:
|
|||
# Postgres credentials
|
||||
POSTGRES = {}
|
||||
|
||||
ADMIN_ID = None
|
||||
ADMIN_TOKEN = None
|
||||
|
||||
|
||||
class Development(Config):
|
||||
DEBUG = True
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
MODE = "Development"
|
||||
|
||||
|
||||
|
|
@ -68,13 +65,10 @@ class Config:
|
|||
|
||||
#: Postgres credentials
|
||||
POSTGRES = {}
|
||||
|
||||
|
||||
#: Shared secret for LVSP
|
||||
LVSP_SECRET = ""
|
||||
|
||||
ADMIN_ID = None
|
||||
ADMIN_TOKEN = None
|
||||
|
||||
|
||||
class Development(Config):
|
||||
DEBUG = True
|
||||
|
|
@ -86,12 +80,6 @@ class Development(Config):
|
|||
"database": "litecord",
|
||||
}
|
||||
|
||||
ADMIN_ID = os.getenv("ADMIN_ID")
|
||||
ADMIN_TOKEN = os.getenv("ADMIN_TOKEN")
|
||||
|
||||
if ADMIN_ID is not None:
|
||||
ADMIN_ID = int(ADMIN_ID)
|
||||
|
||||
|
||||
class Production(Config):
|
||||
DEBUG = False
|
||||
|
|
@ -103,6 +91,3 @@ class Production(Config):
|
|||
"password": "some_production_password",
|
||||
"database": "litecord_or_anything_else_really",
|
||||
}
|
||||
|
||||
ADMIN_TOKEN = None
|
||||
ADMIN_ID = None
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
import base64
|
||||
import binascii
|
||||
from hmac import compare_digest
|
||||
|
||||
import bcrypt
|
||||
from itsdangerous import TimestampSigner, BadSignature
|
||||
|
|
@ -48,11 +47,6 @@ async def raw_token_check(token: str, db=None) -> int:
|
|||
Forbidden
|
||||
If token validation fails.
|
||||
"""
|
||||
if app.config["ADMIN_TOKEN"] is not None and compare_digest(
|
||||
token, app.config["ADMIN_TOKEN"]
|
||||
):
|
||||
return app.config["ADMIN_ID"]
|
||||
|
||||
db = db or app.db
|
||||
|
||||
# just try by fragments instead of
|
||||
|
|
@ -127,8 +121,6 @@ async def token_check() -> int:
|
|||
async def admin_check() -> int:
|
||||
"""Check if the user is an admin."""
|
||||
user_id = await token_check()
|
||||
if user_id == app.config["ADMIN_ID"]:
|
||||
return user_id
|
||||
|
||||
flags = await app.db.fetchval(
|
||||
"""
|
||||
|
|
|
|||
15
run.py
15
run.py
|
|
@ -122,22 +122,7 @@ redirect_logging()
|
|||
|
||||
def make_app():
|
||||
app = Quart(__name__)
|
||||
|
||||
app.config.from_object(f"config.{config.MODE}")
|
||||
|
||||
admin_id, admin_token = app.config["ADMIN_ID"], app.config["ADMIN_TOKEN"]
|
||||
if None in {admin_id, admin_token} and not admin_id == admin_token:
|
||||
log.warning(
|
||||
"Not both admin ID ({}) and token ({}) configured; ignoring",
|
||||
admin_id,
|
||||
admin_token,
|
||||
)
|
||||
admin_id = admin_token = None
|
||||
|
||||
# update config if the variables were updated
|
||||
app.config["ADMIN_ID"] = admin_id
|
||||
app.config["ADMIN_TOKEN"] = admin_token
|
||||
|
||||
is_debug = app.config.get("DEBUG", False)
|
||||
app.debug = is_debug
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue