Skip to content

Commit 0e04af6

Browse files
committed
Check Point Ansible Proxy Integration
1 parent b2b5bb0 commit 0e04af6

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

plugins/httpapi/checkpoint.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,10 @@ def __init__(self, connection):
8080
def login(self, username, password):
8181
payload = {}
8282
url = '/gaia_api/login'
83-
cp_domain = self.get_option('domain')
84-
cp_api_key = self.get_option('api_key')
85-
if cp_domain:
86-
payload['domain'] = cp_domain
87-
if username and password and not cp_api_key:
88-
payload['user'] = username
89-
payload['password'] = password
90-
elif cp_api_key and not username and not password:
91-
payload['api-key'] = cp_api_key
83+
if username and password:
84+
payload = {'user': username, 'password': password}
9285
else:
93-
raise AnsibleConnectionFailure('[Username and password] or api_key are required for login')
86+
raise AnsibleConnectionFailure('Username and password are required for login')
9487
if self.mgmt_proxy_enabled == True:
9588
url = '/web_api/login'
9689
response, response_data = self.send_request(url, payload)
@@ -100,9 +93,6 @@ def login(self, username, password):
10093
except KeyError:
10194
raise ConnectionError(
10295
'Server returned response without token info during connection authentication: %s' % response_data)
103-
# Case of read-only
104-
if 'uid' in response_data.keys():
105-
self.connection._session_uid = response_data['uid']
10696

10797
def logout(self):
10898
url = '/gaia_api/logout'
@@ -114,10 +104,7 @@ def get_session_uid(self):
114104
return self.connection._session_uid
115105

116106
def send_request(self, path, body_params):
117-
cp_cloud_mgmt_id = self.get_option('cloud_mgmt_id')
118-
if cp_cloud_mgmt_id:
119-
path = '/' + cp_cloud_mgmt_id + path
120-
# we only replace gaia_ip/ with web_api/gaia-api/ if target is set and path contails for gaia_ip/
107+
# we only replace gaia_ip/ with web_api/gaia-api/ if target is set and path contains for gaia_ip/
121108
cp_api_target = self.get_option('cptarget')
122109
if 'gaia_api/' in path: # Avoid login/logut requests in case of web_api
123110
if self.mgmt_proxy_enabled == True:

0 commit comments

Comments
 (0)