safe-t-rest 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +134 -1
- data/lib/safe-t-rest.rb +77 -22
- data/safe-t-rest.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c5b84f69704cc3219c72edf56c1ba6414f4c16f
|
4
|
+
data.tar.gz: 4fd84f0b0e8a60ab0053d49df5392e5a47956d22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b92c93fdb650e2ec8202a9b09fcb8eebb2f7461ab8af643628f6ae091dfe71f1ec868c6b4dc0f7f01c3fddcfb58b8178059d3d89b4a5b48f7ea320688ec7dc
|
7
|
+
data.tar.gz: 31ab84f5028d852037e9606c5e60dd38f031eeebd4c0b8b12159d46a9a1e0c13bbfb7a558b50940e65bb822ceb966be40ad21091e5f898a50d83c3a4ac806654
|
data/README.md
CHANGED
@@ -87,8 +87,141 @@ file = client.file_download(args) # Get back the file as a base64 string
|
|
87
87
|
file = Base64.decode64(file) # decode the string
|
88
88
|
File.write('file.txt', file) # write decoded file
|
89
89
|
```
|
90
|
+
* New API
|
91
|
+
# RegisterSession - return json flow
|
92
|
+
|
93
|
+
## Overview
|
94
|
+
|
95
|
+
```
|
96
|
+
StatusCode=OK&StatusData=Base64Json
|
97
|
+
```
|
98
|
+
Base64Json:
|
99
|
+
```json
|
100
|
+
{
|
101
|
+
"flow": [
|
102
|
+
"username_password",
|
103
|
+
"sms"
|
104
|
+
]
|
105
|
+
"token": [
|
106
|
+
"3434",
|
107
|
+
"7676"
|
108
|
+
]
|
109
|
+
}
|
110
|
+
if there is no token element, SDA need to generate token.
|
111
|
+
```
|
112
|
+
|
113
|
+
## Scenarios
|
114
|
+
|
115
|
+
### Scenario 1
|
116
|
+
|
117
|
+
- Login to portal: (https://securemft/Safe-T/login.aspx)
|
118
|
+
- SDA will send a rest call with URL and add sType :
|
119
|
+
`https://securemft/Safe-T/login.aspx&sType=login`
|
120
|
+
```json
|
121
|
+
{"RoleID": "00006", "ExtensionID": "226602f2-4960-4542-a489-8250a551b804", "Username":"", "Password":"", "Method": "RegisterSession","Arguments": ["https://securemft/Safe-T/login.aspx&sType=login"]}
|
122
|
+
```
|
123
|
+
|
124
|
+
- Return value:
|
125
|
+
`StatusCode=OK&StatusData=`
|
126
|
+
```json
|
127
|
+
{
|
128
|
+
"flow": [
|
129
|
+
"username_password",
|
130
|
+
"sms"
|
131
|
+
]
|
132
|
+
}
|
133
|
+
```
|
134
|
+
- Handle return value
|
135
|
+
- on submit , call iVerifyUserAccount add the submitted user name and password in base64 arguments:
|
136
|
+
first step : username_password - call iVerifyUserAccount (no need to call mobile - all against the same SDE Authentication app):
|
137
|
+
|
138
|
+
```json
|
139
|
+
{
|
140
|
+
"RoleID": "00006",
|
141
|
+
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
|
142
|
+
"Username":"",
|
143
|
+
"Password":"",
|
144
|
+
"Method": "iVerifyUserAccount",
|
145
|
+
"Arguments": ["base64username","base64pass",true]
|
146
|
+
}
|
147
|
+
```
|
148
|
+
Return value:
|
149
|
+
OK:Q2xpZW50TW93NyI=
|
150
|
+
base64 string is "05977777777"
|
151
|
+
|
152
|
+
- If its ok + number :
|
153
|
+
go to second step
|
154
|
+
else handle retries and captcha
|
155
|
+
- if there is no number ? we need to ask alex\eithan.
|
156
|
+
|
157
|
+
- second step : sms - send sms to the ClientMobileNumber and validate it
|
158
|
+
else handle retries and captcha
|
159
|
+
|
160
|
+
### Scenario 2
|
161
|
+
Any other case : https://securemft/Safe-T/login.aspx?folderType=x&(query_string_params) (packages related url's ,safe reply,package view, registration)
|
162
|
+
|
163
|
+
1. SDA will call RegisterSession with URL param:
|
164
|
+
|
165
|
+
```json
|
166
|
+
{
|
167
|
+
"RoleID": "00006",
|
168
|
+
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
|
169
|
+
"Username":"",
|
170
|
+
"Password":"",
|
171
|
+
"Method": "iVerifyUserAccount",
|
172
|
+
"Arguments": ["base64username","base64pass",true]
|
173
|
+
}
|
174
|
+
```
|
175
|
+
|
176
|
+
Return value:
|
177
|
+
|
178
|
+
in case of registers users:
|
179
|
+
`StatusCode=OK&StatusData=`
|
180
|
+
```json
|
181
|
+
{
|
182
|
+
"flow": [
|
183
|
+
"username_password",
|
184
|
+
"sms"
|
185
|
+
]
|
186
|
+
"token": [
|
187
|
+
"3434",
|
188
|
+
"7676"
|
189
|
+
]
|
190
|
+
}
|
191
|
+
```
|
192
|
+
|
193
|
+
2. Handle return :
|
194
|
+
```ruby
|
195
|
+
if flow is :
|
196
|
+
"username_password",
|
197
|
+
"sms"
|
198
|
+
```
|
199
|
+
- Handle return value
|
200
|
+
- on submit , call iVerifyUserAccount add the submitted user name and password in base64 arguments:
|
201
|
+
first step : username_password - call iVerifyUserAccount (no need to call mobile - all against the same SDE Authentication app):
|
202
|
+
```json
|
203
|
+
{
|
204
|
+
"RoleID": "00006",
|
205
|
+
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
|
206
|
+
"Username":"",
|
207
|
+
"Password":"",
|
208
|
+
"Method": "iVerifyUserAccount",
|
209
|
+
"Arguments": ["base64username","base64pass",true]
|
210
|
+
}
|
211
|
+
|
212
|
+
Return value:
|
213
|
+
OK:Q2xpZW50TW93NyI=
|
214
|
+
base64 string is "05977777777"
|
215
|
+
|
216
|
+
- If its ok + number :
|
217
|
+
go to second step
|
218
|
+
else handle retries and captcha
|
219
|
+
- if there is no number ? we need to ask alex\eithan.
|
220
|
+
|
221
|
+
- second step : sms - send sms to the ClientMobileNumber and validate it
|
222
|
+
else handle retries and captcha
|
90
223
|
|
91
224
|
# RubyDoc
|
92
225
|
http://www.rubydoc.info/github/bararchy/safe-t-rest/SafeTRest
|
93
226
|
|
94
|
-
* Added example client under /bin
|
227
|
+
* Added example client under /bin
|
data/lib/safe-t-rest.rb
CHANGED
@@ -1,72 +1,127 @@
|
|
1
1
|
require 'rest-client'
|
2
|
+
require 'base64'
|
3
|
+
require 'json'
|
2
4
|
|
3
5
|
class SafeTRest
|
4
|
-
attr_accessor :extension_id, :user_name, :password, :url, :role_id
|
5
6
|
|
6
7
|
def initialize(config_hash={})
|
7
8
|
@extension_id = config_hash[:extension_id]
|
8
|
-
@user_name
|
9
|
-
@password
|
10
|
-
@url
|
11
|
-
@role_id
|
9
|
+
@user_name = Base64.strict_encode64(config_hash[:user_name])
|
10
|
+
@password = Base64.strict_encode64(config_hash[:password])
|
11
|
+
@url = config_hash[:url]
|
12
|
+
@role_id = config_hash[:role_id]
|
12
13
|
end
|
13
14
|
|
14
15
|
def get_apps_process_state(guid)
|
15
|
-
send_request("GetAppsProcessState
|
16
|
+
send_request("GetAppsProcessState", [guid, false])
|
16
17
|
end
|
17
18
|
|
18
19
|
def get_package_file_list(guid)
|
19
|
-
send_request("GetPackageFileList
|
20
|
+
send_request("GetPackageFileList",[guid])
|
20
21
|
end
|
21
22
|
|
22
23
|
def verify_user_account
|
23
|
-
send_request("iVerifyUserAccount
|
24
|
+
response = send_request("iVerifyUserAccount",[@user_name, @password, true])
|
25
|
+
status, message = response.split(':')
|
26
|
+
case status.downcase
|
27
|
+
when 'ok'
|
28
|
+
return Base64.decode64(message)
|
29
|
+
when 'error'
|
30
|
+
raise SafeTError.new(Base64.decode64(message))
|
31
|
+
else
|
32
|
+
raise SafeTError.new("Non-Standard status #{status}:#{Base64.decode64(message)}")
|
33
|
+
end
|
24
34
|
end
|
25
35
|
|
26
36
|
def get_user_history(days)
|
27
|
-
send_request("iGetHistory
|
37
|
+
send_request("iGetHistory", [@user_name, @password, days])
|
28
38
|
end
|
29
39
|
|
30
40
|
def user_account_address_list
|
31
|
-
send_request("iUserAccountAddressList
|
41
|
+
send_request("iUserAccountAddressList",[@user_name, @password])
|
32
42
|
end
|
33
43
|
|
34
44
|
def get_folder_list(path)
|
35
|
-
send_request("iGetFolderList
|
45
|
+
send_request("iGetFolderList",[@user_name, @password, false, true, path, 417])
|
36
46
|
end
|
37
47
|
|
38
48
|
def safe_share_file(args)
|
39
|
-
send_request("iSafeShareFile:
|
49
|
+
send_request("iSafeShareFile:",[
|
50
|
+
@user_name,
|
51
|
+
@password,
|
52
|
+
args[:files],
|
53
|
+
args[:recipients],
|
54
|
+
args[:sender_name],
|
55
|
+
args[:sender_address],
|
56
|
+
args[:subject],
|
57
|
+
args[:message],
|
58
|
+
args[:message_encryption_level],
|
59
|
+
args[:delivery_method],
|
60
|
+
args[:mobile_recipient],
|
61
|
+
args[:return_receipt],
|
62
|
+
args[:safe_reply],
|
63
|
+
args[:max_downloads],
|
64
|
+
args[:package_expiry],
|
65
|
+
args[:folder_path],
|
66
|
+
args[:root_folder_id]
|
67
|
+
])
|
40
68
|
end
|
41
69
|
|
42
70
|
def file_upload(args)
|
43
|
-
send_request("iFileUpload
|
71
|
+
send_request("iFileUpload",[
|
72
|
+
@user_name,
|
73
|
+
@password,
|
74
|
+
args[:file_base64],
|
75
|
+
args[:file_name],
|
76
|
+
args[:folder_path],
|
77
|
+
args[:root_folder_id]
|
78
|
+
])
|
44
79
|
end
|
45
80
|
|
46
81
|
def file_download(args)
|
47
|
-
send_request("iFileDownload
|
82
|
+
send_request("iFileDownload",[
|
83
|
+
@user_name,
|
84
|
+
@password,
|
85
|
+
args[:file_name],
|
86
|
+
args[:folder_path],
|
87
|
+
args[:root_folder_id]
|
88
|
+
])
|
48
89
|
end
|
49
90
|
|
50
91
|
def register_session(url_string)
|
51
|
-
send_request("
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
92
|
+
response = send_request("RegisterSession",[url_string])
|
93
|
+
status, message = response.split(':')
|
94
|
+
case status.downcase
|
95
|
+
when 'ok'
|
96
|
+
return JSON.parse(Base64.decode64(message), symbolize_names: true)
|
97
|
+
when 'error'
|
98
|
+
raise SafeTError.new(Base64.decode64(message))
|
99
|
+
else
|
100
|
+
raise SafeTError.new("Non-Standard status #{status}:#{Base64.decode64(message)}")
|
101
|
+
end
|
56
102
|
end
|
57
103
|
|
58
104
|
private
|
59
105
|
|
60
|
-
def send_request(
|
106
|
+
def send_request(method, parameters)
|
61
107
|
RestClient::Request.execute(
|
62
108
|
:verify_ssl => false,
|
63
109
|
method: :post,
|
64
110
|
url: @url,
|
65
111
|
headers: {
|
66
112
|
servletRequestID: 'MethodRequest',
|
67
|
-
|
68
|
-
|
113
|
+
},
|
114
|
+
payload: {
|
115
|
+
"Username": "",
|
116
|
+
"Password": "",
|
117
|
+
"RoleID": "#{@role_id}",
|
118
|
+
"ExtensionID": "#{@extension_id}",
|
119
|
+
"Method": "#{method}",
|
120
|
+
"Arguments": parameters
|
121
|
+
}.to_json
|
69
122
|
)
|
70
123
|
end
|
71
124
|
end
|
72
125
|
|
126
|
+
class SafeTError < Exception; end
|
127
|
+
|
data/safe-t-rest.gemspec
CHANGED