Source code for airflow.providers.fab.auth_manager.views.permissions
# 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.
from __future__ import annotations
from flask_appbuilder.security.views import (
    PermissionModelView,
    PermissionViewModelView,
    ViewMenuModelView,
)
from flask_babel import lazy_gettext
from airflow.security import permissions
[docs]class ActionModelView(PermissionModelView):
    """Customize permission names for FAB's builtin PermissionModelView."""
[docs]    class_permission_name = permissions.RESOURCE_ACTION 
[docs]    route_base = "/actions" 
[docs]    method_permission_name = {
        "list": "read",
    } 
[docs]    base_permissions = [
        permissions.ACTION_CAN_READ,
    ] 
[docs]    list_title = lazy_gettext("List Actions") 
[docs]    show_title = lazy_gettext("Show Action") 
[docs]    add_title = lazy_gettext("Add Action") 
[docs]    edit_title = lazy_gettext("Edit Action") 
[docs]    label_columns = {"name": lazy_gettext("Name")}  
[docs]class PermissionPairModelView(PermissionViewModelView):
    """Customize permission names for FAB's builtin PermissionViewModelView."""
[docs]    class_permission_name = permissions.RESOURCE_PERMISSION 
[docs]    route_base = "/permissions" 
[docs]    method_permission_name = {
        "list": "read",
    } 
[docs]    base_permissions = [
        permissions.ACTION_CAN_READ,
    ] 
[docs]    list_title = lazy_gettext("List Permissions") 
[docs]    show_title = lazy_gettext("Show Permission") 
[docs]    add_title = lazy_gettext("Add Permission") 
[docs]    edit_title = lazy_gettext("Edit Permission") 
[docs]    label_columns = {
        "action": lazy_gettext("Action"),
        "resource": lazy_gettext("Resource"),
    } 
[docs]    list_columns = ["action", "resource"]  
[docs]class ResourceModelView(ViewMenuModelView):
    """Customize permission names for FAB's builtin ViewMenuModelView."""
[docs]    class_permission_name = permissions.RESOURCE_RESOURCE 
[docs]    route_base = "/resources" 
[docs]    method_permission_name = {
        "list": "read",
    } 
[docs]    base_permissions = [
        permissions.ACTION_CAN_READ,
    ] 
[docs]    list_title = lazy_gettext("List Resources") 
[docs]    show_title = lazy_gettext("Show Resource") 
[docs]    add_title = lazy_gettext("Add Resource") 
[docs]    edit_title = lazy_gettext("Edit Resource") 
[docs]    label_columns = {"name": lazy_gettext("Name")}