Skip to content

Commit 91f9a68

Browse files
committed
Add ntlm authentication mode
1 parent 43d9cca commit 91f9a68

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
jsonpath_ng
2+
requests_ntlm==1.1.0

parameter-sets/credential/parameter-set.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
{
3939
"value": "bearer_token",
4040
"label": "Bearer token"
41+
},
42+
{
43+
"value": "ntlm",
44+
"label": "NTLM"
4145
}
4246
]
4347
},
@@ -46,14 +50,14 @@
4650
"label": "User name",
4751
"description": "Can be reused as {{username}}",
4852
"type": "STRING",
49-
"visibilityCondition": "model.login_type == 'basic_login'"
53+
"visibilityCondition": "['basic_login', 'ntlm'].includes(model.login_type)"
5054
},
5155
{
5256
"name": "password",
5357
"label": "Password",
5458
"description": "Can be reused as {{password}}",
5559
"type": "PASSWORD",
56-
"visibilityCondition": "model.login_type == 'basic_login'"
60+
"visibilityCondition": "['basic_login', 'ntlm'].includes(model.login_type)"
5761
},
5862
{
5963
"name": "token",

python-lib/rest_api_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,16 @@ def __init__(self, credential, endpoint, custom_key_values={}):
9292
def set_login(self, credential):
9393
login_type = credential.get("login_type", "no_auth")
9494
if login_type == "basic_login":
95-
self.username = credential.get("username", "")
96-
self.password = credential.get("password", "")
97-
self.auth = (self.username, self.password)
98-
self.requests_kwargs.update({"auth": self.auth})
95+
username = credential.get("username", "")
96+
password = credential.get("password", "")
97+
auth = (username, password)
98+
self.requests_kwargs.update({"auth": auth})
99+
if login_type == "ntlm":
100+
from requests_ntlm import HttpNtlmAuth
101+
username = credential.get("username", "")
102+
password = credential.get("password", "")
103+
auth = HttpNtlmAuth(username, password)
104+
self.requests_kwargs.update({"auth": auth})
99105
if login_type == "bearer_token":
100106
token = credential.get("token", "")
101107
bearer_template = credential.get("bearer_template", "Bearer {{token}}")

0 commit comments

Comments
 (0)