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

[keycloak] use the old prefix by default #2300

Closed
wants to merge 7 commits into from
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
2 changes: 1 addition & 1 deletion galaxy_ng/app/dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def configure_keycloak(settings: Dynaconf) -> Dict[str, Any]:
# with /auth. In newer versions, that substring no longer exists.
# There is a setting which can re-add that substring to make
# a newer system operate similar to the old.
KEYCLOAK_KC_HTTP_RELATIVE_PATH = settings.get("KEYCLOAK_KC_HTTP_RELATIVE_PATH", default="")
KEYCLOAK_KC_HTTP_RELATIVE_PATH = settings.get("KEYCLOAK_KC_HTTP_RELATIVE_PATH", default="/auth")

SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL = \
settings.get("SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL", default=None)
Expand Down
29 changes: 24 additions & 5 deletions galaxy_ng/tests/unit/app/test_dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ def test_dynaconf_hooks_authentication_backends_and_classes(
"INSTALLED_APPS": ["social_django", "dynaconf_merge_unique"],
"KEYCLOAK_URL": "https://mykeycloak:1337",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL":
"https://mykeycloak:1337/realms/aap/protocol/openid-connect/auth/",
"https://mykeycloak:1337/auth/realms/aap/protocol/openid-connect/auth/",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL":
"https://mykeycloak:1337/realms/aap/protocol/openid-connect/token/",
"https://mykeycloak:1337/auth/realms/aap/protocol/openid-connect/token/",
"GALAXY_AUTH_KEYCLOAK_ENABLED": True,
"GALAXY_FEATURE_FLAGS__external_authentication": True,
"GALAXY_TOKEN_EXPIRATION": 1440,
Expand All @@ -369,17 +369,36 @@ def test_dynaconf_hooks_authentication_backends_and_classes(
(
True,
{
"KEYCLOAK_KC_HTTP_RELATIVE_PATH": "/auth",
"KEYCLOAK_KC_HTTP_RELATIVE_PATH": "",
"KEYCLOAK_PROTOCOL": "http",
"GALAXY_TOKEN_EXPIRATION": 0,
},
{
"INSTALLED_APPS": ["social_django", "dynaconf_merge_unique"],
"KEYCLOAK_URL": "http://mykeycloak:1337",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL":
"http://mykeycloak:1337/auth/realms/aap/protocol/openid-connect/auth/",
"http://mykeycloak:1337/realms/aap/protocol/openid-connect/auth/",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL":
"http://mykeycloak:1337/auth/realms/aap/protocol/openid-connect/token/",
"http://mykeycloak:1337/realms/aap/protocol/openid-connect/token/",
"GALAXY_AUTH_KEYCLOAK_ENABLED": True,
"GALAXY_FEATURE_FLAGS__external_authentication": True,
"GALAXY_TOKEN_EXPIRATION": 0,
},
),
(
True,
{
"KEYCLOAK_KC_HTTP_RELATIVE_PATH": "/mylittlepony",
"KEYCLOAK_PROTOCOL": "http",
"GALAXY_TOKEN_EXPIRATION": 0,
},
{
"INSTALLED_APPS": ["social_django", "dynaconf_merge_unique"],
"KEYCLOAK_URL": "http://mykeycloak:1337",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL":
"http://mykeycloak:1337/mylittlepony/realms/aap/protocol/openid-connect/auth/",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL":
"http://mykeycloak:1337/mylittlepony/realms/aap/protocol/openid-connect/token/",
"GALAXY_AUTH_KEYCLOAK_ENABLED": True,
"GALAXY_FEATURE_FLAGS__external_authentication": True,
"GALAXY_TOKEN_EXPIRATION": 0,
Expand Down
7 changes: 4 additions & 3 deletions profiles/keycloak/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
# - "UI_EXTERNAL_LOGIN_URI={API_PROTOCOL}://{API_HOST}:{API_PORT}/login"

keycloak:
#image: quay.io/keycloak/keycloak:legacy
image: quay.io/keycloak/keycloak:latest
image: quay.io/keycloak/keycloak:legacy
#image: quay.io/keycloak/keycloak:latest
environment:
- DB_VENDOR=POSTGRES
- DB_ADDR=kc-postgres
Expand All @@ -25,12 +25,13 @@ services:
- KEYCLOAK_ADMIN_PASSWORD=admin
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
#- KC_HTTP_RELATIVE_PATH=/auth
ports:
- 8080:8080
depends_on:
- kc-postgres
- ldap
command: ['start-dev']
#command: ['start-dev']

kc-postgres:
image: "postgres:12"
Expand Down
37 changes: 12 additions & 25 deletions profiles/keycloak/keycloak-playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
- name: Create or update AAP Keycloak realm
community.general.keycloak_realm:
auth_client_id: admin-cli
#auth_keycloak_url: http://keycloak:8080/auth
auth_keycloak_url: http://keycloak:8080
#auth_keycloak_url: http://localhost:8080
auth_keycloak_url: http://keycloak:8080/auth
auth_realm: master
auth_username: admin
auth_password: admin
Expand All @@ -33,8 +31,7 @@
- name: Create or update a Keycloak client
community.general.keycloak_client:
auth_client_id: admin-cli
#auth_keycloak_url: http://keycloak:8080/auth
auth_keycloak_url: http://keycloak:8080
auth_keycloak_url: http://keycloak:8080/auth
auth_realm: master
auth_username: admin
auth_password: admin
Expand Down Expand Up @@ -161,8 +158,7 @@

- name: Create Token for service Keycloak
uri:
#url: "http://keycloak:8080/auth/realms/master/protocol/openid-connect/token"
url: "http://keycloak:8080/realms/master/protocol/openid-connect/token"
url: "http://keycloak:8080/auth/realms/master/protocol/openid-connect/token"
method: POST
body_format: form-urlencoded
body:
Expand Down Expand Up @@ -240,8 +236,7 @@

- name: Create LDAP configuration
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/components"
url: "http://keycloak:8080/admin/realms/aap/components"
url: "http://keycloak:8080/auth/admin/realms/aap/components"
method: POST
body_format: json
body: "{{ ldap_config | to_json }}"
Expand All @@ -256,8 +251,7 @@

- name: Get components
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/components?parent=aap&type=org.keycloak.storage.UserStorageProvider"
url: "http://keycloak:8080/admin/realms/aap/components?parent=aap&type=org.keycloak.storage.UserStorageProvider"
url: "http://keycloak:8080/auth/admin/realms/aap/components?parent=aap&type=org.keycloak.storage.UserStorageProvider"
method: GET
status_code:
- 200
Expand Down Expand Up @@ -308,8 +302,7 @@

- name: Create LDAP group mapping
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/components"
url: "http://keycloak:8080/admin/realms/aap/components"
url: "http://keycloak:8080/auth/admin/realms/aap/components"
method: POST
body_format: json
body: "{{ ldap_group_mapper | to_json }}"
Expand All @@ -324,8 +317,7 @@

- name: Get group mapper identifier
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/components?parent={{ ldap_id }}&type=org.keycloak.storage.ldap.mappers.LDAPStorageMapper&name=group"
url: "http://keycloak:8080/admin/realms/aap/components?parent={{ ldap_id }}&type=org.keycloak.storage.ldap.mappers.LDAPStorageMapper&name=group"
url: "http://keycloak:8080/auth/admin/realms/aap/components?parent={{ ldap_id }}&type=org.keycloak.storage.ldap.mappers.LDAPStorageMapper&name=group"
method: GET
status_code:
- 200
Expand All @@ -341,8 +333,7 @@

- name: Sync LDAP users
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/user-storage/{{ ldap_id }}/sync?action=triggerFullSync"
url: "http://keycloak:8080/admin/realms/aap/user-storage/{{ ldap_id }}/sync?action=triggerFullSync"
url: "http://keycloak:8080/auth/admin/realms/aap/user-storage/{{ ldap_id }}/sync?action=triggerFullSync"
method: POST
status_code:
- 200
Expand All @@ -354,8 +345,7 @@

- name: Sync LDAP groups
uri:
#url: "http://keycloak:8080/auth/admin/realms/aap/user-storage/{{ ldap_id }}/mappers/{{ keycloak_ldap_group_mapper_id }}/sync?direction=fedToKeycloak"
url: "http://keycloak:8080/admin/realms/aap/user-storage/{{ ldap_id }}/mappers/{{ keycloak_ldap_group_mapper_id }}/sync?direction=fedToKeycloak"
url: "http://keycloak:8080/auth/admin/realms/aap/user-storage/{{ ldap_id }}/mappers/{{ keycloak_ldap_group_mapper_id }}/sync?direction=fedToKeycloak"
method: POST
status_code:
- 200
Expand All @@ -373,8 +363,7 @@
client_id: automation-hub
state: present
auth_client_id: admin-cli
#auth_keycloak_url: http://keycloak:8080/auth
auth_keycloak_url: http://keycloak:8080
auth_keycloak_url: http://keycloak:8080/auth
auth_realm: master
auth_username: admin
auth_password: admin
Expand All @@ -390,17 +379,15 @@
client_id: automation-hub
state: present
auth_client_id: admin-cli
#auth_keycloak_url: http://keycloak:8080/auth
auth_keycloak_url: http://keycloak:8080
auth_keycloak_url: http://keycloak:8080/auth
auth_realm: master
auth_username: admin
auth_password: admin
# loop: "{{ user_list.json}}"

- name: Get realm public key
uri:
#url: "http://keycloak:8080/auth/realms/aap"
url: "http://keycloak:8080/realms/aap"
url: "http://keycloak:8080/auth/realms/aap"
method: GET
status_code:
- 200
Expand Down
1 change: 1 addition & 0 deletions profiles/keycloak/pulp_config.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PULP_KEYCLOAK_PORT=8080
PULP_KEYCLOAK_REALM=aap

KEYCLOAK_REDIRECT_URL="{API_PROTOCOL}://{API_HOST}:{API_PORT}/"
# PULP_KEYCLOAK_KC_HTTP_RELATIVE_PATH=""

# Integration test settings
HUB_TEST_AUTHENTICATION_BACKEND="keycloak"
Expand Down
Loading