migrated to poetry; updated all packages
This commit is contained in:
@@ -3,19 +3,18 @@
|
||||
Backend base module
|
||||
"""
|
||||
import logging
|
||||
from io import StringIO
|
||||
from logging.config import dictConfig
|
||||
from logging.handlers import MemoryHandler
|
||||
from typing import Union
|
||||
|
||||
import coloredlogs as coloredlogs
|
||||
import coloredlogs
|
||||
import jwt
|
||||
import requests
|
||||
from flask import Flask, jsonify
|
||||
from flask_httpauth import HTTPTokenAuth, HTTPBasicAuth, MultiAuth
|
||||
from flask_jwt_extended import JWTManager, decode_token
|
||||
from flask_login import LoginManager
|
||||
from flask_restplus import abort
|
||||
from flask_restx import abort
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_cors import CORS
|
||||
from backend.config import Config
|
||||
@@ -109,11 +108,11 @@ class LrcException(Exception):
|
||||
|
||||
def __repr__(self):
|
||||
if self.type is None:
|
||||
msg = "LRC Exception: \"{}\"".format(', '.join(super().args))
|
||||
msg = f"LRC Exception: \"{', '.join(super().args)}\""
|
||||
else:
|
||||
msg = "LRC Exception: (original Exception: {}) \"{}\"".format(self.type, ', '.join(super().args))
|
||||
msg = f"LRC Exception: (original Exception: {self.type}) \"{', '.join(super().args)}\""
|
||||
if self.html_code is not None:
|
||||
msg += " (HTML Code: {})".format(self.html_code)
|
||||
msg += f" (HTML Code: {self.html_code})"
|
||||
return msg
|
||||
|
||||
def __str__(self):
|
||||
@@ -135,7 +134,7 @@ jwt_auth = HTTPTokenAuth('Bearer')
|
||||
|
||||
@jwt_extended.invalid_token_loader
|
||||
def unauthorized_jwt(token):
|
||||
main_logger.info("Unauthorized access; invalid token provided: {}".format(token))
|
||||
main_logger.info("Unauthorized access; invalid token provided: %s", token)
|
||||
abort(401)
|
||||
|
||||
|
||||
@@ -147,10 +146,10 @@ def verify_token(token):
|
||||
try:
|
||||
decoded = decode_token(token)
|
||||
except jwt.exceptions.DecodeError as e:
|
||||
app.logger.warn("Could not verify token: {}".format(str(e)))
|
||||
app.logger.warning("Could not verify token: %s", str(e))
|
||||
return False
|
||||
except jwt.exceptions.ExpiredSignatureError as e:
|
||||
app.logger.warn("Could not verify token: {}".format(str(e)))
|
||||
app.logger.warning("Could not verify token: %s", str(e))
|
||||
return False
|
||||
app.logger.info(decoded)
|
||||
return True
|
||||
@@ -164,20 +163,22 @@ from backend.auth import oidc_auth, auth_bp
|
||||
try:
|
||||
oidc_auth.init_app(app)
|
||||
except requests.exceptions.ConnectionError as err:
|
||||
app.logger.error("Could not connect to OIDC!!", err)
|
||||
app.logger.exception("Could not connect to OIDC!!", exc_info=err)
|
||||
|
||||
# oidc_multi_auth = MultiAuth(oidc_auth, jwt_auth) <- can't work as OIDCAuthentication not implementing HTTPAuth
|
||||
|
||||
from .serve_frontend import fe_bp
|
||||
#from .serve_frontend import fe_bp
|
||||
from .api import auth_api_bp, api_v1, api_bp
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(auth_api_bp)
|
||||
app.register_blueprint(api_bp)
|
||||
app.register_blueprint(fe_bp)
|
||||
|
||||
CORS(app)
|
||||
CORS(api_bp)
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(auth_api_bp)
|
||||
app.register_blueprint(api_bp)
|
||||
#app.register_blueprint(fe_bp)
|
||||
|
||||
|
||||
|
||||
# Fix flask-restplus by duck typing error handlers
|
||||
jwt_extended._set_error_handler_callbacks(api_v1)
|
||||
|
||||
Reference in New Issue
Block a user