diff --git a/schilder2000/__init__.py b/schilder2000/__init__.py index 159073c92fbfb8708dfbf40d52366cd71f8bec99..a4c9fa3c280fa85c31ba2ee7b03563c4a1572290 100644 --- a/schilder2000/__init__.py +++ b/schilder2000/__init__.py @@ -27,15 +27,16 @@ def create_app(): csrf.init_app(app) - app.config["MULTIPASS_LOGIN_FORM_TEMPLATE"] = "login.html.j2" - app.config["MULTIPASS_LOGIN_SELECTOR_TEMPLATE"] = "login_select.html.j2" - app.config["MULTIPASS_SUCCESS_ENDPOINT"] = "views.index" - multipass.identity_handler(identity_handler) - multipass.init_app(app) + if app.config["REQUIRE_LOGIN"]: + app.config["MULTIPASS_LOGIN_FORM_TEMPLATE"] = "login.html.j2" + app.config["MULTIPASS_LOGIN_SELECTOR_TEMPLATE"] = "login_select.html.j2" + app.config["MULTIPASS_SUCCESS_ENDPOINT"] = "views.index" + multipass.identity_handler(identity_handler) + multipass.init_app(app) - for k, v in app.view_functions.items(): - if k.startswith("_flaskmultipass_saml_acs_"): - csrf.exempt(v) + for k, v in app.view_functions.items(): + if k.startswith("_flaskmultipass_saml_acs_"): + csrf.exempt(v) app.config.update( { @@ -50,14 +51,16 @@ def create_app(): from . import views - views.bp.before_request(require_login) + if app.config["REQUIRE_LOGIN"]: + views.bp.before_request(require_login) app.register_blueprint(views.bp) from . import instance instance.bp.static_folder = instance_path / "static" instance.bp.template_folder = instance_path / "templates" - instance.bp.before_request(require_login) + if app.config["REQUIRE_LOGIN"]: + instance.bp.before_request(require_login) app.register_blueprint(instance.bp) return app