class_docstr: Custom security manager, which introduces a permission model adapted to Airflow.
  
  It's named V2 to differentiate it from the obsolete airflow.www.security.AirflowSecurityManager.
class_docstr_tok: ["Custom","security","manager",",","which","introduces","a","permission","model","adapted","to","Airflow",".","It","'s","named","V2","to","differentiate","it","from","the","obsolete","airflow.www.security.AirflowSecurityManager","."]
docstr: Verify whether a given user could perform a certain action on the given resource.
  
  Example actions might include can_read, can_write, can_delete, etc.
  
  This function is called by FAB when accessing a view. See
  https://github.com/dpgaspar/Flask-AppBuilder/blob/c6fecdc551629e15467fde5d06b4437379d90592/flask_appbuilder/security/decorators.py#L134
  
  :param action_name: action_name on resource (e.g can_read, can_edit).
  :param resource_name: name of view-menu or resource.
  :param user: user
  :param resource_pk: the resource primary key (e.g. the connection ID)
  :return: Whether user could perform certain action on the resource.
docstr_tok: ["Verify","whether","a","given","user","could","perform","a","certain","action","on","the","given","resource",".","Example","actions","might","include","can_read",",","can_write",",","can_delete",",","etc",".","This","function","is","called","by","FAB","when","accessing","a","view",".","See","https",":","\/\/github.com\/dpgaspar\/Flask-AppBuilder\/blob\/c6fecdc551629e15467fde5d06b4437379d90592\/flask_appbuilder\/security\/decorators.py","#","L134",":","param","action_name",":","action_name","on","resource","(","e.g","can_read",",","can_edit",")",".",":","param","resource_name",":","name","of","view-menu","or","resource",".",":","param","user",":","user",":","param","resource_pk",":","the","resource","primary","key","(","e.g",".","the","connection","ID",")",":","return",":","Whether","user","could","perform","certain","action","on","the","resource","."]
code: def has_access(
      self,
      action_name: str,
      resource_name: str,
      user=None,
      resource_pk: str | None = None,
  ) -> bool:
      """
      Verify whether a given user could perform a certain action on the given resource.
  
      Example actions might include can_read, can_write, can_delete, etc.
  
      This function is called by FAB when accessing a view. See
      https://github.com/dpgaspar/Flask-AppBuilder/blob/c6fecdc551629e15467fde5d06b4437379d90592/flask_appbuilder/security/decorators.py#L134
  
      :param action_name: action_name on resource (e.g can_read, can_edit).
      :param resource_name: name of view-menu or resource.
      :param user: user
      :param resource_pk: the resource primary key (e.g. the connection ID)
      :return: Whether user could perform certain action on the resource.
      """
      if not user:
          user = g.user
  
      is_authorized_method = (
          self._get_auth_manager_is_authorized_method(resource_name)
      )
      return is_authorized_method(action_name, resource_pk, user)
  
imports: from __future__ import annotations
  import json
  from functools import cached_property
  from typing import TYPE_CHECKING, Callable
  from flask import g
  from flask_limiter import Limiter
  from flask_limiter.util import get_remote_address
  from sqlalchemy import select
  from airflow.auth.managers.models.resource_details import AccessView, ConnectionDetails, DagAccessEntity, DagDetails, PoolDetails, VariableDetails
  from airflow.auth.managers.utils.fab import get_method_from_fab_action_map
  from airflow.exceptions import AirflowException
  from airflow.models import Connection, DagRun, Pool, TaskInstance, Variable
  from airflow.security.permissions import ACTION_CAN_ACCESS_MENU, ACTION_CAN_READ, RESOURCE_ADMIN_MENU, RESOURCE_AUDIT_LOG, RESOURCE_BROWSE_MENU, RESOURCE_CLUSTER_ACTIVITY, RESOURCE_CONFIG, RESOURCE_CONNECTION, RESOURCE_DAG, RESOURCE_DAG_CODE, RESOURCE_DAG_DEPENDENCIES, RESOURCE_DAG_RUN, RESOURCE_DATASET, RESOURCE_DOCS, RESOURCE_DOCS_MENU, RESOURCE_JOB, RESOURCE_PLUGIN, RESOURCE_POOL, RESOURCE_PROVIDER, RESOURCE_SLA_MISS, RESOURCE_TASK_INSTANCE, RESOURCE_TASK_RESCHEDULE, RESOURCE_TRIGGER, RESOURCE_VARIABLE, RESOURCE_XCOM
  from airflow.utils.log.logging_mixin import LoggingMixin
  from airflow.utils.session import NEW_SESSION, provide_session
  from airflow.www.extensions.init_auth_manager import get_auth_manager
  from airflow.www.utils import CustomSQLAInterface
label_desc: Use image node_id 5 for calling the AirflowSecurityManagerV2 obj's underlying member method code with example usage: obj.has_access(action_name, resource_name, user, resource_pk) and returns: is_authorized_method