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

PAPP-32932 Msscom: Feature - support for different authentication methods #12

Open
wants to merge 12 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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 LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ to true on SCOM server.
By default WinRM HTTP uses port 80. On Windows 7 and higher the default port is 5985.
By default WinRM HTTPS uses port 443. On Windows 7 and higher the default port is 5986.

This app uses NTLM authorization. The use of the HTTP_PROXY and HTTPS_PROXY environment variables is
This app uses NTLM authorization by default when FIPS is disabled and basic HTTP when FIPS is enabled.
In asset configuration other authentication methods are available.

The use of the HTTP_PROXY and HTTPS_PROXY environment variables is
currently unsupported.


Expand All @@ -44,6 +47,7 @@ VARIABLE | REQUIRED | TYPE | DESCRIPTION
**verify_server_cert** | optional | boolean | Verify server certificate
**username** | required | string | Username
**password** | required | password | Password
**auth_method** | optional | string | Authentication Method

### Supported Actions
[test connectivity](#action-test-connectivity) - Validate the asset configuration for connectivity using supplied configuration
Expand Down
5 changes: 4 additions & 1 deletion manual_readme_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ to true on SCOM server.
By default WinRM HTTP uses port 80. On Windows 7 and higher the default port is 5985.
By default WinRM HTTPS uses port 443. On Windows 7 and higher the default port is 5986.

This app uses NTLM authorization. The use of the HTTP_PROXY and HTTPS_PROXY environment variables is
This app uses NTLM authorization by default when FIPS is disabled and basic HTTP when FIPS is enabled.
In asset configuration other authentication methods are available.

The use of the HTTP_PROXY and HTTPS_PROXY environment variables is
currently unsupported.
104 changes: 97 additions & 7 deletions microsoftscom.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@
"data_type": "password",
"required": true,
"order": 3
},
"auth_method": {
"description": "Authentication Method",
"data_type": "string",
"default": "default",
"order": 4,
"required": false,
"value_list": [
"default",
"ssl",
"credssp",
"ntlm",
"basic"
]
}
},
"actions": [
Expand Down Expand Up @@ -1074,23 +1088,27 @@
"wheel": [
{
"module": "certifi",
"input_file": "wheels/py3/certifi-2023.7.22-py3-none-any.whl"
"input_file": "wheels/py3/certifi-2023.11.17-py3-none-any.whl"
},
{
"module": "cffi",
"input_file": "wheels/py39/cffi-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "charset_normalizer",
"input_file": "wheels/py39/charset_normalizer-3.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
"input_file": "wheels/py39/charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "cryptography",
"input_file": "wheels/py3/cryptography-41.0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
"input_file": "wheels/py3/cryptography-41.0.7-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "idna",
"input_file": "wheels/py3/idna-3.4-py3-none-any.whl"
"input_file": "wheels/py3/idna-3.6-py3-none-any.whl"
},
{
"module": "ntlm_auth",
"input_file": "wheels/shared/ntlm_auth-1.5.0-py2.py3-none-any.whl"
},
{
"module": "pycparser",
Expand All @@ -1108,22 +1126,94 @@
"module": "requests",
"input_file": "wheels/py3/requests-2.31.0-py3-none-any.whl"
},
{
"module": "requests_credssp",
"input_file": "wheels/shared/requests_credssp-2.0.0-py2.py3-none-any.whl"
},
{
"module": "requests_ntlm",
"input_file": "wheels/shared/requests_ntlm-1.1.0-py2.py3-none-any.whl"
},
{
"module": "six",
"input_file": "wheels/shared/six-1.16.0-py2.py3-none-any.whl"
},
{
"module": "urllib3",
"input_file": "wheels/py3/urllib3-2.1.0-py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.13.0-py2.py3-none-any.whl"
}
]
},
"pip_dependencies": {
"wheel": [
{
"module": "certifi",
"input_file": "wheels/py3/certifi-2023.11.17-py3-none-any.whl"
},
{
"module": "cffi",
"input_file": "wheels/py36/cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "charset_normalizer",
"input_file": "wheels/py3/charset_normalizer-2.0.12-py3-none-any.whl"
},
{
"module": "cryptography",
"input_file": "wheels/py36/cryptography-40.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "dataclasses",
"input_file": "wheels/py3/dataclasses-0.8-py3-none-any.whl"
},
{
"module": "idna",
"input_file": "wheels/py3/idna-3.6-py3-none-any.whl"
},
{
"module": "ntlm_auth",
"input_file": "wheels/shared/ntlm_auth-1.5.0-py2.py3-none-any.whl"
},
{
"module": "pycparser",
"input_file": "wheels/shared/pycparser-2.21-py2.py3-none-any.whl"
},
{
"module": "pyspnego",
"input_file": "wheels/shared/pyspnego-0.5.4-py2.py3-none-any.whl"
},
{
"module": "pywinrm",
"input_file": "wheels/shared/pywinrm-0.4.3-py2.py3-none-any.whl"
},
{
"module": "requests",
"input_file": "wheels/shared/requests-2.27.1-py2.py3-none-any.whl"
},
{
"module": "requests_credssp",
"input_file": "wheels/shared/requests_credssp-2.0.0-py2.py3-none-any.whl"
},
{
"module": "requests_ntlm",
"input_file": "wheels/py3/requests_ntlm-1.2.0-py3-none-any.whl"
"input_file": "wheels/shared/requests_ntlm-1.1.0-py2.py3-none-any.whl"
},
{
"module": "six",
"input_file": "wheels/shared/six-1.16.0-py2.py3-none-any.whl"
},
{
"module": "urllib3",
"input_file": "wheels/py3/urllib3-2.0.7-py3-none-any.whl"
"input_file": "wheels/shared/urllib3-1.26.18-py2.py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.13.0-py2.py3-none-any.whl"
}
]
}
}
}
29 changes: 18 additions & 11 deletions microsoftscom_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self):
# Configuration variables
self._server_url = None
self._username = None
self._auth_type = MSSCOM_DEFAULT_AUTH_METHOD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the other fields from config you've added be here as well?

self._password = None
self._verify_server_cert = False

Expand Down Expand Up @@ -82,28 +83,33 @@ def _get_fips_enabled(self):
self.debug_print("FIPS is not enabled")
return fips_enabled

def _execute_ps_command(self, action_result, ps_command):
""" This function is used to execute power shell command.

:param action_result: object of ActionResult
:param ps_command: power shell command
:return: output of executed power shell command
"""

resp_output = None
def _get_protocol(self):
server_cert_validation = 'ignore'
transport = 'ntlm'

if self._get_fips_enabled():
if self._auth_type != MSSCOM_DEFAULT_AUTH_METHOD:
transport = self._auth_type
elif self._get_fips_enabled():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as in #11

transport = 'basic'

if self._verify_server_cert:
server_cert_validation = 'validate'

protocol = Protocol(endpoint=MSSCOM_SERVER_URL.format(url=self._server_url), transport=transport,
return Protocol(endpoint=MSSCOM_SERVER_URL.format(url=self._server_url), transport=transport,
username=self._username, password=self._password,
server_cert_validation=server_cert_validation)

def _execute_ps_command(self, action_result, ps_command):
""" This function is used to execute power shell command.

:param action_result: object of ActionResult
:param ps_command: power shell command
:return: output of executed power shell command
"""

protocol = self._get_protocol()
resp_output = None

try:
shell_id = protocol.open_shell()
except InvalidCredentialsError as credentials_error:
Expand Down Expand Up @@ -374,6 +380,7 @@ def initialize(self):
self._server_url = config[MSSCOM_CONFIG_SERVER_URL].strip("/")
self._username = config[MSSCOM_CONFIG_USERNAME]
self._password = config[MSSCOM_CONFIG_PASSWORD]
self._auth_type = config[MSSCOM_CONFIG_AUTH_METHOD]

# Optional config parameter
self._verify_server_cert = config.get(MSSCOM_CONFIG_VERIFY_SSL, False)
Expand Down
4 changes: 4 additions & 0 deletions microsoftscom_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
MSSCOM_CONFIG_SERVER_URL = "server_url"
MSSCOM_CONFIG_USERNAME = "username"
MSSCOM_CONFIG_PASSWORD = "password" # pragma: allowlist secret
MSSCOM_CONFIG_AUTH_METHOD = "auth_method"
MSSCOM_CONFIG_VERIFY_SSL = "verify_server_cert"

MSSCOM_DEFAULT_AUTH_METHOD = "default"

MSSCOM_SERVER_URL = "{url}/wsman"
MSSCOM_CONNECTING_ENDPOINT_MSG = "Connecting to endpoint"
MSSCOM_ERROR_SERVER_CONNECTION = "Connection failed"
Expand Down
4 changes: 4 additions & 0 deletions release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
**Unreleased**

* [SOARHELP-2713] Authentication method selection is available in asset configuration.
* User can choose between: default, ssl, basic, credssp, ntlm.
* Default method means that while FIPS is enabled NTLM will be used, otherwise Basic HTTP will be applied
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pywinrm==0.4.3
requests_credssp==2.0.0
requests_ntlm==1.1.0
Binary file added wheels/py3/certifi-2023.11.17-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/certifi-2023.7.22-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added wheels/py3/dataclasses-0.8-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/idna-3.4-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/idna-3.6-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/requests_ntlm-1.2.0-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/urllib3-2.0.7-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/urllib3-2.1.0-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.