mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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:
parent
aaf42f3646
commit
777a741d4d
2 changed files with 4 additions and 0 deletions
2
changelogs/fragments/331_keycloak.yml
Normal file
2
changelogs/fragments/331_keycloak.yml
Normal 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).
|
|
@ -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',
|
||||||
|
|
Loading…
Reference in a new issue