Skip to content
Snippets Groups Projects
Commit d6b98132 authored by Christian Boettcher's avatar Christian Boettcher
Browse files

check integration via blueprint and single view

parent 86a4103a
No related branches found
No related tags found
No related merge requests found
Pipeline #131157 passed
import os, random, string
from authlib.integrations.flask_client import OAuth
from flask import url_for, redirect, current_app as app
from flask import url_for, redirect, current_app as app, Blueprint
from flask_login import login_user
from flask_appbuilder import expose, BaseView as AppBuilderBaseView
from airflow.plugins_manager import AirflowPlugin
......@@ -26,16 +26,17 @@ oauth.register(
)
class UnityIntegrationLoginView(AppBuilderBaseView):
#@expose("/unity_login")
@app.route('/unity_login')
def unity_login():
redirect_uri = url_for('unity_authorize', _external=True)
unity = Blueprint('unity', __name__, url_prefix="/unity")
class UnityIntegrationView(AppBuilderBaseView):
@unity.route('/login')
def login():
redirect_uri = url_for('authorize', _external=True)
return oauth.unity.authorize_redirect(redirect_uri)
class UnityIntegrationAuthView(AppBuilderBaseView):
#@expose("/unity_authorize")
@app.route('/unity_authorize')
async def unity_authorize():
@unity.route('/authorize')
async def authorize():
token = await oauth.unity.authorize_access_token()
user = await oauth.unity.userinfo(token=token)
# get relevant data from token
......@@ -66,20 +67,20 @@ class UnityIntegrationAuthView(AppBuilderBaseView):
login_user(fab_user, remember=False)
return redirect('/')
v_unity_login_view = UnityIntegrationLoginView()
v_unity_login_package = {
"name": "Unity Login View",
"category": "Unity Integration",
"view": v_unity_login_view,
}
@unity.route('/logout')
def logout():
pass
v_unity_auth_view = UnityIntegrationAuthView()
v_unity_auth_package = {
"name": "Unity Auth View",
v_unity_view = UnityIntegrationView()
v_unity_package = {
"name": "Unity SSO View",
"category": "Unity Integration",
"view": v_unity_auth_view,
"view": v_unity_view,
}
class UnityIntegrationPlugin(AirflowPlugin):
name = "unity_integration"
appbuilder_views = [v_unity_auth_package, v_unity_login_package]
\ No newline at end of file
appbuilder_views = [v_unity_package]
flask_blueprints = [unity]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment