Skip to content

Commit 228d4b4

Browse files
authored
Merge pull request #26 from dataiku/feature/add-ntlm-auth
Add ntlm auth
2 parents 43ef72d + add45d2 commit 228d4b4

7 files changed

Lines changed: 25 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Changelog
22

33

4-
## [Version 1.0.7](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.0.7) - Bugfix release - 2022-08-30
4+
## [Version 1.1.0](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.1.0) - Feature and bugfix release - 2022-09-15
55

66
- Handling Offset pagination on APIs returning an array
77
- Fix throttling calculation
8+
- Allow dots in `Key to next request URL`
9+
- Add NTLM authentication
810

911
## [Version 1.0.6](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.0.6) - Feature and bugfix release - 2022-05-19
1012

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
jsonpath-ng==1.5.3
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",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "api-connect",
3-
"version": "1.0.7",
3+
"version": "1.1.0",
44
"meta": {
55
"label": "API Connect",
66
"description": "Retrieve data from any REST API",

python-lib/dku_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def parse_keys_for_json(items):
4747
def get_value_from_path(dictionary, path, default=None, can_raise=True):
4848
ret = copy.deepcopy(dictionary)
4949
for key in path:
50-
if key in ret and isinstance(ret, dict):
50+
if isinstance(ret, dict) and (key in ret):
5151
ret = ret.get(key)
5252
else:
5353
error_message = "The extraction path {} was not found in the incoming data".format(path)

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}}")

tests/python/integration/test_scenario.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ def test_run_api_connect_redirection(user_dss_clients):
3333

3434
def test_run_api_connect_check_sc_84465(user_dss_clients):
3535
dss_scenario.run(user_dss_clients, project_key=TEST_PROJECT_KEY, scenario_id="CHECKSC84465")
36+
37+
def test_run_api_connect_ntlm_authentication(user_dss_clients):
38+
dss_scenario.run(user_dss_clients, project_key=TEST_PROJECT_KEY, scenario_id="NTLMAUTHENTICATION")

0 commit comments

Comments
 (0)