This is an automated email from the ASF dual-hosted git repository. vincbeck pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new c7104f53b9 Move user and roles schemas to fab provider (#42869) c7104f53b9 is described below commit c7104f53b9fbb0795822745848824fe322acd2f7 Author: Vincent <97131062+vincb...@users.noreply.github.com> AuthorDate: Thu Oct 10 09:08:42 2024 -0400 Move user and roles schemas to fab provider (#42869) --- .../api_endpoints/role_and_permission_endpoint.py | 6 +++--- .../fab/auth_manager/api_endpoints/user_endpoint.py | 6 +++--- .../providers/fab/auth_manager/schemas/__init__.py | 16 ++++++++++++++++ .../auth_manager}/schemas/role_and_permission_schema.py | 0 .../providers/fab/auth_manager}/schemas/user_schema.py | 2 +- providers/tests/fab/auth_manager/schemas/__init__.py | 17 +++++++++++++++++ .../test_role_and_permission_schema.py | 2 +- .../{api_endpoints => schemas}/test_user_schema.py | 5 ++++- 8 files changed, 45 insertions(+), 9 deletions(-) diff --git a/providers/src/airflow/providers/fab/auth_manager/api_endpoints/role_and_permission_endpoint.py b/providers/src/airflow/providers/fab/auth_manager/api_endpoints/role_and_permission_endpoint.py index ed42f91163..121a88be28 100644 --- a/providers/src/airflow/providers/fab/auth_manager/api_endpoints/role_and_permission_endpoint.py +++ b/providers/src/airflow/providers/fab/auth_manager/api_endpoints/role_and_permission_endpoint.py @@ -26,15 +26,15 @@ from sqlalchemy import asc, desc, func, select from airflow.api_connexion.exceptions import AlreadyExists, BadRequest, NotFound from airflow.api_connexion.parameters import check_limit, format_parameters -from airflow.api_connexion.schemas.role_and_permission_schema import ( +from airflow.api_connexion.security import requires_access_custom_view +from airflow.providers.fab.auth_manager.models import Action, Role +from airflow.providers.fab.auth_manager.schemas.role_and_permission_schema import ( ActionCollection, RoleCollection, action_collection_schema, role_collection_schema, role_schema, ) -from airflow.api_connexion.security import requires_access_custom_view -from airflow.providers.fab.auth_manager.models import Action, Role from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride from airflow.security import permissions from airflow.www.extensions.init_auth_manager import get_auth_manager diff --git a/providers/src/airflow/providers/fab/auth_manager/api_endpoints/user_endpoint.py b/providers/src/airflow/providers/fab/auth_manager/api_endpoints/user_endpoint.py index 665b7f52d8..43464a23d3 100644 --- a/providers/src/airflow/providers/fab/auth_manager/api_endpoints/user_endpoint.py +++ b/providers/src/airflow/providers/fab/auth_manager/api_endpoints/user_endpoint.py @@ -27,14 +27,14 @@ from werkzeug.security import generate_password_hash from airflow.api_connexion.exceptions import AlreadyExists, BadRequest, NotFound, Unknown from airflow.api_connexion.parameters import check_limit, format_parameters -from airflow.api_connexion.schemas.user_schema import ( +from airflow.api_connexion.security import requires_access_custom_view +from airflow.providers.fab.auth_manager.models import User +from airflow.providers.fab.auth_manager.schemas.user_schema import ( UserCollection, user_collection_item_schema, user_collection_schema, user_schema, ) -from airflow.api_connexion.security import requires_access_custom_view -from airflow.providers.fab.auth_manager.models import User from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride from airflow.security import permissions from airflow.www.extensions.init_auth_manager import get_auth_manager diff --git a/providers/src/airflow/providers/fab/auth_manager/schemas/__init__.py b/providers/src/airflow/providers/fab/auth_manager/schemas/__init__.py new file mode 100644 index 0000000000..13a83393a9 --- /dev/null +++ b/providers/src/airflow/providers/fab/auth_manager/schemas/__init__.py @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/airflow/api_connexion/schemas/role_and_permission_schema.py b/providers/src/airflow/providers/fab/auth_manager/schemas/role_and_permission_schema.py similarity index 100% rename from airflow/api_connexion/schemas/role_and_permission_schema.py rename to providers/src/airflow/providers/fab/auth_manager/schemas/role_and_permission_schema.py diff --git a/airflow/api_connexion/schemas/user_schema.py b/providers/src/airflow/providers/fab/auth_manager/schemas/user_schema.py similarity index 96% rename from airflow/api_connexion/schemas/user_schema.py rename to providers/src/airflow/providers/fab/auth_manager/schemas/user_schema.py index 167dd160d1..4155667d56 100644 --- a/airflow/api_connexion/schemas/user_schema.py +++ b/providers/src/airflow/providers/fab/auth_manager/schemas/user_schema.py @@ -22,8 +22,8 @@ from marshmallow import Schema, fields from marshmallow_sqlalchemy import SQLAlchemySchema, auto_field from airflow.api_connexion.parameters import validate_istimezone -from airflow.api_connexion.schemas.role_and_permission_schema import RoleSchema from airflow.providers.fab.auth_manager.models import User +from airflow.providers.fab.auth_manager.schemas.role_and_permission_schema import RoleSchema class UserCollectionItemSchema(SQLAlchemySchema): diff --git a/providers/tests/fab/auth_manager/schemas/__init__.py b/providers/tests/fab/auth_manager/schemas/__init__.py new file mode 100644 index 0000000000..217e5db960 --- /dev/null +++ b/providers/tests/fab/auth_manager/schemas/__init__.py @@ -0,0 +1,17 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/providers/tests/fab/auth_manager/api_endpoints/test_role_and_permission_schema.py b/providers/tests/fab/auth_manager/schemas/test_role_and_permission_schema.py similarity index 97% rename from providers/tests/fab/auth_manager/api_endpoints/test_role_and_permission_schema.py rename to providers/tests/fab/auth_manager/schemas/test_role_and_permission_schema.py index f5ec73a3e9..8e44c35546 100644 --- a/providers/tests/fab/auth_manager/api_endpoints/test_role_and_permission_schema.py +++ b/providers/tests/fab/auth_manager/schemas/test_role_and_permission_schema.py @@ -18,7 +18,7 @@ from __future__ import annotations import pytest -from airflow.api_connexion.schemas.role_and_permission_schema import ( +from airflow.providers.fab.auth_manager.schemas.role_and_permission_schema import ( RoleCollection, role_collection_schema, role_schema, diff --git a/providers/tests/fab/auth_manager/api_endpoints/test_user_schema.py b/providers/tests/fab/auth_manager/schemas/test_user_schema.py similarity index 97% rename from providers/tests/fab/auth_manager/api_endpoints/test_user_schema.py rename to providers/tests/fab/auth_manager/schemas/test_user_schema.py index b37f27abe0..648372d3ba 100644 --- a/providers/tests/fab/auth_manager/api_endpoints/test_user_schema.py +++ b/providers/tests/fab/auth_manager/schemas/test_user_schema.py @@ -24,8 +24,11 @@ from dev.tests_common.test_utils.compat import ignore_provider_compatibility_err from providers.tests.fab.auth_manager.api_endpoints.api_connexion_utils import create_role, delete_role with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.api_connexion.schemas.user_schema import user_collection_item_schema, user_schema from airflow.providers.fab.auth_manager.models import User + from airflow.providers.fab.auth_manager.schemas.user_schema import ( + user_collection_item_schema, + user_schema, + ) TEST_EMAIL = "t...@example.org"