diff --git a/images/pic1.png b/images/pic1.png index 0fefcff..5ff953b 100644 Binary files a/images/pic1.png and b/images/pic1.png differ diff --git a/src/core/__init__.py b/src/core/__init__.py index 6d395e1..6964aca 100644 --- a/src/core/__init__.py +++ b/src/core/__init__.py @@ -4,17 +4,21 @@ import os # Lib imports from flask import Flask - #OIDC Login path + # OIDC Login path from flask_oidc import OpenIDConnect - # Flask Login Path + # Flask Login Path from flask_bcrypt import Bcrypt -from flask_login import current_user, login_user, logout_user, LoginManager +from flask_login import current_user +from flask_login import login_user +from flask_login import logout_user +from flask_login import LoginManager # Apoplication imports from core.utils import Logger + app = Flask(__name__) app.config.from_object("core.config.Config") @@ -23,6 +27,7 @@ login_manager = LoginManager(app) bcrypt = Bcrypt(app) logger = Logger().get_logger() + def oidc_loggedin(): return oidc.user_loggedin @@ -33,15 +38,19 @@ def oidc_isAdmin(): return True return False + app.jinja_env.globals['oidc_loggedin'] = oidc_loggedin app.jinja_env.globals['oidc_isAdmin'] = oidc_isAdmin app.jinja_env.globals['TITLE'] = app.config["TITLE"] -from core.models import db, User +from core.models import db +from core.models import User + db.init_app(app) with app.app_context(): db.create_all() -from core.forms import RegisterForm, LoginForm +from core.forms import RegisterForm +from core.forms import LoginForm from core import routes diff --git a/src/core/client_secrets.json b/src/core/client_secrets.json index 2493f47..413e32d 100644 --- a/src/core/client_secrets.json +++ b/src/core/client_secrets.json @@ -1,14 +1,14 @@ { "web": { - "auth_uri": "http://localhost:8080/auth/realms/apps/protocol/openid-connect/auth", + "auth_uri": "https://www.ssoapps.com/auth/realms/apps/protocol/openid-connect/auth", "client_id": "apps", - "issuer": "http://localhost:8080/auth/realms/apps", + "issuer": "https://www.ssoapps.com/auth/realms/apps", "client_secret": "[ADD YOUR SECRET FROM THE REALM>CLIENTS>apps>Credentials Tab]", "redirect_uris": [ - "http://localhost:6969/" + "https%3A%2F%2Fwww.your-domain-here.com%2F" ], - "userinfo_uri": "http://localhost:8080/auth/realms/apps/protocol/openid-connect/userinfo", - "token_uri": "http://localhost:8080/auth/realms/apps/protocol/openid-connect/token", - "token_introspection_uri": "http://localhost:8080/auth/realms/apps/protocol/openid-connect/token/introspect" + "userinfo_uri": "https://www.ssoapps.com/auth/realms/apps/protocol/openid-connect/userinfo", + "token_uri": "https://www.ssoapps.com/auth/realms/apps/protocol/openid-connect/token", + "token_introspection_uri": "https://www.ssoapps.com/auth/realms/apps/protocol/openid-connect/token/introspect" } } diff --git a/src/core/config.py b/src/core/config.py index e0fc33d..9b928d7 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -1,14 +1,15 @@ -# System import -import os, secrets, json +# Python imports +import os +import secrets +import json from datetime import timedelta - # Lib imports - # Apoplication imports + APP_NAME = ':::APP TITLE:::' ROOT_FILE_PTH = os.path.dirname(os.path.realpath(__file__)) # This path is submitted as the redirect URI in certain code flows. @@ -35,6 +36,8 @@ class Config(object): SQLALCHEMY_DATABASE_URI = "sqlite:///static/db/database.db" SQLALCHEMY_TRACK_MODIFICATIONS = False + REGISTER_DISABLED = False + LOGIN_DISABLED = False LOGIN_PATH = "FLASK_LOGIN" # Value can be OIDC or FLASK_LOGIN OIDC_TOKEN_TYPE_HINT = 'access_token' APP_REDIRECT_URI = REDIRECT_LINK diff --git a/src/core/forms.py b/src/core/forms.py index 12ba62b..c21bb45 100644 --- a/src/core/forms.py +++ b/src/core/forms.py @@ -1,9 +1,23 @@ +# Python imports + +# Lib imports from flask_wtf import FlaskForm -from wtforms import StringField, PasswordField, SubmitField -from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError + +from wtforms import StringField +from wtforms import PasswordField +from wtforms import SubmitField + +from wtforms.validators import DataRequired +from wtforms.validators import Length +from wtforms.validators import Email +from wtforms.validators import EqualTo +from wtforms.validators import ValidationError + +# Apoplication imports from core import User + class RegisterForm(FlaskForm): username = StringField('Username', validators=[DataRequired(), Length(min=4, max=24)]) email = StringField('Email', validators=[DataRequired(), Email()]) diff --git a/src/core/models.py b/src/core/models.py index e8e86f4..4978349 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -1,7 +1,12 @@ +# Python imports -from flask_sqlalchemy import SQLAlchemy -from core import app, login_manager +# Lib imports from flask_login import UserMixin +from flask_sqlalchemy import SQLAlchemy + +# Apoplication imports +from core import app, login_manager + db = SQLAlchemy(app) diff --git a/src/core/routes/__init__.py b/src/core/routes/__init__.py index 058bca0..2bbe6b6 100644 --- a/src/core/routes/__init__.py +++ b/src/core/routes/__init__.py @@ -1,6 +1,10 @@ -from . import Routes -from .pages import Flask_Login -from .pages import Flask_Register -from .pages import OIDC_Login -from .pages import OIDC_Register -from .pages import LoginManager +""" + Routes module +""" +from .login_controller import flask_login +from .login_controller import flask_register +from .login_controller import oidc_login +from .login_controller import oidc_register +from .login_controller import controller + +from . import routes diff --git a/src/core/routes/login_controller/__init__.py b/src/core/routes/login_controller/__init__.py new file mode 100644 index 0000000..27116fe --- /dev/null +++ b/src/core/routes/login_controller/__init__.py @@ -0,0 +1,3 @@ +""" + Login module +""" diff --git a/src/core/routes/pages/LoginManager.py b/src/core/routes/login_controller/controller.py similarity index 91% rename from src/core/routes/pages/LoginManager.py rename to src/core/routes/login_controller/controller.py index a8966fa..69657b4 100644 --- a/src/core/routes/pages/LoginManager.py +++ b/src/core/routes/login_controller/controller.py @@ -1,12 +1,15 @@ # Python imports # Lib imports -from flask import redirect, url_for, flash +from flask import redirect +from flask import url_for +from flask import flash -# App imports +# Application imports from core import app + ROUTE = app.config['LOGIN_PATH'] diff --git a/src/core/routes/pages/Flask_Login.py b/src/core/routes/login_controller/flask_login.py similarity index 66% rename from src/core/routes/pages/Flask_Login.py rename to src/core/routes/login_controller/flask_login.py index 6d33a83..e3985ab 100644 --- a/src/core/routes/pages/Flask_Login.py +++ b/src/core/routes/login_controller/flask_login.py @@ -1,19 +1,32 @@ # Python imports # Lib imports -from flask import request, render_template, flash, redirect, url_for -from flask_login import current_user, login_user, logout_user +from flask import flash +from flask import redirect +from flask import request +from flask import render_template +from flask import url_for + +from flask_login import current_user +from flask_login import login_user +from flask_login import logout_user + +# Application imports +from core import app +from core import bcrypt +from core import db +from core import User +from core import LoginForm -# App imports -from core import app, bcrypt, db, User, LoginForm from core.utils import MessageHandler # Get simple message processor + msgHandler = MessageHandler() @app.route('/app-login', methods=['GET', 'POST']) def app_login(): - if current_user.is_authenticated: + if current_user.is_authenticated or app.config["LOGIN_DISABLED"]: return redirect(url_for("home")) _form = LoginForm() diff --git a/src/core/routes/pages/Flask_Register.py b/src/core/routes/login_controller/flask_register.py similarity index 67% rename from src/core/routes/pages/Flask_Register.py rename to src/core/routes/login_controller/flask_register.py index 21398e6..e0a9a5c 100644 --- a/src/core/routes/pages/Flask_Register.py +++ b/src/core/routes/login_controller/flask_register.py @@ -1,20 +1,31 @@ # Python imports # Lib imports -from flask import request, render_template, url_for, redirect, flash +from flask import flash +from flask import redirect +from flask import request +from flask import render_template +from flask import url_for + +# Application imports + # Get from __init__ +from core import app +from core import bcrypt +from core import db +from core import current_user +from core import RegisterForm -# App imports -from core import app, bcrypt, db, current_user, RegisterForm # Get from __init__ from core.models import User from core.utils import MessageHandler # Get simple message processor + msgHandler = MessageHandler() @app.route('/app-register', methods=['GET', 'POST']) def app_register(): - if current_user.is_authenticated: + if current_user.is_authenticated or app.config["REGISTER_DISABLED"]: return redirect(url_for("home")) _form = RegisterForm() diff --git a/src/core/routes/pages/OIDC_Login.py b/src/core/routes/login_controller/oidc_login.py similarity index 87% rename from src/core/routes/pages/OIDC_Login.py rename to src/core/routes/login_controller/oidc_login.py index 7337011..75d88bf 100644 --- a/src/core/routes/pages/OIDC_Login.py +++ b/src/core/routes/login_controller/oidc_login.py @@ -1,13 +1,15 @@ # Python imports # Lib imports -from flask import request, redirect, flash +from flask import request +from flask import redirect +from flask import flash - -# App imports +# Application imports from ... import app, oidc + @app.route('/oidc-login', methods=['GET', 'POST']) @oidc.require_login def oidc_login(): diff --git a/src/core/routes/pages/OIDC_Register.py b/src/core/routes/login_controller/oidc_register.py similarity index 63% rename from src/core/routes/pages/OIDC_Register.py rename to src/core/routes/login_controller/oidc_register.py index 8fa115d..5fb4de3 100644 --- a/src/core/routes/pages/OIDC_Register.py +++ b/src/core/routes/login_controller/oidc_register.py @@ -1,19 +1,28 @@ # Python imports # Lib imports -from flask import request, render_template, url_for, redirect, flash +from flask import flash +from flask import redirect +from flask import request +from flask import render_template +from flask import url_for + +# Application imports + # Get from __init__ +from ... import app +from ... import oidc +from ... import db -# App imports -from ... import app, oidc, db # Get from __init__ from ...utils import MessageHandler # Get simple message processor + msgHandler = MessageHandler() @app.route('/oidc-register', methods=['GET', 'POST']) def oidc_register(): - if oidc.user_loggedin: + if oidc.user_loggedin or app.config["REGISTER_DISABLED"]: return redirect("/home") _form = RegisterForm() diff --git a/src/core/routes/Routes.py b/src/core/routes/routes.py similarity index 88% rename from src/core/routes/Routes.py rename to src/core/routes/routes.py index d9486a3..a370c26 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/routes.py @@ -1,15 +1,21 @@ # Python imports # Lib imports -from flask import request, render_template +from flask import request +from flask import render_template from flask_login import current_user +# Application imports + # Get from __init__ +from core import app +from core import logger +from core import oidc +from core import db -# App imports -from core import app, logger, oidc, db # Get from __init__ from core.utils import MessageHandler # Get simple message processor + msgHandler = MessageHandler() diff --git a/src/core/static/css/webfonts/fa-brands-400.ttf b/src/core/static/css/webfonts/fa-brands-400.ttf deleted file mode 100644 index 2421b22..0000000 Binary files a/src/core/static/css/webfonts/fa-brands-400.ttf and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-brands-400.woff b/src/core/static/css/webfonts/fa-brands-400.woff deleted file mode 100644 index 994b85d..0000000 Binary files a/src/core/static/css/webfonts/fa-brands-400.woff and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-brands-400.woff2 b/src/core/static/css/webfonts/fa-brands-400.woff2 deleted file mode 100644 index 0208509..0000000 Binary files a/src/core/static/css/webfonts/fa-brands-400.woff2 and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-regular-400.ttf b/src/core/static/css/webfonts/fa-regular-400.ttf deleted file mode 100644 index f4348f4..0000000 Binary files a/src/core/static/css/webfonts/fa-regular-400.ttf and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-regular-400.woff b/src/core/static/css/webfonts/fa-regular-400.woff deleted file mode 100644 index 8f6c874..0000000 Binary files a/src/core/static/css/webfonts/fa-regular-400.woff and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-regular-400.woff2 b/src/core/static/css/webfonts/fa-regular-400.woff2 deleted file mode 100644 index f1de39b..0000000 Binary files a/src/core/static/css/webfonts/fa-regular-400.woff2 and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-solid-900.ttf b/src/core/static/css/webfonts/fa-solid-900.ttf deleted file mode 100644 index aa50441..0000000 Binary files a/src/core/static/css/webfonts/fa-solid-900.ttf and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-solid-900.woff b/src/core/static/css/webfonts/fa-solid-900.woff deleted file mode 100644 index e87d1b8..0000000 Binary files a/src/core/static/css/webfonts/fa-solid-900.woff and /dev/null differ diff --git a/src/core/static/css/webfonts/fa-solid-900.woff2 b/src/core/static/css/webfonts/fa-solid-900.woff2 deleted file mode 100644 index ac2f203..0000000 Binary files a/src/core/static/css/webfonts/fa-solid-900.woff2 and /dev/null differ diff --git a/src/core/templates/layout.html b/src/core/templates/layout.html index 27d97ff..dd1bdca 100644 --- a/src/core/templates/layout.html +++ b/src/core/templates/layout.html @@ -25,12 +25,8 @@ {% block header_css %} - - - - - - + + @@ -47,21 +43,21 @@ {% endblock %} {% endblock %} -
+ {% block body_header %} @@ -111,9 +107,9 @@ + - {% block body_scripts_additional %} diff --git a/src/core/templates/pages/index.html b/src/core/templates/pages/index.html index 2313d91..c2c0be6 100644 --- a/src/core/templates/pages/index.html +++ b/src/core/templates/pages/index.html @@ -16,8 +16,7 @@ {% block body_content_additional %}Using Bootstrap 5 Themeing...
-Themes: Bootswatch
+Using Bootstrap 5 Themeing with Dark Mode defaulted...
With React available...