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 import os, random, string
from authlib.integrations.flask_client import OAuth 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_login import login_user
from flask_appbuilder import expose, BaseView as AppBuilderBaseView from flask_appbuilder import expose, BaseView as AppBuilderBaseView
from airflow.plugins_manager import AirflowPlugin from airflow.plugins_manager import AirflowPlugin
...@@ -26,16 +26,17 @@ oauth.register( ...@@ -26,16 +26,17 @@ oauth.register(
) )
class UnityIntegrationLoginView(AppBuilderBaseView): unity = Blueprint('unity', __name__, url_prefix="/unity")
#@expose("/unity_login")
@app.route('/unity_login') class UnityIntegrationView(AppBuilderBaseView):
def unity_login():
redirect_uri = url_for('unity_authorize', _external=True) @unity.route('/login')
def login():
redirect_uri = url_for('authorize', _external=True)
return oauth.unity.authorize_redirect(redirect_uri) return oauth.unity.authorize_redirect(redirect_uri)
class UnityIntegrationAuthView(AppBuilderBaseView):
#@expose("/unity_authorize") @unity.route('/authorize')
@app.route('/unity_authorize') async def authorize():
async def unity_authorize():
token = await oauth.unity.authorize_access_token() token = await oauth.unity.authorize_access_token()
user = await oauth.unity.userinfo(token=token) user = await oauth.unity.userinfo(token=token)
# get relevant data from token # get relevant data from token
...@@ -66,20 +67,20 @@ class UnityIntegrationAuthView(AppBuilderBaseView): ...@@ -66,20 +67,20 @@ class UnityIntegrationAuthView(AppBuilderBaseView):
login_user(fab_user, remember=False) login_user(fab_user, remember=False)
return redirect('/') return redirect('/')
v_unity_login_view = UnityIntegrationLoginView() @unity.route('/logout')
v_unity_login_package = { def logout():
"name": "Unity Login View", pass
"category": "Unity Integration",
"view": v_unity_login_view,
}
v_unity_auth_view = UnityIntegrationAuthView() v_unity_view = UnityIntegrationView()
v_unity_auth_package = { v_unity_package = {
"name": "Unity Auth View", "name": "Unity SSO View",
"category": "Unity Integration", "category": "Unity Integration",
"view": v_unity_auth_view, "view": v_unity_view,
} }
class UnityIntegrationPlugin(AirflowPlugin): class UnityIntegrationPlugin(AirflowPlugin):
name = "unity_integration" name = "unity_integration"
appbuilder_views = [v_unity_auth_package, v_unity_login_package] appbuilder_views = [v_unity_package]
\ No newline at end of file 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