flaschengeist/geruecht/__init__.py

60 lines
1.9 KiB
Python
Raw Normal View History

2019-04-17 12:46:46 +00:00
""" Server-package
Initialize app, cors, database and bcrypt (for passwordhashing) and added it to the application.
Initialize also a singelton for the AccesTokenControler and start the Thread.
"""
from .logger import getDebugLogger
2020-02-26 22:03:02 +00:00
from geruecht.controller import dbConfig, ldapConfig
from flask_mysqldb import MySQL
from flask_ldapconn import LDAPConn
2020-06-28 10:59:06 +00:00
import ssl
DEBUG = getDebugLogger()
2020-03-09 18:54:51 +00:00
DEBUG.info("Initialize App")
2019-04-17 12:46:46 +00:00
2019-04-11 21:56:55 +00:00
from flask import Flask
from flask_cors import CORS
2019-01-13 19:07:46 +00:00
2020-03-09 18:54:51 +00:00
DEBUG.info("Build APP")
2019-01-13 19:07:46 +00:00
app = Flask(__name__)
CORS(app)
app.config['SECRET_KEY'] = '0a657b97ef546da90b2db91862ad4e29'
app.config['MYSQL_HOST'] = dbConfig['URL']
app.config['MYSQL_USER'] = dbConfig['user']
app.config['MYSQL_PASSWORD'] = dbConfig['passwd']
app.config['MYSQL_DB'] = dbConfig['database']
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
2020-02-26 22:03:02 +00:00
app.config['LDAP_SERVER'] = ldapConfig['URL']
2020-06-28 10:59:06 +00:00
app.config['LDAP_PORT'] = ldapConfig['PORT']
if ldapConfig['BIND_DN']:
app.config['LDAP_BINDDN'] = ldapConfig['BIND_DN']
else:
app.config['LDAP_BINDDN'] = ldapConfig['DN']
if ldapConfig['BIND_SECRET']:
app.config['LDAP_SECRET'] = ldapConfig['BIND_SECRET']
app.config['LDAP_USE_TLS'] = False
2020-06-28 10:59:06 +00:00
app.config['LDAP_USE_SSL'] = ldapConfig['SSL']
app.config['LDAP_TLS_VERSION'] = ssl.PROTOCOL_TLSv1_2
app.config['LDAP_REQUIRE_CERT'] = ssl.CERT_NONE
app.config['FORCE_ATTRIBUTE_VALUE_AS_LIST'] = True
ldap = LDAPConn(app)
db = MySQL(app)
2019-04-11 21:56:55 +00:00
from geruecht import routes
2019-12-22 21:27:39 +00:00
from geruecht.baruser.routes import baruser
from geruecht.finanzer.routes import finanzer
2020-01-17 00:05:58 +00:00
from geruecht.user.routes import user
2020-01-18 22:31:49 +00:00
from geruecht.vorstand.routes import vorstand
from geruecht.gastro.routes import gastrouser
2020-06-17 18:25:29 +00:00
from geruecht.registration_route import registration
2020-03-09 18:54:51 +00:00
DEBUG.info("Registrate bluebrints")
2019-12-22 21:27:39 +00:00
app.register_blueprint(baruser)
app.register_blueprint(finanzer)
2020-01-17 00:05:58 +00:00
app.register_blueprint(user)
2020-01-18 22:31:49 +00:00
app.register_blueprint(vorstand)
app.register_blueprint(gastrouser)
2020-06-17 18:25:29 +00:00
app.register_blueprint(registration)