49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
import flask
|
|
from jose import jwt, jwk
|
|
import os
|
|
from flask import render_template, send_from_directory, Blueprint, jsonify
|
|
from flask_pyoidc.user_session import UserSession
|
|
|
|
from backend.auth import oidc_auth
|
|
|
|
fe_path = os.path.join(os.getcwd(), "frontend", "dist")
|
|
fe_bp = Blueprint('frontend', __name__, url_prefix='/', template_folder=os.path.join(fe_path, ""))
|
|
|
|
|
|
@fe_bp.route('/js/<path:path>')
|
|
def send_js(path):
|
|
return send_from_directory(os.path.join(fe_path, "js"), path)
|
|
|
|
|
|
@fe_bp.route('/css/<path:path>')
|
|
def send_css(path):
|
|
return send_from_directory(os.path.join(fe_path, "css"), path)
|
|
|
|
|
|
@fe_bp.route('/img/<path:path>')
|
|
def send_img(path):
|
|
return send_from_directory(os.path.join(fe_path, "img"), path)
|
|
|
|
|
|
@fe_bp.route('/test')
|
|
@oidc_auth.oidc_auth()
|
|
def test_oidc():
|
|
user_session = UserSession(flask.session)
|
|
access_token = user_session.access_token
|
|
token_claim = jwt.get_unverified_claims(access_token)
|
|
token_header = jwt.get_unverified_header(access_token)
|
|
return jsonify(id_token=flask.session['id_token'], access_token=flask.session['access_token'],
|
|
userinfo=flask.session['userinfo'],
|
|
token_claim=token_claim,
|
|
token_header=token_header)
|
|
|
|
|
|
|
|
@fe_bp.route('/', defaults={'path': ''})
|
|
@fe_bp.route('/<path:path>')
|
|
def catch_all(path):
|
|
return render_template("index.html")
|