safe-t-rest
A ruby gem for Safe-T Box REST API
Basic usage:
gem install safe-t-rest
require 'safe-t-rest'
- Initialize a new instance (can be empty or set via parameters)
empty:
client = SafeTRest.new
set using hash:
client = SafeTRest.new(url: 'https://Safe-T/ui_api/login.aspx', user_name: 'test', password: '123', extension_id: '1', role_id: '0')
- Configure the client (if you initialized empty)
client.url = 'https://Safe-T_Box_Site.com/ui_api/login.aspx'
client.username = 'test'
client.password = '12345'
client.extension_id = '435-34534-24-234-6'
client.role_id = '00006'
puts client.get_apps_process_state('my_packge_GUID.123123')
puts client.get_package_file_list('my_packge_GUID.123123')
args = {
:files => 'file.txt',
:recipients => 'alexander.dan@safe-t.com',
:sender_name => 'Bar Hofesh',
:sender_address => 'bar.hofesh@safe-t.com',
:subject => 'Testing Ruby API',
:message => 'This is a Test message, just checking the Ruby API using REST',
:message_encryption_level => '0',
:delivery_method => '0',
:mobile_recipient => '',
:return_receipt => true,
:safe_reply => true,
:max_downloads => '3',
:package_expiry => '1440',
:folder_path => '',
:root_folder_id => '417'
}
client.safe_share_file(args)
args = {
:file_base64 => 'V29ya2luZyA6KQo=',
:file_name => 'file.txt',
:folder_path => '',
:root_folder_id => 417
}
client.file_upload(args)
args = {
:file_name => 'file.txt',
:folder_path => '',
:root_folder_id => 417
}
file = client.file_download(args)
file = Base64.decode64(file)
File.write('file.txt', file)
RegisterSession - return json flow
Overview
StatusCode=OK&StatusData=Base64Json
Base64Json:
{
"flow": [
"username_password",
"sms"
]
"token": [
"3434",
"7676"
]
}
if there is no token element, SDA need to generate token.
Scenarios
Scenario 1
-
Login to portal: (https://securemft/Safe-T/login.aspx)
-
SDA will send a rest call with URL and add sType :
https://securemft/Safe-T/login.aspx&sType=login
{"RoleID": "00006", "ExtensionID": "226602f2-4960-4542-a489-8250a551b804", "Username":"", "Password":"", "Method": "RegisterSession","Arguments": ["https://securemft/Safe-T/login.aspx&sType=login"]}
-
Return value:
StatusCode=OK&StatusData=
{
"flow": [
"username_password",
"sms"
]
}
-
Handle return value
- on submit , call iVerifyUserAccount add the submitted user name and password in base64 arguments:
first step : username_password - call iVerifyUserAccount (no need to call mobile - all against the same SDE Authentication app):
{
"RoleID": "00006",
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
"Username":"",
"Password":"",
"Method": "iVerifyUserAccount",
"Arguments": ["base64username","base64pass",true]
}
Return value:
OK:Q2xpZW50TW93NyI=
base64 string is "05977777777"
- If its ok + number :
go to second step
else handle retries and captcha
- if there is no number ? we need to ask alex\eithan.
- second step : sms - send sms to the ClientMobileNumber and validate it
else handle retries and captcha
Scenario 2
Any other case : https://securemft/Safe-T/login.aspx?folderType=x&(query_string_params) (packages related url's ,safe reply,package view, registration)
- SDA will call RegisterSession with URL param:
{
"RoleID": "00006",
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
"Username":"",
"Password":"",
"Method": "iVerifyUserAccount",
"Arguments": ["base64username","base64pass",true]
}
Return value:
in case of registers users:
StatusCode=OK&StatusData=
{
"flow": [
"username_password",
"sms"
]
"token": [
"3434",
"7676"
]
}
- Handle return :
if flow is :
"username_password",
"sms"
- Handle return value
- on submit , call iVerifyUserAccount add the submitted user name and password in base64 arguments:
first step : username_password - call iVerifyUserAccount (no need to call mobile - all against the same SDE Authentication app):
{
"RoleID": "00006",
"ExtensionID": "226602f2-4960-4542-a489-8250a551b804",
"Username":"",
"Password":"",
"Method": "iVerifyUserAccount",
"Arguments": ["base64username","base64pass",true]
}
Return value:
OK:Q2xpZW50TW93NyI=
base64 string is "05977777777"
- If its ok + number :
go to second step
else handle retries and captcha
- if there is no number ? we need to ask alex\eithan.
- second step : sms - send sms to the ClientMobileNumber and validate it
else handle retries and captcha
RubyDoc
http://www.rubydoc.info/github/bararchy/safe-t-rest/SafeTRest
- Added example client under /bin