apache-airflow-providers-fab 1.5.3__py3-none-any.whl → 2.0.0b1__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.
- airflow/providers/fab/LICENSE +0 -52
- airflow/providers/fab/__init__.py +3 -3
- airflow/providers/fab/auth_manager/api/auth/backend/basic_auth.py +3 -3
- airflow/providers/fab/auth_manager/api/auth/backend/kerberos_auth.py +4 -4
- airflow/providers/fab/auth_manager/api/auth/backend/session.py +1 -1
- airflow/providers/fab/auth_manager/api_endpoints/role_and_permission_endpoint.py +14 -13
- airflow/providers/fab/auth_manager/api_endpoints/user_endpoint.py +12 -12
- airflow/providers/fab/auth_manager/api_fastapi/__init__.py +16 -0
- airflow/providers/fab/auth_manager/api_fastapi/datamodels/__init__.py +16 -0
- airflow/providers/fab/auth_manager/api_fastapi/datamodels/login.py +32 -0
- airflow/providers/fab/auth_manager/api_fastapi/openapi/__init__.py +16 -0
- airflow/providers/fab/auth_manager/api_fastapi/openapi/v1-generated.yaml +152 -0
- airflow/providers/fab/auth_manager/api_fastapi/routes/__init__.py +16 -0
- airflow/providers/fab/auth_manager/api_fastapi/routes/login.py +51 -0
- airflow/providers/fab/auth_manager/api_fastapi/services/__init__.py +16 -0
- airflow/providers/fab/auth_manager/api_fastapi/services/login.py +58 -0
- airflow/providers/fab/auth_manager/cli_commands/db_command.py +2 -4
- airflow/providers/fab/auth_manager/cli_commands/user_command.py +2 -2
- airflow/providers/fab/auth_manager/cli_commands/utils.py +10 -9
- airflow/providers/fab/auth_manager/fab_auth_manager.py +231 -126
- airflow/providers/fab/auth_manager/models/__init__.py +1 -1
- airflow/providers/fab/auth_manager/models/anonymous_user.py +1 -1
- airflow/providers/fab/auth_manager/models/db.py +22 -5
- airflow/providers/fab/auth_manager/schemas/user_schema.py +1 -1
- airflow/providers/fab/auth_manager/security_manager/override.py +71 -632
- airflow/providers/fab/auth_manager/views/permissions.py +1 -1
- airflow/providers/fab/auth_manager/views/roles_list.py +1 -1
- airflow/providers/fab/auth_manager/views/user.py +1 -1
- airflow/providers/fab/auth_manager/views/user_edit.py +1 -1
- airflow/providers/fab/auth_manager/views/user_stats.py +1 -1
- airflow/providers/fab/get_provider_info.py +22 -16
- airflow/providers/fab/www/airflow_flask_app.py +31 -0
- airflow/providers/fab/www/api_connexion/__init__.py +17 -0
- airflow/providers/fab/www/api_connexion/exceptions.py +197 -0
- airflow/providers/fab/www/api_connexion/parameters.py +131 -0
- airflow/providers/fab/www/api_connexion/security.py +84 -0
- airflow/providers/fab/www/api_connexion/types.py +30 -0
- airflow/providers/fab/www/app.py +112 -0
- airflow/providers/fab/www/auth.py +350 -0
- airflow/providers/fab/www/constants.py +28 -0
- airflow/providers/fab/www/extensions/__init__.py +16 -0
- airflow/providers/fab/www/extensions/init_appbuilder.py +602 -0
- airflow/providers/fab/www/extensions/init_jinja_globals.py +82 -0
- airflow/providers/fab/www/extensions/init_manifest_files.py +61 -0
- airflow/providers/fab/www/extensions/init_security.py +61 -0
- airflow/providers/fab/www/extensions/init_session.py +64 -0
- airflow/providers/fab/www/extensions/init_views.py +177 -0
- airflow/providers/fab/www/package-lock.json +10127 -0
- airflow/providers/fab/www/package.json +81 -0
- airflow/providers/fab/www/security/__init__.py +17 -0
- airflow/providers/fab/www/security/permissions.py +126 -0
- airflow/providers/fab/www/security_appless.py +44 -0
- airflow/providers/fab/www/security_manager.py +122 -0
- airflow/providers/fab/www/session.py +41 -0
- airflow/providers/fab/www/static/css/bootstrap-theme.css +6215 -0
- airflow/providers/fab/www/static/css/flash.css +57 -0
- airflow/providers/fab/www/static/css/loading-dots.css +60 -0
- airflow/providers/fab/www/static/css/main.css +676 -0
- airflow/providers/fab/www/static/css/material-icons.css +84 -0
- airflow/providers/fab/www/static/dist/airflowDefaultTheme.feec4a4075c2f3d6ae01.css +33 -0
- airflow/providers/fab/www/static/dist/airflowDefaultTheme.feec4a4075c2f3d6ae01.js +1 -0
- airflow/providers/fab/www/static/dist/flash.137b30cff85b5588e661.css +18 -0
- airflow/providers/fab/www/static/dist/flash.137b30cff85b5588e661.js +1 -0
- airflow/providers/fab/www/static/dist/jquery-ui.min.css +5 -0
- airflow/providers/fab/www/static/dist/jquery-ui.min.js +2 -0
- airflow/providers/fab/www/static/dist/jquery-ui.min.js.LICENSE.txt +4 -0
- airflow/providers/fab/www/static/dist/loadingDots.48ab7d5b04e66f2686b0.css +18 -0
- airflow/providers/fab/www/static/dist/loadingDots.48ab7d5b04e66f2686b0.js +1 -0
- airflow/providers/fab/www/static/dist/main.ec1d38d994d72bb083cd.css +18 -0
- airflow/providers/fab/www/static/dist/main.ec1d38d994d72bb083cd.js +2 -0
- airflow/providers/fab/www/static/dist/main.ec1d38d994d72bb083cd.js.LICENSE.txt +18 -0
- airflow/providers/fab/www/static/dist/manifest.json +17 -0
- airflow/providers/fab/www/static/dist/materialIcons.57390fa60d8f61175334.css +18 -0
- airflow/providers/fab/www/static/dist/materialIcons.57390fa60d8f61175334.js +1 -0
- airflow/providers/fab/www/static/dist/moment.4d28b37c229bdfc54575.js +2 -0
- airflow/providers/fab/www/static/dist/moment.4d28b37c229bdfc54575.js.LICENSE.txt +11 -0
- airflow/providers/fab/www/static/dist/oss-licenses.json +29 -0
- airflow/providers/fab/www/static/js/datetime_utils.js +134 -0
- airflow/providers/fab/www/static/js/main.js +324 -0
- airflow/providers/fab/www/static/sort_asc.png +0 -0
- airflow/providers/fab/www/static/sort_both.png +0 -0
- airflow/providers/fab/www/static/sort_desc.png +0 -0
- airflow/providers/fab/www/templates/airflow/_messages.html +30 -0
- airflow/providers/fab/www/templates/airflow/error.html +35 -0
- airflow/providers/fab/www/templates/airflow/main.html +78 -0
- airflow/providers/fab/www/templates/airflow/traceback.html +53 -0
- airflow/providers/fab/www/templates/appbuilder/flash.html +34 -0
- airflow/providers/fab/www/templates/appbuilder/index.html +20 -0
- airflow/providers/fab/www/templates/appbuilder/navbar.html +60 -0
- airflow/providers/fab/www/templates/appbuilder/navbar_menu.html +60 -0
- airflow/providers/fab/www/templates/appbuilder/navbar_right.html +64 -0
- airflow/providers/fab/www/utils.py +272 -0
- airflow/providers/fab/www/views.py +129 -0
- airflow/providers/fab/www/webpack.config.js +213 -0
- {apache_airflow_providers_fab-1.5.3.dist-info → apache_airflow_providers_fab-2.0.0b1.dist-info}/METADATA +17 -35
- apache_airflow_providers_fab-2.0.0b1.dist-info/RECORD +122 -0
- {apache_airflow_providers_fab-1.5.3.dist-info → apache_airflow_providers_fab-2.0.0b1.dist-info}/WHEEL +1 -1
- airflow/providers/fab/auth_manager/decorators/auth.py +0 -126
- apache_airflow_providers_fab-1.5.3.dist-info/RECORD +0 -51
- /airflow/providers/fab/{auth_manager/decorators → www}/__init__.py +0 -0
- {apache_airflow_providers_fab-1.5.3.dist-info → apache_airflow_providers_fab-2.0.0b1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
3
|
+
# distributed with this work for additional information
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
6
|
+
# "License"); you may not use this file except in compliance
|
7
|
+
# with the License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
from __future__ import annotations
|
18
|
+
|
19
|
+
from typing import TYPE_CHECKING, cast
|
20
|
+
|
21
|
+
from starlette import status
|
22
|
+
from starlette.exceptions import HTTPException
|
23
|
+
|
24
|
+
from airflow.api_fastapi.app import get_auth_manager
|
25
|
+
from airflow.configuration import conf
|
26
|
+
from airflow.providers.fab.auth_manager.api_fastapi.datamodels.login import LoginBody, LoginResponse
|
27
|
+
from airflow.providers.fab.auth_manager.fab_auth_manager import FabAuthManager
|
28
|
+
|
29
|
+
if TYPE_CHECKING:
|
30
|
+
from airflow.providers.fab.auth_manager.models import User
|
31
|
+
|
32
|
+
|
33
|
+
class FABAuthManagerLogin:
|
34
|
+
"""Login Service for FABAuthManager."""
|
35
|
+
|
36
|
+
@classmethod
|
37
|
+
def create_token(
|
38
|
+
cls, body: LoginBody, expiration_time_in_sec: int = conf.getint("api_auth", "jwt_expiration_time")
|
39
|
+
) -> LoginResponse:
|
40
|
+
"""Create a new token."""
|
41
|
+
if not body.username or not body.password:
|
42
|
+
raise HTTPException(
|
43
|
+
status_code=status.HTTP_400_BAD_REQUEST, detail="Username and password must be provided"
|
44
|
+
)
|
45
|
+
|
46
|
+
auth_manager = cast(FabAuthManager, get_auth_manager())
|
47
|
+
user: User = auth_manager.security_manager.find_user(username=body.username)
|
48
|
+
if not user:
|
49
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid username")
|
50
|
+
|
51
|
+
if auth_manager.security_manager.check_password(username=body.username, password=body.password):
|
52
|
+
return LoginResponse(
|
53
|
+
jwt_token=auth_manager.generate_jwt(
|
54
|
+
user=user, expiration_time_in_seconds=expiration_time_in_sec
|
55
|
+
)
|
56
|
+
)
|
57
|
+
else:
|
58
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid password")
|
@@ -17,7 +17,7 @@
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
19
|
from airflow import settings
|
20
|
-
from airflow.cli.commands.db_command import run_db_downgrade_command, run_db_migrate_command
|
20
|
+
from airflow.cli.commands.local_commands.db_command import run_db_downgrade_command, run_db_migrate_command
|
21
21
|
from airflow.providers.fab.auth_manager.models.db import _REVISION_HEADS_MAP, FABDBManager
|
22
22
|
from airflow.utils import cli as cli_utils
|
23
23
|
from airflow.utils.providers_configuration_loader import providers_configuration_loaded
|
@@ -38,9 +38,7 @@ def migratedb(args):
|
|
38
38
|
"""Migrates the metadata database."""
|
39
39
|
session = settings.Session()
|
40
40
|
upgrade_command = FABDBManager(session).upgradedb
|
41
|
-
run_db_migrate_command(
|
42
|
-
args, upgrade_command, revision_heads_map=_REVISION_HEADS_MAP, reserialize_dags=False
|
43
|
-
)
|
41
|
+
run_db_migrate_command(args, upgrade_command, revision_heads_map=_REVISION_HEADS_MAP)
|
44
42
|
|
45
43
|
|
46
44
|
@cli_utils.action_cli(check_db=False)
|
@@ -23,10 +23,10 @@ import getpass
|
|
23
23
|
import json
|
24
24
|
import os
|
25
25
|
import random
|
26
|
+
import re
|
26
27
|
import string
|
27
28
|
from typing import Any
|
28
29
|
|
29
|
-
import re2
|
30
30
|
from marshmallow import Schema, fields, validate
|
31
31
|
from marshmallow.exceptions import ValidationError
|
32
32
|
|
@@ -178,7 +178,7 @@ def users_export(args):
|
|
178
178
|
# In the User model the first and last name fields have underscores,
|
179
179
|
# but the corresponding parameters in the CLI don't
|
180
180
|
def remove_underscores(s):
|
181
|
-
return
|
181
|
+
return re.sub("_", "", s)
|
182
182
|
|
183
183
|
users = [
|
184
184
|
{
|
@@ -18,29 +18,30 @@
|
|
18
18
|
from __future__ import annotations
|
19
19
|
|
20
20
|
import os
|
21
|
+
from collections.abc import Generator
|
21
22
|
from contextlib import contextmanager
|
22
|
-
from functools import
|
23
|
+
from functools import cache
|
23
24
|
from os.path import isabs
|
24
|
-
from typing import TYPE_CHECKING
|
25
|
+
from typing import TYPE_CHECKING
|
25
26
|
|
26
27
|
from flask import Flask
|
28
|
+
from sqlalchemy.engine import make_url
|
27
29
|
|
28
30
|
import airflow
|
29
31
|
from airflow.configuration import conf
|
30
32
|
from airflow.exceptions import AirflowConfigException
|
31
|
-
from airflow.www.
|
32
|
-
from airflow.www.extensions.
|
33
|
-
from airflow.www.extensions.
|
34
|
-
from airflow.www.extensions.init_views import init_plugins
|
33
|
+
from airflow.providers.fab.www.extensions.init_appbuilder import init_appbuilder
|
34
|
+
from airflow.providers.fab.www.extensions.init_session import init_airflow_session_interface
|
35
|
+
from airflow.providers.fab.www.extensions.init_views import init_plugins
|
35
36
|
|
36
37
|
if TYPE_CHECKING:
|
37
|
-
from airflow.www.extensions.init_appbuilder import AirflowAppBuilder
|
38
|
+
from airflow.providers.fab.www.extensions.init_appbuilder import AirflowAppBuilder
|
38
39
|
|
39
40
|
|
40
|
-
@
|
41
|
+
@cache
|
41
42
|
def _return_appbuilder(app: Flask) -> AirflowAppBuilder:
|
42
43
|
"""Return an appbuilder instance for the given app."""
|
43
|
-
init_appbuilder(app)
|
44
|
+
init_appbuilder(app, enable_plugins=False)
|
44
45
|
init_plugins(app)
|
45
46
|
init_airflow_session_interface(app)
|
46
47
|
return app.appbuilder # type: ignore[attr-defined]
|