dataflow-core 2.1.0__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- authenticator/dataflowsupersetauthenticator.py +47 -37
- {dataflow_core-2.1.0.dist-info → dataflow_core-2.1.1.dist-info}/METADATA +1 -1
- {dataflow_core-2.1.0.dist-info → dataflow_core-2.1.1.dist-info}/RECORD +6 -6
- {dataflow_core-2.1.0.dist-info → dataflow_core-2.1.1.dist-info}/WHEEL +0 -0
- {dataflow_core-2.1.0.dist-info → dataflow_core-2.1.1.dist-info}/entry_points.txt +0 -0
- {dataflow_core-2.1.0.dist-info → dataflow_core-2.1.1.dist-info}/top_level.txt +0 -0
|
@@ -15,50 +15,60 @@ class DataflowAuthDBView(AuthDBView):
|
|
|
15
15
|
def __init__(self):
|
|
16
16
|
self.dataflow = Dataflow()
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def create_user(self, user_details):
|
|
19
|
+
"""
|
|
20
|
+
Create a new user in Superset with the given details.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
User object: The newly created user instance
|
|
24
|
+
"""
|
|
25
|
+
return self.appbuilder.sm.add_user(
|
|
26
|
+
username=user_details['user_name'],
|
|
27
|
+
first_name=user_details.get("first_name", ""),
|
|
28
|
+
last_name=user_details.get("last_name", ""),
|
|
29
|
+
email=user_details.get("email", ""),
|
|
30
|
+
role=self.appbuilder.sm.find_role('Admin')
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
@expose('/login/', methods=['GET', "POST"])
|
|
34
|
+
def login(self):
|
|
35
|
+
"""
|
|
36
|
+
Handles both GET and POST login requests.
|
|
37
|
+
|
|
38
|
+
- GET: Used for browser-based login. Authenticates using session cookie and redirects to home.
|
|
39
|
+
- POST: Used for API-based login. Returns JWT access token for programmatic access.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
- Redirect to home page (GET)
|
|
43
|
+
- JSON response with access token (POST)
|
|
44
|
+
"""
|
|
45
|
+
if request.method == "GET":
|
|
21
46
|
session_id = request.cookies.get('dataflow_session')
|
|
22
|
-
|
|
23
47
|
user_details = self.dataflow.auth(session_id)
|
|
24
48
|
user = self.appbuilder.sm.find_user(username=user_details['user_name'])
|
|
49
|
+
try:
|
|
50
|
+
if user:
|
|
51
|
+
login_user(user, remember=False)
|
|
52
|
+
else:
|
|
53
|
+
user = self.create_user(user_details)
|
|
54
|
+
login_user(user, remember=False)
|
|
55
|
+
return redirect(self.appbuilder.get_url_for_index)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
return super().login()
|
|
58
|
+
else:
|
|
59
|
+
user_details = request.get_json()
|
|
60
|
+
user = self.appbuilder.sm.find_user(username=user_details["user_name"])
|
|
25
61
|
if user:
|
|
26
62
|
login_user(user, remember=False)
|
|
27
63
|
else:
|
|
28
|
-
user = self.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
role=self.appbuilder.sm.find_role('Admin')
|
|
64
|
+
user = self.create_user(user_details)
|
|
65
|
+
login_user(user, remember=False)
|
|
66
|
+
resp = {
|
|
67
|
+
API_SECURITY_ACCESS_TOKEN_KEY: create_access_token(
|
|
68
|
+
identity=str(user.id), fresh=True
|
|
34
69
|
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return redirect(self.appbuilder.get_url_for_index)
|
|
39
|
-
|
|
40
|
-
except Exception as e:
|
|
41
|
-
return super().login()
|
|
42
|
-
|
|
43
|
-
@expose("/login", methods=["POST"])
|
|
44
|
-
def login_token(self):
|
|
45
|
-
login_payload = request.get_json()
|
|
46
|
-
user = self.appbuilder.sm.find_user(username=login_payload["user_name"])
|
|
47
|
-
|
|
48
|
-
if not user:
|
|
49
|
-
user = self.appbuilder.sm.add_user(
|
|
50
|
-
username=login_payload["user_name"],
|
|
51
|
-
first_name=login_payload.get("first_name", ""),
|
|
52
|
-
last_name=login_payload.get("last_name", ""),
|
|
53
|
-
email=login_payload.get("email", ""),
|
|
54
|
-
role=self.appbuilder.sm.find_role('Admin')
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
resp = dict()
|
|
58
|
-
resp[API_SECURITY_ACCESS_TOKEN_KEY] = create_access_token(
|
|
59
|
-
identity=str(user.id), fresh=True
|
|
60
|
-
)
|
|
61
|
-
return jsonify(resp)
|
|
70
|
+
}
|
|
71
|
+
return jsonify(resp)
|
|
62
72
|
|
|
63
73
|
class DataflowSecurityManager(SupersetSecurityManager):
|
|
64
74
|
authdbview = DataflowAuthDBView
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
authenticator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
authenticator/dataflowairflowauthenticator.py,sha256=gEdCiL2yJQ7lYvAwbrjcAkccVMfehoMJldw9eU7cc2s,2243
|
|
3
3
|
authenticator/dataflowhubauthenticator.py,sha256=A0S0_PJVCPiTfuoLormmO0xNDqjIh00Cf93P0-mF0cw,2913
|
|
4
|
-
authenticator/dataflowsupersetauthenticator.py,sha256=
|
|
4
|
+
authenticator/dataflowsupersetauthenticator.py,sha256=NkAmDaIc-ui-qEolu4xz_UY7P_2g8111hwNjPvAOW1Q,2839
|
|
5
5
|
dataflow/__init__.py,sha256=WTRg8HMpMWSgxYJ9ZGVldx4k07fAbta3mBmZ1hG9mWE,30
|
|
6
6
|
dataflow/configuration.py,sha256=7To6XwH1eESiYp39eqPcswXWwrdBUdPF6xN6WnazOF0,663
|
|
7
7
|
dataflow/database_manager.py,sha256=tJHMuOZ9Muskrh9t4uLRlTuFU0VkHAzoHlGP5DORIC4,899
|
|
@@ -36,8 +36,8 @@ dataflow/utils/aws_secrets_manager.py,sha256=A_fNs9VNah9dDdl9NhqizJamYU7xr2v_GXl
|
|
|
36
36
|
dataflow/utils/get_current_user.py,sha256=akjcUyTpmMdAZj9LFGSTs76hjBRjltNk9hLUqC_BdkA,1140
|
|
37
37
|
dataflow/utils/json_handler.py,sha256=5_7WdypegRBDe2HSqBXyrJAdd92wsha8qRcmQvCj1TA,782
|
|
38
38
|
dataflow/utils/logger.py,sha256=7BFrOq5Oiqn8P4XZbgJzMP5O07d2fpdECbbfsjrUuHw,1213
|
|
39
|
-
dataflow_core-2.1.
|
|
40
|
-
dataflow_core-2.1.
|
|
41
|
-
dataflow_core-2.1.
|
|
42
|
-
dataflow_core-2.1.
|
|
43
|
-
dataflow_core-2.1.
|
|
39
|
+
dataflow_core-2.1.1.dist-info/METADATA,sha256=WdN8Xh9UGcvgYnv-i-CB9fANkjBlUjcw_NawSc2_EcY,301
|
|
40
|
+
dataflow_core-2.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
41
|
+
dataflow_core-2.1.1.dist-info/entry_points.txt,sha256=ppj_EIbYrJJwCPg1kfdsZk5q1N-Ejfis1neYrnjhO8o,117
|
|
42
|
+
dataflow_core-2.1.1.dist-info/top_level.txt,sha256=SZsUOpSCK9ntUy-3Tusxzf5A2e8ebwD8vouPb1dPt_8,23
|
|
43
|
+
dataflow_core-2.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|