login_radius 3.0.0 → 10.0.0.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +21 -0
- data/README.md +58 -52
- data/lib/login_radius.rb +30 -15
- data/lib/login_radius/api/account/account_api.rb +581 -0
- data/lib/login_radius/api/account/role_api.rb +330 -0
- data/lib/login_radius/api/account/sott_api.rb +47 -0
- data/lib/login_radius/api/advanced/configuration_api.rb +57 -0
- data/lib/login_radius/api/advanced/consent_management_api.rb +161 -0
- data/lib/login_radius/api/advanced/custom_object_api.rb +316 -0
- data/lib/login_radius/api/advanced/custom_registration_data_api.rb +195 -0
- data/lib/login_radius/api/advanced/multi_factor_authentication_api.rb +606 -0
- data/lib/login_radius/api/advanced/re_authentication_api.rb +243 -0
- data/lib/login_radius/api/advanced/web_hook_api.rb +101 -0
- data/lib/login_radius/api/authentication/authentication_api.rb +986 -0
- data/lib/login_radius/api/authentication/one_touch_login_api.rb +160 -0
- data/lib/login_radius/api/authentication/password_less_login_api.rb +158 -0
- data/lib/login_radius/api/authentication/phone_authentication_api.rb +329 -0
- data/lib/login_radius/api/authentication/pin_authentication_api.rb +316 -0
- data/lib/login_radius/api/authentication/risk_based_authentication_api.rb +286 -0
- data/lib/login_radius/api/authentication/smart_login_api.rb +146 -0
- data/lib/login_radius/api/social/native_social_api.rb +193 -0
- data/lib/login_radius/api/social/social_api.rb +802 -0
- data/lib/login_radius/error.rb +7 -0
- data/lib/login_radius/request_client.rb +295 -0
- data/lib/login_radius/response.rb +12 -0
- data/lib/login_radius/version.rb +3 -3
- data/login_radius.gemspec +36 -0
- metadata +61 -20
- data/LICENSE +0 -22
- data/lib/hash.rb +0 -12
- data/lib/login_radius/advanced_api.rb +0 -133
- data/lib/login_radius/authentication_api.rb +0 -597
- data/lib/login_radius/exception.rb +0 -4
- data/lib/login_radius/management_api.rb +0 -327
- data/lib/login_radius/rest_request.rb +0 -142
- data/lib/login_radius/social_api.rb +0 -402
- data/lib/login_radius/two_fa_api.rb +0 -191
- data/lib/string.rb +0 -8
@@ -1,327 +0,0 @@
|
|
1
|
-
module LoginRadius
|
2
|
-
module ManagementApi
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# ------------------------------------------------------------- Get API --------------------------------------------------------------------#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def accountIdentitiesByEmail(email)
|
11
|
-
return getRequest("identity/v2/manage/account/identities", {:apikey=> appkey,:apisecret=>appsecret,:email=>email},"api");
|
12
|
-
rescue LoginRadiusRaas::Exception => e
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
def userImpersonation(uid)
|
18
|
-
return getRequest("identity/v2/manage/account/access_token", {:apikey=> appkey,:apisecret=>appsecret,:uid=>uid},"api");
|
19
|
-
rescue LoginRadiusRaas::Exception => e
|
20
|
-
false
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def accountPassword(uid)
|
26
|
-
return getRequest("identity/v2/manage/account/"+uid+"/password", {:apikey=> appkey,:apisecret=>appsecret},"api");
|
27
|
-
rescue LoginRadiusRaas::Exception => e
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def accountProfileByEmail(email)
|
34
|
-
return getRequest("identity/v2/manage/account", {:apikey=> appkey,:apisecret=>appsecret,:email=>email},"api");
|
35
|
-
rescue LoginRadiusRaas::Exception => e
|
36
|
-
false
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
def accountProfileByUserName(username)
|
42
|
-
return getRequest("identity/v2/manage/account", {:apikey=> appkey,:apisecret=>appsecret,:username=>username},"api");
|
43
|
-
rescue LoginRadiusRaas::Exception => e
|
44
|
-
false
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
def accountProfileByPhone(phone)
|
49
|
-
return getRequest("identity/v2/manage/account", {:apikey=> appkey,:apisecret=>appsecret,:phone=>phone},"api");
|
50
|
-
rescue LoginRadiusRaas::Exception => e
|
51
|
-
false
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def accountProfileByUid(uid)
|
57
|
-
return getRequest("identity/v2/manage/account/"+uid, {:apikey=> appkey,:apisecret=>appsecret},"api");
|
58
|
-
rescue LoginRadiusRaas::Exception => e
|
59
|
-
false
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def getContextWithRolesAndPermissions(uid)
|
64
|
-
return getRequest("identity/v2/manage/account/"+uid+"/rolecontext", {:apikey=> appkey,:apisecret=>appsecret},"api");
|
65
|
-
rescue LoginRadiusRaas::Exception => e
|
66
|
-
false
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
def getRolesList()
|
71
|
-
return getRequest("identity/v2/manage/role", {:apikey=> appkey,:apisecret=>appsecret},"api");
|
72
|
-
rescue LoginRadiusRaas::Exception => e
|
73
|
-
false
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def getRolesByUid(uid)
|
78
|
-
return getRequest("identity/v2/manage/account/"+uid+"/role", {:apikey=> appkey,:apisecret=>appsecret},"api");
|
79
|
-
rescue LoginRadiusRaas::Exception => e
|
80
|
-
false
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
def getCustomObjectByObjectrecordIdAndUid(objectname,uid,objectrecordid)
|
86
|
-
return getRequest("identity/v2/manage/account/"+uid+"/customobject/"+objectrecordid, {:apikey=> appkey,:apisecret=>appsecret,:objectname=>objectname},"api");
|
87
|
-
rescue LoginRadiusRaas::Exception => e
|
88
|
-
false
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
def getCustomObjectByUid(objectname,uid)
|
93
|
-
return getRequest("identity/v2/manage/account/"+uid+"/customobject", {:apikey=> appkey,:apisecret=>appsecret,:objectname=>objectname},"api");
|
94
|
-
rescue LoginRadiusRaas::Exception => e
|
95
|
-
false
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
def generateSott(timedifference)
|
101
|
-
return getRequest("identity/v2/manage/account/sott", {:apikey=> appkey,:apisecret=>appsecret,:timedifference=>timedifference},"api");
|
102
|
-
rescue LoginRadiusRaas::Exception => e
|
103
|
-
false
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def getServerTime(timedifference)
|
108
|
-
return getRequest("identity/v2/serverinfo", {:apikey=> appkey,:timedifference=>timedifference},"api");
|
109
|
-
rescue LoginRadiusRaas::Exception => e
|
110
|
-
false
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
def getRegistrationData(type,parentid,skip,limit)
|
116
|
-
return getRequest("identity/v2/manage/registrationdata/"+type, {:apikey=> appkey,:parentid=>parentid,:skip=>skip,:limit=>limit},"api");
|
117
|
-
rescue LoginRadiusRaas::Exception => e
|
118
|
-
false
|
119
|
-
end
|
120
|
-
|
121
|
-
def getRegistrationDataServer(type,parentid,skip,limit)
|
122
|
-
return getRequest("identity/v2/auth/registrationdata/"+type, {:apikey=> appkey,:apisecret=>appsecret,:parentid=>parentid,:skip=>skip,:limit=>limit},"api");
|
123
|
-
rescue LoginRadiusRaas::Exception => e
|
124
|
-
false
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
# ------------------------------------------------------------- Post API --------------------------------------------------------------------#
|
129
|
-
|
130
|
-
|
131
|
-
def accountCreate(payload)
|
132
|
-
return postRequest("identity/v2/manage/account",{:apikey=> appkey,:apisecret=>appsecret},payload,nil,"api");
|
133
|
-
rescue LoginRadiusRaas::Exception => e
|
134
|
-
false
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
def getEmailVerificationToken(payload)
|
139
|
-
return postRequest("identity/v2/manage/account/verify/token",{:apikey=> appkey,:apisecret=>appsecret},payload,nil,"api");
|
140
|
-
rescue LoginRadiusRaas::Exception => e
|
141
|
-
false
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
def getForgotPasswordToken(payload)
|
147
|
-
return postRequest("identity/v2/manage/account/forgot/token",{:apikey=> appkey,:apisecret=>appsecret},payload,nil,"api");
|
148
|
-
rescue LoginRadiusRaas::Exception => e
|
149
|
-
false
|
150
|
-
end
|
151
|
-
|
152
|
-
|
153
|
-
def rolesCreate(payload)
|
154
|
-
return postRequest("identity/v2/manage/role",{:apikey=> appkey,:apisecret=>appsecret},payload,nil,"api");
|
155
|
-
rescue LoginRadiusRaas::Exception => e
|
156
|
-
false
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
def createCustomObjectByUid(objectname,uid,payload)
|
161
|
-
return postRequest("identity/v2/manage/account/"+uid+"/customobject",{:apikey=> appkey,:apisecret=>appsecret,:objectname =>objectname },payload,nil,"api");
|
162
|
-
rescue LoginRadiusRaas::Exception => e
|
163
|
-
false
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
def addRegistrationData(payload)
|
168
|
-
return postRequest("identity/v2/manage/registrationdata",{:apikey=> appkey,:apisecret=>appsecret},payload,nil,"api");
|
169
|
-
rescue LoginRadiusRaas::Exception => e
|
170
|
-
false
|
171
|
-
end
|
172
|
-
|
173
|
-
def ValidateSecretCode(payload)
|
174
|
-
return postRequest("identity/v2/auth/registrationdata/validatecode", {:apikey=> appkey},payload,nil,"api");
|
175
|
-
rescue LoginRadiusRaas::Exception => e
|
176
|
-
false
|
177
|
-
end
|
178
|
-
|
179
|
-
# ------------------------------------------------------------- Put API --------------------------------------------------------------------#
|
180
|
-
|
181
|
-
|
182
|
-
def accountSetPasswordToken(uid,payload)
|
183
|
-
return putRequest("identity/v2/manage/account/"+uid+"/password",{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
184
|
-
rescue LoginRadiusRaas::Exception => e
|
185
|
-
false
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
def accountUpdate(uid,payload)
|
190
|
-
return putRequest("identity/v2/manage/account/"+uid,{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
191
|
-
rescue LoginRadiusRaas::Exception => e
|
192
|
-
false
|
193
|
-
end
|
194
|
-
|
195
|
-
|
196
|
-
def accountUpdateSecurityQuestionConfiguration(uid,payload)
|
197
|
-
return putRequest("identity/v2/manage/account/"+uid,{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
198
|
-
rescue LoginRadiusRaas::Exception => e
|
199
|
-
false
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
|
-
def accountInvalidateVerificationEmail(uid,verificationurl,emailtemplate)
|
204
|
-
return putRequest("identity/v2/manage/account/"+uid+"/invalidateemail",{:apikey=> appkey,:apisecret=>appsecret,:verificationurl=>verificationurl,:emailtemplate=>emailtemplate},{},"api");
|
205
|
-
rescue LoginRadiusRaas::Exception => e
|
206
|
-
false
|
207
|
-
end
|
208
|
-
|
209
|
-
|
210
|
-
def accountAddPermissionsToRole(role,payload)
|
211
|
-
return putRequest("identity/v2/manage/role/"+role+"/permission",{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
212
|
-
rescue LoginRadiusRaas::Exception => e
|
213
|
-
false
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
def roleAssignToUser(uid,payload)
|
218
|
-
return putRequest("identity/v2/manage/account/"+uid+"/role",{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
219
|
-
rescue LoginRadiusRaas::Exception => e
|
220
|
-
false
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
def upsertContext(uid,payload)
|
225
|
-
return putRequest("identity/v2/manage/account/"+uid+"/rolecontext",{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
226
|
-
rescue LoginRadiusRaas::Exception => e
|
227
|
-
false
|
228
|
-
end
|
229
|
-
|
230
|
-
|
231
|
-
def customObjectUpdateByUid(objectname,updatetype,uid,objectrecordid,payload)
|
232
|
-
return putRequest("identity/v2/manage/account/"+uid+"/customobject/"+objectrecordid,{:apikey=> appkey,:apisecret=>appsecret,:updatetype=> updatetype,:objectname=>objectname},payload,"api");
|
233
|
-
rescue LoginRadiusRaas::Exception => e
|
234
|
-
false
|
235
|
-
end
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
def resetPhoneIdVerification(uid)
|
240
|
-
return putRequest("identity/v2/manage/account/"+uid+"/invalidatephone",{:apikey=> appkey,:apisecret=>appsecret},{},"api");
|
241
|
-
rescue LoginRadiusRaas::Exception => e
|
242
|
-
false
|
243
|
-
end
|
244
|
-
|
245
|
-
def updateRegistrationData(recordid,payload)
|
246
|
-
return putRequest("identity/v2/manage/registrationdata/"+recordid,{:apikey=> appkey,:apisecret=>appsecret},payload,"api");
|
247
|
-
rescue LoginRadiusRaas::Exception => e
|
248
|
-
false
|
249
|
-
end
|
250
|
-
|
251
|
-
# ------------------------------------------------------------- Delete API --------------------------------------------------------------------#
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
def accountEmailDelete(uid,email)
|
256
|
-
payload = {
|
257
|
-
:email=> email
|
258
|
-
}
|
259
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/email",{:apikey=> appkey,:apisecret=>appsecret},payload);
|
260
|
-
rescue LoginRadiusRaas::Exception => e
|
261
|
-
false
|
262
|
-
end
|
263
|
-
|
264
|
-
def accountDelete(uid)
|
265
|
-
return deleteRequest("identity/v2/manage/account/"+uid,{:apikey=> appkey,:apisecret=>appsecret},{});
|
266
|
-
rescue LoginRadiusRaas::Exception => e
|
267
|
-
false
|
268
|
-
end
|
269
|
-
|
270
|
-
|
271
|
-
def accountDeleteRole(uid)
|
272
|
-
return deleteRequest("identity/v2/manage/role/"+uid,{:apikey=> appkey,:apisecret=>appsecret},{});
|
273
|
-
rescue LoginRadiusRaas::Exception => e
|
274
|
-
false
|
275
|
-
end
|
276
|
-
|
277
|
-
|
278
|
-
def roleUnassignToUser(uid,payload)
|
279
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/role",{:apikey=> appkey,:apisecret=>appsecret},payload);
|
280
|
-
rescue LoginRadiusRaas::Exception => e
|
281
|
-
false
|
282
|
-
end
|
283
|
-
|
284
|
-
|
285
|
-
def accountRemovePermission(roleName,payload)
|
286
|
-
return deleteRequest("identity/v2/manage/role/"+roleName+"/permission",{:apikey=> appkey,:apisecret=>appsecret},payload);
|
287
|
-
rescue LoginRadiusRaas::Exception => e
|
288
|
-
false
|
289
|
-
end
|
290
|
-
|
291
|
-
|
292
|
-
def deleteRoleContext(uid,rolecontextname)
|
293
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/rolecontext/"+rolecontextname,{:apikey=> appkey,:apisecret=>appsecret},{});
|
294
|
-
rescue LoginRadiusRaas::Exception => e
|
295
|
-
false
|
296
|
-
end
|
297
|
-
|
298
|
-
|
299
|
-
def deleteRoleFromContext(uid,rolecontextname,payload)
|
300
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/rolecontext/"+rolecontextname+"/role",{:apikey=> appkey,:apisecret=>appsecret},payload);
|
301
|
-
rescue LoginRadiusRaas::Exception => e
|
302
|
-
false
|
303
|
-
end
|
304
|
-
|
305
|
-
|
306
|
-
def deleteAdditionalPermissionsFromContext(uid,rolecontextname,payload)
|
307
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/rolecontext/"+rolecontextname+"/additionalpermission",{:apikey=> appkey,:apisecret=>appsecret},payload);
|
308
|
-
rescue LoginRadiusRaas::Exception => e
|
309
|
-
false
|
310
|
-
end
|
311
|
-
|
312
|
-
|
313
|
-
def deleteCustomObjectByObjectrecordId(uid,objectrecordid,objectname)
|
314
|
-
return deleteRequest("identity/v2/manage/account/"+uid+"/customobject/"+objectrecordid,{:apikey=> appkey,:apisecret=>appsecret,:objectname=>objectname},{});
|
315
|
-
rescue LoginRadiusRaas::Exception => e
|
316
|
-
false
|
317
|
-
end
|
318
|
-
|
319
|
-
def deleteRegistrationData(recordid)
|
320
|
-
return deleteRequest("identity/v2/manage/registrationdata/"+recordid,{:apikey=> appkey,:apisecret=>appsecret},{});
|
321
|
-
rescue LoginRadiusRaas::Exception => e
|
322
|
-
false
|
323
|
-
end
|
324
|
-
|
325
|
-
|
326
|
-
end
|
327
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
|
-
module LoginRadius
|
4
|
-
class RestRequest
|
5
|
-
include SocialApi
|
6
|
-
include AdvancedApi
|
7
|
-
include AuthenticationApi
|
8
|
-
include ManagementApi
|
9
|
-
include Two_FA_Api
|
10
|
-
|
11
|
-
attr_accessor :appkey, :appsecret, :ssl_verify_peer
|
12
|
-
|
13
|
-
API_V2_BASE_URL = "https://api.loginradius.com/"
|
14
|
-
API_V2_BASE_URL_CONFIG = "https://config.lrcontent.com/"
|
15
|
-
API_V2_BASE_URL_CLOUD = "https://cloud-api.loginradius.com/"
|
16
|
-
|
17
|
-
# Takes a hash of account secret, token, and connection type(net_http or em_http)
|
18
|
-
# and uses it to auth against the LoginRadius API. Then it returns the Account object. The
|
19
|
-
# async key is optional, if set to true, will use Em::HTTP instead of Net::HTTP.
|
20
|
-
#
|
21
|
-
# @param opts [Hash] Must have keys :token, :secret, :async(optional) and :ssl_verify_peer(optional)
|
22
|
-
# @return [LoginRadius::Account]
|
23
|
-
def initialize(opts = {})
|
24
|
-
self.appsecret = opts[:appsecret]
|
25
|
-
self.appkey = opts[:appkey]
|
26
|
-
self.ssl_verify_peer = opts[:ssl_verify_peer]
|
27
|
-
raise LoginRadiusRaas::Exception.new("Invalid appkey") unless guid_valid?(appkey)
|
28
|
-
raise LoginRadiusRaas::Exception.new("Invalid appsecret") unless guid_valid?(appsecret)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Takes a guid and returns whether or not it is valid.
|
32
|
-
#
|
33
|
-
# @param guid [String]
|
34
|
-
# @return [Boolean]
|
35
|
-
def guid_valid?(guid)
|
36
|
-
guid.match(/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/i)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Generic GET call function that other submodules can use to hit the API.
|
40
|
-
#
|
41
|
-
# @param url [String] Target URL to fetch data from.
|
42
|
-
# @param params [Hash] Parameters to send
|
43
|
-
# @return data [Hash] Parsed JSON data from the call
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def getRequest(url,getparams = {},baseURL)
|
49
|
-
if baseURL == "cloud"
|
50
|
-
url_obj = URI.parse(API_V2_BASE_URL_CLOUD+url)
|
51
|
-
elsif baseURL == "config"
|
52
|
-
url_obj = URI.parse(API_V2_BASE_URL_CONFIG+url)
|
53
|
-
else
|
54
|
-
url_obj = URI.parse(API_V2_BASE_URL+url)
|
55
|
-
end
|
56
|
-
url_obj.query = URI.encode_www_form(getparams)
|
57
|
-
http = Net::HTTP.new(url_obj.host, url_obj.port)
|
58
|
-
http.use_ssl = true
|
59
|
-
response = http.get(url_obj.request_uri)
|
60
|
-
begin
|
61
|
-
converted_response = JSON.parse(response.body, :symbolize_names => true)
|
62
|
-
return converted_response
|
63
|
-
rescue JSON::ParserError => e
|
64
|
-
raise LoginRadiusRaas::Exception.new("A JSON parsing error occurred because the API returned an HTML page instead of JSON. This happens mostly when you're using an expired Token. Specifics: #{e.message}")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
def postRequest(url,getparams = {},postparams,sott,baseURL)
|
71
|
-
if baseURL == "cloud"
|
72
|
-
url_obj = URI.parse(API_V2_BASE_URL_CLOUD+url)
|
73
|
-
elsif baseURL == "config"
|
74
|
-
url_obj = URI.parse(API_V2_BASE_URL_CONFIG+url)
|
75
|
-
else
|
76
|
-
url_obj = URI.parse(API_V2_BASE_URL+url)
|
77
|
-
end
|
78
|
-
url_obj.query = URI.encode_www_form(getparams)
|
79
|
-
http = Net::HTTP.new(url_obj.host, url_obj.port)
|
80
|
-
http.use_ssl = true
|
81
|
-
if sott!=nil
|
82
|
-
response = http.post(url_obj.request_uri, postparams.to_json, {'Content-Type' => 'application/json', 'X-LoginRadius-Sott' => sott})
|
83
|
-
else
|
84
|
-
response = http.post(url_obj.request_uri, postparams.to_json, {'Content-Type' => 'application/json'})
|
85
|
-
end
|
86
|
-
begin
|
87
|
-
converted_response = JSON.parse(response.body, :symbolize_names => true)
|
88
|
-
return converted_response
|
89
|
-
rescue JSON::ParserError => e
|
90
|
-
raise LoginRadiusRaas::Exception.new("A JSON parsing error occurred because the API returned an HTML page instead of JSON. This happens mostly when you're using an expired Token. Specifics: #{e.message}")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
def putRequest(url,getparams = {},postparams,baseURL)
|
97
|
-
|
98
|
-
if baseURL == "cloud"
|
99
|
-
url_obj = URI.parse(API_V2_BASE_URL_CLOUD+url)
|
100
|
-
elsif baseURL == "config"
|
101
|
-
url_obj = URI.parse(API_V2_BASE_URL_CONFIG+url)
|
102
|
-
else
|
103
|
-
url_obj = URI.parse(API_V2_BASE_URL+url)
|
104
|
-
end
|
105
|
-
url_obj.query = URI.encode_www_form(getparams)
|
106
|
-
http = Net::HTTP.new(url_obj.host, url_obj.port)
|
107
|
-
http.use_ssl = true
|
108
|
-
response = http.put(url_obj.request_uri, postparams.to_json, {'Content-Type' => 'application/json'})
|
109
|
-
begin
|
110
|
-
converted_response = JSON.parse(response.body, :symbolize_names => true)
|
111
|
-
return converted_response
|
112
|
-
rescue JSON::ParserError => e
|
113
|
-
raise LoginRadiusRaas::Exception.new("A JSON parsing error occurred because the API returned an HTML page instead of JSON. This happens mostly when you're using an expired Token. Specifics: #{e.message}")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
def deleteRequest(url,getparams = {},postparams)
|
119
|
-
url_obj = URI.parse(API_V2_BASE_URL+url)
|
120
|
-
url_obj.query = URI.encode_www_form(getparams)
|
121
|
-
require 'uri'
|
122
|
-
require 'net/http'
|
123
|
-
url = URI("https://api.loginradius.com"+url_obj.request_uri)
|
124
|
-
http = Net::HTTP.new(url.host, url.port)
|
125
|
-
http.use_ssl = true
|
126
|
-
http.verify_mode = false
|
127
|
-
request = Net::HTTP::Delete.new(url)
|
128
|
-
request.body = postparams.to_json #"{\n \"provider\": \"xxxxxxxxxxx\",\n \"providerid\": \"xxxxxxxxxxxxxxxxxxx\"\n}"
|
129
|
-
request['content-Type'] = 'application/json'
|
130
|
-
response = http.request(request)
|
131
|
-
begin
|
132
|
-
converted_response = JSON.parse(response.read_body, :symbolize_names => true)
|
133
|
-
return converted_response
|
134
|
-
rescue JSON::ParserError => e
|
135
|
-
raise LoginRadiusRaas::Exception.new("A JSON parsing error occurred because the API returned an HTML page instead of JSON. This happens mostly when you're using an expired Token. Specifics: #{e.message}")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
end
|