add flag to disable microsoft login

This commit is contained in:
mcbloch 2022-04-20 01:34:19 +02:00
parent da88d807d1
commit 841c3d5fb8
3 changed files with 18 additions and 6 deletions

View file

@ -16,6 +16,8 @@ from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Server
from auth.login import init_login
from markupsafe import Markup
from config import Configuration
from models import db
from models.anonymous_user import AnonymouseUser
from utils import euro_string, price_range_string
@ -108,8 +110,9 @@ def add_routes(application: Flask) -> None:
application.register_blueprint(order_bp, url_prefix="/order")
application.register_blueprint(stats_blueprint, url_prefix="/stats")
application.register_blueprint(auth_bp, url_prefix="/")
application.register_blueprint(auth_microsoft_bp,
url_prefix="/users/auth/microsoft_graph_auth") # "/auth/microsoft")
if Configuration.ENABLE_MICROSOFT_AUTH:
application.register_blueprint(auth_microsoft_bp,
url_prefix="/users/auth/microsoft_graph_auth") # "/auth/microsoft")
application.register_blueprint(auth_zeus_bp, url_prefix="/auth/zeus")
if application.debug:
@ -167,6 +170,10 @@ def create_app():
add_routes(app)
add_template_filters(app)
@app.context_processor
def inject_config():
return dict(configuration=Configuration)
return app_manager

View file

@ -14,5 +14,7 @@ class Configuration:
LOGFILE = "haldis.log"
ZEUS_KEY = "tomtest"
ZEUS_SECRET = "blargh"
ENABLE_MICROSOFT_AUTH = False
MICROSOFT_AUTH_ID = ""
MICROSOFT_AUTH_SECRET = ""

View file

@ -63,7 +63,8 @@
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@ -81,7 +82,9 @@
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous() %}
<li><a href="{{ url_for('auth_microsoft_bp.login') }}">Login with Microsoft</a></li>
{% if configuration.ENABLE_MICROSOFT_AUTH %}
<li><a href="{{ url_for('auth_microsoft_bp.login') }}">Login with Microsoft</a></li>
{% endif %}
<li><a href="{{ url_for('auth_zeus_bp.login') }}">Login with Zeus</a></li>
{% else %}
<li><a href="{{ url_for('general_bp.profile') }}">{{ current_user.username }}</a></li>
@ -97,8 +100,8 @@
{{ utils.flashed_messages(container=True) }}
<div class="container main">
{% block container -%}
{%- endblock %}
{% block container -%}
{%- endblock %}
</div>
<footer>