Skip to content

Commit f149ae5

Browse files
committed
add support for login with api key, with function LoginWithApiKey()
1 parent 0e02ac6 commit f149ae5

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

APIFiles/APIClient.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version 1.0
55
A library for communicating with Check Point's management server using Golang
66
written by: Check Point software technologies inc.
77
June 2019
8-
tested with Check Point R80.20 (tested with take hero2 198)
8+
tested with Check Point R81.20
99
1010
-----------------------------------------------------------------------------
1111
@@ -190,6 +190,30 @@ func (c *ApiClient) Login(username string, password string, continueLastSession
190190
"user": username,
191191
"password": password,
192192
}
193+
return c.commonLoginLogic(credentials, continueLastSession, domain, readOnly, payload)
194+
}
195+
196+
/*
197+
performs a 'login' API call to the management server
198+
199+
api_key: Check Point api-key
200+
continue_last_session: [optional] It is possible to continue the last Check Point session
201+
or to create a new one
202+
domain: [optional] The name, UID or IP-Address of the domain to login.
203+
read_only: [optional] Login with Read Only permissions. This parameter is not considered in case
204+
continue-last-session is true.
205+
payload: [optional] More settings for the login command
206+
returns: APIResponse object
207+
side-effects: updates the class's uid and server variables
208+
*/
209+
func (c *ApiClient) LoginWithApiKey(apiKey string, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
210+
credentials := map[string]interface{}{
211+
"api-key": apiKey,
212+
}
213+
return c.commonLoginLogic(credentials, continueLastSession, domain, readOnly, payload)
214+
}
215+
216+
func (c *ApiClient) commonLoginLogic(credentials map[string]interface{}, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
193217

194218
if c.context == WebContext {
195219
credentials["continue-last-session"] = continueLastSession

0 commit comments

Comments
 (0)