-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow configuration of KEYCLOAK_HOST_LOOPBACK env var (#942) No-Issue (cherry picked from commit b21faf4) * Add configuration for API access logging to dev environment (#946) * Add configuration for API access logging to dev environment No-Issue * Move configuration to dev/Dockerfile.base No-Issue (cherry picked from commit 858f53e) * Pass .compose.env variables to the containers (#947) docker compose allows `env_file` to be a list of .env files those files are loaded in order. It makes easier to have custom local settings. Ex: ``` PULP_GALAXY_ENABLE_API_ACCESS_LOG=true ``` will enable logs to be written to `/var/log/galaxy_api_access.log` No-Issue (cherry picked from commit 0edf87f) * Add controllers endpoint for listing connected controllers (#941) * Add controllers endpoint for listing connected controllers Issue: AAH-888 (cherry picked from commit f2d4092) * Attempt to fix Keycloak conditional settings using Dynaconf Hooks (#945) KEYCLOAK settings was not being loaded from /etc/pulp/settings.py Dynaconf hooks are available only on 3.1.6 Issue: AAH-915 (cherry picked from commit 0bf124a) * Enable keycloak SSO for podman login (#949) * Enable keycloak SSO for podman login (cherry picked from commit 9580c5d) Co-authored-by: ironfroggy <[email protected]> Co-authored-by: Brian McLaughlin <[email protected]> Co-authored-by: Bruno Rocha <[email protected]>
- Loading branch information
1 parent
5f7ffbb
commit 2d83cec
Showing
22 changed files
with
505 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add CONNECTED_ANSIBLE_CONTROLLERS setting which enables users to specify a list of controller instances that they wish to have galaxy ng connect to. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix keycloak setting not being loaded from /etc/pulp/settings.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Enable keycloak authentication using username and password for podman login. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ RUN set -ex; \ | |
|
||
USER root | ||
|
||
RUN dnf install -y gettext | ||
RUN dnf install -y gettext; | ||
|
||
USER galaxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.conf import settings | ||
from rest_framework.permissions import IsAuthenticated | ||
|
||
from galaxy_ng.app.api import base as api_base | ||
|
||
|
||
class ControllerListView(api_base.APIView): | ||
permission_classes = [IsAuthenticated] | ||
|
||
# Returns a paginated list. This will make this easier to upgrade to a | ||
# database setting down the line. | ||
def get(self, request, *args, **kwargs): | ||
host_filter = request.GET.get("host", None) | ||
host_icontains_filter = request.GET.get("host__icontains", None) | ||
|
||
controllers = [] | ||
for controller in settings.CONNECTED_ANSIBLE_CONTROLLERS: | ||
if host_filter and controller != host_filter: | ||
continue | ||
|
||
if host_icontains_filter and host_icontains_filter.lower() not in controller.lower(): | ||
continue | ||
|
||
controllers.append({"host": controller}) | ||
paginator = self.pagination_class() | ||
page = paginator.paginate_queryset(controllers, request, view=self) | ||
|
||
return paginator.get_paginated_response(page) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from requests import post as requests_post | ||
|
||
from django.conf import settings | ||
|
||
from rest_framework.authentication import BasicAuthentication | ||
|
||
from rest_framework import status as http_code | ||
from rest_framework import exceptions | ||
|
||
from social_django.utils import load_strategy | ||
from social_core.backends.keycloak import KeycloakOAuth2 | ||
|
||
from gettext import gettext as _ | ||
|
||
|
||
class KeycloakBasicAuth(BasicAuthentication): | ||
def authenticate_credentials(self, userid, password, request=None): | ||
payload = { | ||
'client_id': settings.SOCIAL_AUTH_KEYCLOAK_KEY, | ||
'client_secret': settings.SOCIAL_AUTH_KEYCLOAK_SECRET, | ||
'grant_type': 'password', | ||
'scope': 'openid', | ||
'username': userid, | ||
'password': password | ||
} | ||
headers = { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
} | ||
|
||
response = requests_post( | ||
url=settings.SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL, | ||
headers=headers, | ||
data=payload | ||
) | ||
|
||
if response.status_code == http_code.HTTP_200_OK: | ||
|
||
# load social auth django strategy | ||
strategy = load_strategy(request) | ||
backend = KeycloakOAuth2(strategy) | ||
|
||
token_data = backend.user_data(response.json()['access_token']) | ||
|
||
# The django social auth strategy uses data from the JWT token in the KeycloackOAuth2 | ||
# backend to create a new user and update it with the data from the token. This | ||
# should return a django user instance. | ||
user = strategy.authenticate(backend, response=token_data) | ||
|
||
if user is None: | ||
raise exceptions.AuthenticationFailed(_("Authentication failed.")) | ||
|
||
return (user, None) | ||
|
||
else: | ||
# If keycloak basic auth fails, try regular basic auth. | ||
return super().authenticate_credentials(userid, password, request) |
Oops, something went wrong.