Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable DAB resource registry #2106

Closed
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
12 changes: 12 additions & 0 deletions galaxy_ng/app/dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def post(settings: Dynaconf) -> Dict[str, Any]:
data.update(configure_password_validators(settings))
data.update(configure_api_base_path(settings))
data.update(configure_legacy_roles(settings))
data.update(configure_dab_resource_registry(settings))

# This should go last, and it needs to receive the data from the previous configuration
# functions because this function configures the rest framework auth classes based off
Expand All @@ -55,6 +56,17 @@ def post(settings: Dynaconf) -> Dict[str, Any]:
return data


def configure_dab_resource_registry(settings: Dynaconf) -> Dict[str, Any]:
flags = settings.get("GALAXY_FEATURE_FLAGS")

data = {}
if flags["dab_resource_registry"]:
data["INSTALLED_APPS"] = ['ansible_base.resource_registry', 'dynaconf_merge']
data["ANSIBLE_BASE_RESOURCE_CONFIG_MODULE"] = "galaxy_ng.app.api.resource_api"

return data


def configure_keycloak(settings: Dynaconf) -> Dict[str, Any]:
"""Configure keycloak settings for galaxy.

Expand Down
3 changes: 1 addition & 2 deletions galaxy_ng/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

INSTALLED_APPS = [
'rest_framework.authtoken',
'ansible_base.resource_registry',
'dynaconf_merge',
]

Expand Down Expand Up @@ -102,6 +101,7 @@
'execution_environments': True, # False will make execution_environments endpoints 404
'legacy_roles': False,
'ai_deny_index': False, # False will make _ui/v1/ai_deny_index/ to 404
'dab_resource_registry': False,
}

AUTH_PASSWORD_VALIDATORS = [
Expand Down Expand Up @@ -298,7 +298,6 @@
GALAXY_DYNAMIC_SETTINGS = False

# DJANGO ANSIBLE BASE RESOURCES REGISTRY SETTINGS
ANSIBLE_BASE_RESOURCE_CONFIG_MODULE = "galaxy_ng.app.api.resource_api"
ANSIBLE_BASE_ORGANIZATION_MODEL = "galaxy.Organization"

# WARNING: This setting is used in database migrations to create a default organization.
Expand Down
23 changes: 11 additions & 12 deletions galaxy_ng/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
from galaxy_ng.app.api import urls as api_urls
from galaxy_ng.ui import urls as ui_urls

from ansible_base.resource_registry.urls import (
urlpatterns as resource_api_urls,
)

from drf_spectacular.views import (
SpectacularJSONAPIView,
SpectacularYAMLAPIView,
Expand Down Expand Up @@ -49,21 +45,24 @@
name="swagger-ui",
),
path("healthz", views.health_view),
path(f"{API_PATH_PREFIX}", include(resource_api_urls))
]

if settings["GALAXY_FEATURE_FLAGS"]["dab_resource_registry"]:
from ansible_base.resource_registry.urls import (
urlpatterns as resource_api_urls,
)
urlpatterns.append(path(f"{API_PATH_PREFIX}/", include(resource_api_urls)))

if settings.get("API_ROOT") != "/pulp/":
urlpatterns.append(
path(
"pulp/api/<path:api_path>",
views.PulpAPIRedirectView.as_view(),
name="pulp_redirect")
path("pulp/api/<path:api_path>", views.PulpAPIRedirectView.as_view(), name="pulp_redirect")
)

if settings.get("SOCIAL_AUTH_KEYCLOAK_KEY"):
urlpatterns.append(url("", include("social_django.urls", namespace="social")))
urlpatterns.append(path("login/",
lambda request: redirect("/login/keycloak/", permanent=False)))
urlpatterns.append(
path("login/", lambda request: redirect("/login/keycloak/", permanent=False))
)

if settings.get("SOCIAL_AUTH_GITHUB_KEY"):
urlpatterns.append(url('', include('social_django.urls', namespace='github')))
urlpatterns.append(url("", include("social_django.urls", namespace="github")))
2 changes: 2 additions & 0 deletions profiles/dab/pulp_config.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ PULP_GALAXY_AUTHENTICATION_CLASSES="['ansible_base.jwt_consumer.hub.auth.HubJWTA
PULP_ANSIBLE_BASE_JWT_VALIDATE_CERT=false
PULP_ANSIBLE_BASE_JWT_KEY=https://localhost
PULP_CSRF_TRUSTED_ORIGINS = ['https://localhost']

PULP_GALAXY_FEATURE_FLAGS__dab_resource_registry=true
Loading