Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion airflow/cli/commands/local_commands/standalone_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def initialize_database(self):
from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder

with get_application_builder() as appbuilder:
user_name, password = appbuilder.sm.create_admin_standalone()
if hasattr(appbuilder.sm, "create_admin_standalone"):
user_name, password = appbuilder.sm.create_admin_standalone()
# Store what we know about the user for printing later in startup
self.user_info = {"username": user_name, "password": password}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from connexion import FlaskApi
from fastapi import FastAPI
from flask import Blueprint, g, url_for
from packaging.version import Version
from sqlalchemy import select
from sqlalchemy.orm import Session, joinedload
from starlette.middleware.wsgi import WSGIMiddleware
Expand Down Expand Up @@ -89,7 +88,6 @@
)
from airflow.utils.session import NEW_SESSION, create_session, provide_session
from airflow.utils.yaml import safe_load
from airflow.version import version

if TYPE_CHECKING:
from airflow.auth.managers.base_auth_manager import ResourceMethod
Expand Down Expand Up @@ -240,14 +238,11 @@ def serialize_user(self, user: User) -> dict[str, Any]:
def is_logged_in(self) -> bool:
"""Return whether the user is logged in."""
user = self.get_user()
if Version(Version(version).base_version) < Version("3.0.0"):
return not user.is_anonymous and user.is_active
else:
return (
self.appbuilder
and self.appbuilder.get_app.config.get("AUTH_ROLE_PUBLIC", None)
or (not user.is_anonymous and user.is_active)
)
return (
self.appbuilder
and self.appbuilder.get_app.config.get("AUTH_ROLE_PUBLIC", None)
or (not user.is_anonymous and user.is_active)
)

def is_authorized_configuration(
self,
Expand Down Expand Up @@ -570,11 +565,7 @@ def _sync_appbuilder_roles(self):
# Otherwise, when the name of a view or menu is changed, the framework
# will add the new Views and Menus names to the backend, but will not
# delete the old ones.
if Version(Version(version).base_version) >= Version("3.0.0"):
fallback = None
else:
fallback = conf.getboolean("webserver", "UPDATE_FAB_PERMS")
if conf.getboolean("fab", "UPDATE_FAB_PERMS", fallback=fallback):
if conf.getboolean("fab", "UPDATE_FAB_PERMS"):
self.security_manager.sync_roles()


Expand Down
Loading