Skip to content

Commit

Permalink
Dev (#7)
Browse files Browse the repository at this point in the history
fix: root app.py to serve bump authlib 1.2
  • Loading branch information
Rishang committed Jan 17, 2023
1 parent 53667d0 commit 8648b0f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: pip install -r requirements.mkdocs.txt
- run: mkdocs gh-deploy --force
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt

WORKDIR /app
COPY . /app

USER appuser
COPY broker /app
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "routes:app"]
9 changes: 0 additions & 9 deletions app.py

This file was deleted.

Empty file modified broker/aws/__init__.py
100644 → 100755
Empty file.
24 changes: 20 additions & 4 deletions broker/routes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from flask import request, session, url_for, redirect, jsonify, render_template
from .aws import sts
from . import app, keycloak_oidc, title
from .utils import msg
"""
Main routes file for running server, to start server
run: python routes.py
"""

import os
import json

from flask import request, session, url_for, redirect, jsonify, render_template

from aws import sts
from serve import app, keycloak_oidc, title
from utils import msg

# flask cors import
# from flask_cors import CORS

Expand Down Expand Up @@ -106,3 +114,11 @@ def aws_auth():
return jsonify(sts_role["cli"])
elif type == "console":
return redirect(sts_role["console"])


if __name__ == "__main__":
env = os.environ.get("FLASK_ENV")
if isinstance(env, str) and env.lower() in ["main", "master"]:
app.run()
else:
app.run(debug=True)
10 changes: 4 additions & 6 deletions broker/__init__.py → broker/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
ref: https://github.com/authlib/demo-oauth-client/tree/master/flask-google-login
"""

from flask import Flask
from authlib.integrations.flask_client import OAuth, FlaskOAuth2App
from .data import KeyCloakOpenIdconfig
from .utils import obj_annotations, load_or_read_env

from data import KeyCloakOpenIdconfig
from utils import obj_annotations, load_or_read_env

app = Flask(
__name__,
Expand All @@ -29,7 +29,7 @@
PROVIDER = "keycloak"


def oidc_conf(provider: str, config_path: str = ".env"):
def oidc_conf(provider: str, config_path: str = "../.env"):
"""Read oidc config from dotenv file"""

if provider.lower() == "keycloak":
Expand All @@ -53,5 +53,3 @@ def oidc_conf(provider: str, config_path: str = ".env"):
)

keycloak_oidc: FlaskOAuth2App = oauth.create_client(PROVIDER)

from broker import routes
2 changes: 0 additions & 2 deletions broker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def obj_annotations(obj: object):

def load_or_read_env(items: list[str], env_path: str):

env_path = os.path.abspath(".") + "/" + env_path

conf = {}

if os.path.isfile(env_path):
Expand Down
Empty file modified docs/assets/devspace.yaml
100755 → 100644
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
boto3
authlib==1.1.0
authlib==1.2.0
flask
python-dotenv
requests
Expand Down

0 comments on commit 8648b0f

Please sign in to comment.