1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

keycloak: Provide meaningful error message to user (#1487) (#1489)

When user provides auth URL value which does not startswith
http or https protocol schema, provide a meaningful error message
stating so.

Fixes: #331

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit f37eb12580)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
patchback[bot] 2020-12-15 06:39:47 +01:00 committed by GitHub
parent aaf42f3646
commit 777a741d4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -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).

View file

@ -75,6 +75,8 @@ class KeycloakError(Exception):
def get_token(base_url, validate_certs, auth_realm, client_id, def get_token(base_url, validate_certs, auth_realm, client_id,
auth_username, auth_password, client_secret): 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) auth_url = URL_TOKEN.format(url=base_url, realm=auth_realm)
temp_payload = { temp_payload = {
'grant_type': 'password', 'grant_type': 'password',