Skip to content

Commit

Permalink
ignored auth headers for login resource
Browse files Browse the repository at this point in the history
  • Loading branch information
sumanth-lingappa committed Apr 29, 2024
1 parent ddf000a commit 017ab88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions plugins/module_utils/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@


class NitroAPIClient(object):
def __init__(self, module):
def __init__(self, module, resource_name):
self._module = module
self.check_mode = module.check_mode # Dry run mode
self.api_path = self._module.params.get("api_path")
self.resource_name = resource_name

# Prepare the http headers according to module arguments
self._headers = {}
Expand All @@ -46,9 +47,13 @@ def __init__(self, module):
elif have_userpass:
self._headers["X-NITRO-USER"] = self._module.params["nitro_user"]
self._headers["X-NITRO-PASS"] = self._module.params["nitro_pass"]
elif self.resource_name in {"login", "change_password"}:
# Do not set any authentication headers for the `login` resource
pass
else:
self._module.fail_json(
msg="Either `nitro_auth_token` or `nitro_user/nitro_pass` must be given for authentication"
msg="Either `nitro_auth_token` or `nitro_user/nitro_pass` must be given for authentication for the resource %s"
% self.resource_name
)

# Do header manipulation when using NetScaler Console (ADM) as proxy
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/module_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self, resource_name, supports_check_mode=True):
}:
self.module.params["api_path"] = "nitro/v2/config"

self.client = NitroAPIClient(self.module)
self.client = NitroAPIClient(self.module, self.resource_name)
self.ns_major_version, self.ns_minor_version = get_netscaler_version(
self.client
)
Expand Down

0 comments on commit 017ab88

Please sign in to comment.