added api to get process groups and added some cors support w/ burnettk

This commit is contained in:
jasquat 2022-06-03 11:40:19 -04:00
parent f08992f2e5
commit 725b06d084
4 changed files with 22 additions and 1 deletions

View File

@ -20,7 +20,8 @@ from spiffworkflow_backend import create_app # noqa: E402
def app() -> Flask:
"""App."""
os.environ["FLASK_ENV"] = "testing"
os.environ["FLASK_SESSION_SECRET_KEY"] = "this_is_testing_secret_key"
# os.environ["FLASK_SESSION_SECRET_KEY"] = "this_is_testing_secret_key"
os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key"
app = create_app()
# NOTE: set this here since nox shoves tests and src code to

View File

@ -6,12 +6,14 @@ import flask.app
from flask_bpmn.api.api_error import api_error_blueprint
from flask_bpmn.models.db import db
from flask_bpmn.models.db import migrate
from flask_cors import CORS
from spiffworkflow_backend.config import setup_config
from spiffworkflow_backend.routes.admin_blueprint.admin_blueprint import admin_blueprint
from spiffworkflow_backend.routes.api_blueprint import api_blueprint
from spiffworkflow_backend.routes.process_api_blueprint import process_api_blueprint
from spiffworkflow_backend.routes.user_blueprint import user_blueprint
from spiffworkflow_backend.models.user import UserModel
def create_app() -> flask.app.Flask:
@ -44,6 +46,10 @@ def create_app() -> flask.app.Flask:
app.register_blueprint(process_api_blueprint)
app.register_blueprint(api_error_blueprint)
app.register_blueprint(admin_blueprint, url_prefix="/admin")
origins_re = [r"^https?:\/\/%s(.*)" % o.replace('.', '\.') for o in app.config['CORS_ALLOW_ORIGINS']]
CORS(app, origins=origins_re)
connexion_app.add_api("api.yml", base_path="/v1.0")
return app

View File

@ -1,4 +1,7 @@
"""Default."""
from os import environ
import re
BPMN_SPEC_ABSOLUTE_DIR = environ.get("BPMN_SPEC_ABSOLUTE_DIR", default="")
CORS_DEFAULT = '*'
CORS_ALLOW_ORIGINS = re.split(r',\s*', environ.get('CORS_ALLOW_ORIGINS', default=CORS_DEFAULT))

View File

@ -7,6 +7,7 @@ from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from flask import current_app
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.user import UserModel
@ -26,6 +27,16 @@ admin_blueprint = Blueprint(
ALLOWED_BPMN_EXTENSIONS = {"bpmn", "dmn"}
@admin_blueprint.route("/token", methods=["GET"])
def token():
if current_app.env != "development":
return "Not authorized"
user = UserModel.query.first()
auth_token = user.encode_auth_token()
return(f"auth_token: {auth_token}")
@admin_blueprint.route("/process-groups", methods=["GET"])
def process_groups_list():
"""Process_groups_list."""