diff --git a/changelogs/fragments/331_keycloak.yml b/changelogs/fragments/331_keycloak.yml new file mode 100644 index 0000000000..99c6474212 --- /dev/null +++ b/changelogs/fragments/331_keycloak.yml @@ -0,0 +1,2 @@ +bugfixes: +- keycloak module_utils - provide meaningful error message to user when auth URL does not start with http or https (https://github.com/ansible-collections/community.general/issues/331). diff --git a/plugins/module_utils/identity/keycloak/keycloak.py b/plugins/module_utils/identity/keycloak/keycloak.py index 5cab048dc8..1859d37d0e 100644 --- a/plugins/module_utils/identity/keycloak/keycloak.py +++ b/plugins/module_utils/identity/keycloak/keycloak.py @@ -75,6 +75,8 @@ class KeycloakError(Exception): def get_token(base_url, validate_certs, auth_realm, client_id, auth_username, auth_password, client_secret): + if not base_url.lower().startswith(('http', 'https')): + raise KeycloakError("auth_url '%s' should either start with 'http' or 'https'." % base_url) auth_url = URL_TOKEN.format(url=base_url, realm=auth_realm) temp_payload = { 'grant_type': 'password',