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.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +21 -0
  3. data/README.md +58 -52
  4. data/lib/login_radius.rb +30 -15
  5. data/lib/login_radius/api/account/account_api.rb +581 -0
  6. data/lib/login_radius/api/account/role_api.rb +330 -0
  7. data/lib/login_radius/api/account/sott_api.rb +47 -0
  8. data/lib/login_radius/api/advanced/configuration_api.rb +57 -0
  9. data/lib/login_radius/api/advanced/consent_management_api.rb +161 -0
  10. data/lib/login_radius/api/advanced/custom_object_api.rb +316 -0
  11. data/lib/login_radius/api/advanced/custom_registration_data_api.rb +195 -0
  12. data/lib/login_radius/api/advanced/multi_factor_authentication_api.rb +606 -0
  13. data/lib/login_radius/api/advanced/re_authentication_api.rb +243 -0
  14. data/lib/login_radius/api/advanced/web_hook_api.rb +101 -0
  15. data/lib/login_radius/api/authentication/authentication_api.rb +986 -0
  16. data/lib/login_radius/api/authentication/one_touch_login_api.rb +160 -0
  17. data/lib/login_radius/api/authentication/password_less_login_api.rb +158 -0
  18. data/lib/login_radius/api/authentication/phone_authentication_api.rb +329 -0
  19. data/lib/login_radius/api/authentication/pin_authentication_api.rb +316 -0
  20. data/lib/login_radius/api/authentication/risk_based_authentication_api.rb +286 -0
  21. data/lib/login_radius/api/authentication/smart_login_api.rb +146 -0
  22. data/lib/login_radius/api/social/native_social_api.rb +193 -0
  23. data/lib/login_radius/api/social/social_api.rb +802 -0
  24. data/lib/login_radius/error.rb +7 -0
  25. data/lib/login_radius/request_client.rb +295 -0
  26. data/lib/login_radius/response.rb +12 -0
  27. data/lib/login_radius/version.rb +3 -3
  28. data/login_radius.gemspec +36 -0
  29. metadata +61 -20
  30. data/LICENSE +0 -22
  31. data/lib/hash.rb +0 -12
  32. data/lib/login_radius/advanced_api.rb +0 -133
  33. data/lib/login_radius/authentication_api.rb +0 -597
  34. data/lib/login_radius/exception.rb +0 -4
  35. data/lib/login_radius/management_api.rb +0 -327
  36. data/lib/login_radius/rest_request.rb +0 -142
  37. data/lib/login_radius/social_api.rb +0 -402
  38. data/lib/login_radius/two_fa_api.rb +0 -191
  39. data/lib/string.rb +0 -8
@@ -0,0 +1,606 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Created by LoginRadius Development Team
4
+ # Copyright 2019 LoginRadius Inc. All rights reserved.
5
+ require_relative '../../request_client'
6
+
7
+ module LoginRadius
8
+ # MultiFactorAuthenticationApi module
9
+ class MultiFactorAuthenticationApi
10
+ include RequestClient
11
+
12
+ attr_accessor :site_name, :api_key, :api_secret
13
+
14
+ # Initializes a LoginRadius Account object with an apikey and secret
15
+ # Takes in a hash containing site_name(required), api_key(required), api_secret(required)
16
+ def initialize
17
+ @site_name = ENV['SITE_NAME']
18
+ @api_key = ENV['API_KEY']
19
+ @api_secret = ENV['API_SECRET']
20
+ raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
21
+ unless @site_name != '' && @site_name != nil
22
+ raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \
23
+ unless @api_key != '' && @api_key != nil
24
+ raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \
25
+ unless @api_secret != '' && @api_secret != nil
26
+ end
27
+
28
+ # This API is used to configure the Multi-factor authentication after login by using the access token when MFA is set as optional on the LoginRadius site.
29
+ #
30
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
31
+ # @param sms_template2_f_a - SMS Template Name
32
+ #
33
+ # @return Response containing Definition of Complete Multi-Factor Authentication Settings data
34
+ # 5.7
35
+ def mfa_configure_by_access_token(access_token, sms_template2_f_a = '')
36
+ if isNullOrWhiteSpace(access_token)
37
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
38
+ end
39
+
40
+ query_parameters = {}
41
+ query_parameters['access_token'] = access_token
42
+ query_parameters['apiKey'] = @api_key
43
+ unless isNullOrWhiteSpace(sms_template2_f_a)
44
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
45
+ end
46
+
47
+ resource_path = 'identity/v2/auth/account/2fa'
48
+ get_request(resource_path, query_parameters, nil)
49
+ end
50
+
51
+ # This API is used to trigger the Multi-factor authentication settings after login for secure actions
52
+ #
53
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
54
+ # @param multi_factor_auth_model_with_lockout - Model Class containing Definition of payload for MultiFactorAuthModel With Lockout API
55
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
56
+ #
57
+ # @return Response containing Definition for Complete profile data
58
+ # 5.9
59
+ def mfa_update_setting(access_token, multi_factor_auth_model_with_lockout, fields = '')
60
+ if isNullOrWhiteSpace(access_token)
61
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
62
+ end
63
+ if multi_factor_auth_model_with_lockout.blank?
64
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_with_lockout')
65
+ end
66
+
67
+ query_parameters = {}
68
+ query_parameters['access_token'] = access_token
69
+ query_parameters['apiKey'] = @api_key
70
+ unless isNullOrWhiteSpace(fields)
71
+ query_parameters['fields'] = fields
72
+ end
73
+
74
+ resource_path = 'identity/v2/auth/account/2fa/verification/otp'
75
+ put_request(resource_path, query_parameters, multi_factor_auth_model_with_lockout)
76
+ end
77
+
78
+ # This API is used to Enable Multi-factor authentication by access token on user login
79
+ #
80
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
81
+ # @param multi_factor_auth_model_by_google_authenticator_code - Model Class containing Definition of payload for MultiFactorAuthModel By GoogleAuthenticator Code API
82
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
83
+ # @param sms_template - SMS Template name
84
+ #
85
+ # @return Response containing Definition for Complete profile data
86
+ # 5.10
87
+ def mfa_update_by_access_token(access_token, multi_factor_auth_model_by_google_authenticator_code, fields = '', sms_template = '')
88
+ if isNullOrWhiteSpace(access_token)
89
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
90
+ end
91
+ if multi_factor_auth_model_by_google_authenticator_code.blank?
92
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_by_google_authenticator_code')
93
+ end
94
+
95
+ query_parameters = {}
96
+ query_parameters['access_token'] = access_token
97
+ query_parameters['apiKey'] = @api_key
98
+ unless isNullOrWhiteSpace(fields)
99
+ query_parameters['fields'] = fields
100
+ end
101
+ unless isNullOrWhiteSpace(sms_template)
102
+ query_parameters['smsTemplate'] = sms_template
103
+ end
104
+
105
+ resource_path = 'identity/v2/auth/account/2fa/verification/googleauthenticatorcode'
106
+ put_request(resource_path, query_parameters, multi_factor_auth_model_by_google_authenticator_code)
107
+ end
108
+
109
+ # This API is used to update the Multi-factor authentication phone number by sending the verification OTP to the provided phone number
110
+ #
111
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
112
+ # @param phone_no2_f_a - Phone Number For 2FA
113
+ # @param sms_template2_f_a - SMS Template Name
114
+ #
115
+ # @return Response containing Definition for Complete SMS data
116
+ # 5.11
117
+ def mfa_update_phone_number_by_token(access_token, phone_no2_f_a, sms_template2_f_a = '')
118
+ if isNullOrWhiteSpace(access_token)
119
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
120
+ end
121
+ if isNullOrWhiteSpace(phone_no2_f_a)
122
+ raise LoginRadius::Error.new, getValidationMessage('phone_no2_f_a')
123
+ end
124
+
125
+ query_parameters = {}
126
+ query_parameters['access_token'] = access_token
127
+ query_parameters['apiKey'] = @api_key
128
+ unless isNullOrWhiteSpace(sms_template2_f_a)
129
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
130
+ end
131
+
132
+ body_parameters = {}
133
+ body_parameters['phoneNo2FA'] = phone_no2_f_a
134
+
135
+ resource_path = 'identity/v2/auth/account/2fa'
136
+ put_request(resource_path, query_parameters, body_parameters)
137
+ end
138
+
139
+ # This API Resets the Google Authenticator configurations on a given account via the access token
140
+ #
141
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
142
+ # @param googleauthenticator - boolean type value,Enable google Authenticator Code.
143
+ #
144
+ # @return Response containing Definition of Delete Request
145
+ # 5.12.1
146
+ def mfa_reset_google_auth_by_token(access_token, googleauthenticator)
147
+ if isNullOrWhiteSpace(access_token)
148
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
149
+ end
150
+
151
+ query_parameters = {}
152
+ query_parameters['access_token'] = access_token
153
+ query_parameters['apiKey'] = @api_key
154
+
155
+ body_parameters = {}
156
+ body_parameters['googleauthenticator'] = googleauthenticator
157
+
158
+ resource_path = 'identity/v2/auth/account/2fa/authenticator'
159
+ delete_request(resource_path, query_parameters, body_parameters)
160
+ end
161
+
162
+ # This API resets the SMS Authenticator configurations on a given account via the access token.
163
+ #
164
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
165
+ # @param otpauthenticator - Pass 'otpauthenticator' to remove SMS Authenticator
166
+ #
167
+ # @return Response containing Definition of Delete Request
168
+ # 5.12.2
169
+ def mfa_reset_sms_auth_by_token(access_token, otpauthenticator)
170
+ if isNullOrWhiteSpace(access_token)
171
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
172
+ end
173
+
174
+ query_parameters = {}
175
+ query_parameters['access_token'] = access_token
176
+ query_parameters['apiKey'] = @api_key
177
+
178
+ body_parameters = {}
179
+ body_parameters['otpauthenticator'] = otpauthenticator
180
+
181
+ resource_path = 'identity/v2/auth/account/2fa/authenticator'
182
+ delete_request(resource_path, query_parameters, body_parameters)
183
+ end
184
+
185
+ # This API is used to get a set of backup codes via access token to allow the user login on a site that has Multi-factor Authentication enabled in the event that the user does not have a secondary factor available. We generate 10 codes, each code can only be consumed once. If any user attempts to go over the number of invalid login attempts configured in the Dashboard then the account gets blocked automatically
186
+ #
187
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
188
+ #
189
+ # @return Response containing Definition of Complete Backup Code data
190
+ # 5.13
191
+ def mfa_backup_code_by_access_token(access_token)
192
+ if isNullOrWhiteSpace(access_token)
193
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
194
+ end
195
+
196
+ query_parameters = {}
197
+ query_parameters['access_token'] = access_token
198
+ query_parameters['apiKey'] = @api_key
199
+
200
+ resource_path = 'identity/v2/auth/account/2fa/backupcode'
201
+ get_request(resource_path, query_parameters, nil)
202
+ end
203
+
204
+ # API is used to reset the backup codes on a given account via the access token. This API call will generate 10 new codes, each code can only be consumed once
205
+ #
206
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
207
+ #
208
+ # @return Response containing Definition of Complete Backup Code data
209
+ # 5.14
210
+ def mfa_reset_backup_code_by_access_token(access_token)
211
+ if isNullOrWhiteSpace(access_token)
212
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
213
+ end
214
+
215
+ query_parameters = {}
216
+ query_parameters['access_token'] = access_token
217
+ query_parameters['apiKey'] = @api_key
218
+
219
+ resource_path = 'identity/v2/auth/account/2fa/backupcode/reset'
220
+ get_request(resource_path, query_parameters, nil)
221
+ end
222
+
223
+ # This API can be used to login by emailid on a Multi-factor authentication enabled LoginRadius site.
224
+ #
225
+ # @param email - user's email
226
+ # @param password - Password for the email
227
+ # @param email_template - Email template name
228
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
229
+ # @param login_url - Url where the user is logging from
230
+ # @param sms_template - SMS Template name
231
+ # @param sms_template2_f_a - SMS Template Name
232
+ # @param verification_url - Email verification url
233
+ #
234
+ # @return Complete user UserProfile data
235
+ # 9.8.1
236
+ def mfa_login_by_email(email, password, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '')
237
+ if isNullOrWhiteSpace(email)
238
+ raise LoginRadius::Error.new, getValidationMessage('email')
239
+ end
240
+ if isNullOrWhiteSpace(password)
241
+ raise LoginRadius::Error.new, getValidationMessage('password')
242
+ end
243
+
244
+ query_parameters = {}
245
+ query_parameters['apiKey'] = @api_key
246
+ unless isNullOrWhiteSpace(email_template)
247
+ query_parameters['emailTemplate'] = email_template
248
+ end
249
+ unless isNullOrWhiteSpace(fields)
250
+ query_parameters['fields'] = fields
251
+ end
252
+ unless isNullOrWhiteSpace(login_url)
253
+ query_parameters['loginUrl'] = login_url
254
+ end
255
+ unless isNullOrWhiteSpace(sms_template)
256
+ query_parameters['smsTemplate'] = sms_template
257
+ end
258
+ unless isNullOrWhiteSpace(sms_template2_f_a)
259
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
260
+ end
261
+ unless isNullOrWhiteSpace(verification_url)
262
+ query_parameters['verificationUrl'] = verification_url
263
+ end
264
+
265
+ body_parameters = {}
266
+ body_parameters['email'] = email
267
+ body_parameters['password'] = password
268
+
269
+ resource_path = 'identity/v2/auth/login/2fa'
270
+ post_request(resource_path, query_parameters, body_parameters)
271
+ end
272
+
273
+ # This API can be used to login by username on a Multi-factor authentication enabled LoginRadius site.
274
+ #
275
+ # @param password - Password for the email
276
+ # @param username - Username of the user
277
+ # @param email_template - Email template name
278
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
279
+ # @param login_url - Url where the user is logging from
280
+ # @param sms_template - SMS Template name
281
+ # @param sms_template2_f_a - SMS Template Name
282
+ # @param verification_url - Email verification url
283
+ #
284
+ # @return Complete user UserProfile data
285
+ # 9.8.2
286
+ def mfa_login_by_user_name(password, username, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '')
287
+ if isNullOrWhiteSpace(password)
288
+ raise LoginRadius::Error.new, getValidationMessage('password')
289
+ end
290
+ if isNullOrWhiteSpace(username)
291
+ raise LoginRadius::Error.new, getValidationMessage('username')
292
+ end
293
+
294
+ query_parameters = {}
295
+ query_parameters['apiKey'] = @api_key
296
+ unless isNullOrWhiteSpace(email_template)
297
+ query_parameters['emailTemplate'] = email_template
298
+ end
299
+ unless isNullOrWhiteSpace(fields)
300
+ query_parameters['fields'] = fields
301
+ end
302
+ unless isNullOrWhiteSpace(login_url)
303
+ query_parameters['loginUrl'] = login_url
304
+ end
305
+ unless isNullOrWhiteSpace(sms_template)
306
+ query_parameters['smsTemplate'] = sms_template
307
+ end
308
+ unless isNullOrWhiteSpace(sms_template2_f_a)
309
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
310
+ end
311
+ unless isNullOrWhiteSpace(verification_url)
312
+ query_parameters['verificationUrl'] = verification_url
313
+ end
314
+
315
+ body_parameters = {}
316
+ body_parameters['password'] = password
317
+ body_parameters['username'] = username
318
+
319
+ resource_path = 'identity/v2/auth/login/2fa'
320
+ post_request(resource_path, query_parameters, body_parameters)
321
+ end
322
+
323
+ # This API can be used to login by Phone on a Multi-factor authentication enabled LoginRadius site.
324
+ #
325
+ # @param password - Password for the email
326
+ # @param phone - New Phone Number
327
+ # @param email_template - Email template name
328
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
329
+ # @param login_url - Url where the user is logging from
330
+ # @param sms_template - SMS Template name
331
+ # @param sms_template2_f_a - SMS Template Name
332
+ # @param verification_url - Email verification url
333
+ #
334
+ # @return Complete user UserProfile data
335
+ # 9.8.3
336
+ def mfa_login_by_phone(password, phone, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '')
337
+ if isNullOrWhiteSpace(password)
338
+ raise LoginRadius::Error.new, getValidationMessage('password')
339
+ end
340
+ if isNullOrWhiteSpace(phone)
341
+ raise LoginRadius::Error.new, getValidationMessage('phone')
342
+ end
343
+
344
+ query_parameters = {}
345
+ query_parameters['apiKey'] = @api_key
346
+ unless isNullOrWhiteSpace(email_template)
347
+ query_parameters['emailTemplate'] = email_template
348
+ end
349
+ unless isNullOrWhiteSpace(fields)
350
+ query_parameters['fields'] = fields
351
+ end
352
+ unless isNullOrWhiteSpace(login_url)
353
+ query_parameters['loginUrl'] = login_url
354
+ end
355
+ unless isNullOrWhiteSpace(sms_template)
356
+ query_parameters['smsTemplate'] = sms_template
357
+ end
358
+ unless isNullOrWhiteSpace(sms_template2_f_a)
359
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
360
+ end
361
+ unless isNullOrWhiteSpace(verification_url)
362
+ query_parameters['verificationUrl'] = verification_url
363
+ end
364
+
365
+ body_parameters = {}
366
+ body_parameters['password'] = password
367
+ body_parameters['phone'] = phone
368
+
369
+ resource_path = 'identity/v2/auth/login/2fa'
370
+ post_request(resource_path, query_parameters, body_parameters)
371
+ end
372
+
373
+ # This API is used to login via Multi-factor authentication by passing the One Time Password received via SMS
374
+ #
375
+ # @param multi_factor_auth_model_with_lockout - Model Class containing Definition of payload for MultiFactorAuthModel With Lockout API
376
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
377
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
378
+ # @param sms_template2_f_a - SMS Template Name
379
+ #
380
+ # @return Complete user UserProfile data
381
+ # 9.12
382
+ def mfa_validate_otp_by_phone(multi_factor_auth_model_with_lockout, second_factor_authentication_token, fields = '', sms_template2_f_a = '')
383
+ if multi_factor_auth_model_with_lockout.blank?
384
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_with_lockout')
385
+ end
386
+ if isNullOrWhiteSpace(second_factor_authentication_token)
387
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
388
+ end
389
+
390
+ query_parameters = {}
391
+ query_parameters['apiKey'] = @api_key
392
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
393
+ unless isNullOrWhiteSpace(fields)
394
+ query_parameters['fields'] = fields
395
+ end
396
+ unless isNullOrWhiteSpace(sms_template2_f_a)
397
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
398
+ end
399
+
400
+ resource_path = 'identity/v2/auth/login/2fa/verification/otp'
401
+ put_request(resource_path, query_parameters, multi_factor_auth_model_with_lockout)
402
+ end
403
+
404
+ # This API is used to login via Multi-factor-authentication by passing the google authenticator code.
405
+ #
406
+ # @param google_authenticator_code - The code generated by google authenticator app after scanning QR code
407
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
408
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
409
+ # @param sms_template2_f_a - SMS Template Name
410
+ #
411
+ # @return Complete user UserProfile data
412
+ # 9.13
413
+ def mfa_validate_google_auth_code(google_authenticator_code, second_factor_authentication_token, fields = '', sms_template2_f_a = '')
414
+ if isNullOrWhiteSpace(google_authenticator_code)
415
+ raise LoginRadius::Error.new, getValidationMessage('google_authenticator_code')
416
+ end
417
+ if isNullOrWhiteSpace(second_factor_authentication_token)
418
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
419
+ end
420
+
421
+ query_parameters = {}
422
+ query_parameters['apiKey'] = @api_key
423
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
424
+ unless isNullOrWhiteSpace(fields)
425
+ query_parameters['fields'] = fields
426
+ end
427
+ unless isNullOrWhiteSpace(sms_template2_f_a)
428
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
429
+ end
430
+
431
+ body_parameters = {}
432
+ body_parameters['googleAuthenticatorCode'] = google_authenticator_code
433
+
434
+ resource_path = 'identity/v2/auth/login/2fa/verification/googleauthenticatorcode'
435
+ put_request(resource_path, query_parameters, body_parameters)
436
+ end
437
+
438
+ # This API is used to validate the backup code provided by the user and if valid, we return an access token allowing the user to login incases where Multi-factor authentication (MFA) is enabled and the secondary factor is unavailable. When a user initially downloads the Backup codes, We generate 10 codes, each code can only be consumed once. if any user attempts to go over the number of invalid login attempts configured in the Dashboard then the account gets blocked automatically
439
+ #
440
+ # @param multi_factor_auth_model_by_backup_code - Model Class containing Definition of payload for MultiFactorAuth By BackupCode API
441
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
442
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
443
+ #
444
+ # @return Complete user UserProfile data
445
+ # 9.14
446
+ def mfa_validate_backup_code(multi_factor_auth_model_by_backup_code, second_factor_authentication_token, fields = '')
447
+ if multi_factor_auth_model_by_backup_code.blank?
448
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_by_backup_code')
449
+ end
450
+ if isNullOrWhiteSpace(second_factor_authentication_token)
451
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
452
+ end
453
+
454
+ query_parameters = {}
455
+ query_parameters['apiKey'] = @api_key
456
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
457
+ unless isNullOrWhiteSpace(fields)
458
+ query_parameters['fields'] = fields
459
+ end
460
+
461
+ resource_path = 'identity/v2/auth/login/2fa/verification/backupcode'
462
+ put_request(resource_path, query_parameters, multi_factor_auth_model_by_backup_code)
463
+ end
464
+
465
+ # This API is used to update (if configured) the phone number used for Multi-factor authentication by sending the verification OTP to the provided phone number
466
+ #
467
+ # @param phone_no2_f_a - Phone Number For 2FA
468
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
469
+ # @param sms_template2_f_a - SMS Template Name
470
+ #
471
+ # @return Response containing Definition for Complete SMS data
472
+ # 9.16
473
+ def mfa_update_phone_number(phone_no2_f_a, second_factor_authentication_token, sms_template2_f_a = '')
474
+ if isNullOrWhiteSpace(phone_no2_f_a)
475
+ raise LoginRadius::Error.new, getValidationMessage('phone_no2_f_a')
476
+ end
477
+ if isNullOrWhiteSpace(second_factor_authentication_token)
478
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
479
+ end
480
+
481
+ query_parameters = {}
482
+ query_parameters['apiKey'] = @api_key
483
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
484
+ unless isNullOrWhiteSpace(sms_template2_f_a)
485
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
486
+ end
487
+
488
+ body_parameters = {}
489
+ body_parameters['phoneNo2FA'] = phone_no2_f_a
490
+
491
+ resource_path = 'identity/v2/auth/login/2fa'
492
+ put_request(resource_path, query_parameters, body_parameters)
493
+ end
494
+
495
+ # This API is used to resending the verification OTP to the provided phone number
496
+ #
497
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
498
+ # @param sms_template2_f_a - SMS Template Name
499
+ #
500
+ # @return Response containing Definition for Complete SMS data
501
+ # 9.17
502
+ def mfa_resend_otp(second_factor_authentication_token, sms_template2_f_a = '')
503
+ if isNullOrWhiteSpace(second_factor_authentication_token)
504
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
505
+ end
506
+
507
+ query_parameters = {}
508
+ query_parameters['apiKey'] = @api_key
509
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
510
+ unless isNullOrWhiteSpace(sms_template2_f_a)
511
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
512
+ end
513
+
514
+ resource_path = 'identity/v2/auth/login/2fa/resend'
515
+ get_request(resource_path, query_parameters, nil)
516
+ end
517
+
518
+ # This API resets the SMS Authenticator configurations on a given account via the UID.
519
+ #
520
+ # @param otpauthenticator - Pass 'otpauthenticator' to remove SMS Authenticator
521
+ # @param uid - UID, the unified identifier for each user account
522
+ #
523
+ # @return Response containing Definition of Delete Request
524
+ # 18.21.1
525
+ def mfa_reset_sms_authenticator_by_uid(otpauthenticator, uid)
526
+ if isNullOrWhiteSpace(uid)
527
+ raise LoginRadius::Error.new, getValidationMessage('uid')
528
+ end
529
+
530
+ query_parameters = {}
531
+ query_parameters['apiKey'] = @api_key
532
+ query_parameters['apiSecret'] = @api_secret
533
+ query_parameters['uid'] = uid
534
+
535
+ body_parameters = {}
536
+ body_parameters['otpauthenticator'] = otpauthenticator
537
+
538
+ resource_path = 'identity/v2/manage/account/2fa/authenticator'
539
+ delete_request(resource_path, query_parameters, body_parameters)
540
+ end
541
+
542
+ # This API resets the Google Authenticator configurations on a given account via the UID.
543
+ #
544
+ # @param googleauthenticator - boolean type value,Enable google Authenticator Code.
545
+ # @param uid - UID, the unified identifier for each user account
546
+ #
547
+ # @return Response containing Definition of Delete Request
548
+ # 18.21.2
549
+ def mfa_reset_google_authenticator_by_uid(googleauthenticator, uid)
550
+ if isNullOrWhiteSpace(uid)
551
+ raise LoginRadius::Error.new, getValidationMessage('uid')
552
+ end
553
+
554
+ query_parameters = {}
555
+ query_parameters['apiKey'] = @api_key
556
+ query_parameters['apiSecret'] = @api_secret
557
+ query_parameters['uid'] = uid
558
+
559
+ body_parameters = {}
560
+ body_parameters['googleauthenticator'] = googleauthenticator
561
+
562
+ resource_path = 'identity/v2/manage/account/2fa/authenticator'
563
+ delete_request(resource_path, query_parameters, body_parameters)
564
+ end
565
+
566
+ # This API is used to reset the backup codes on a given account via the UID. This API call will generate 10 new codes, each code can only be consumed once.
567
+ #
568
+ # @param uid - UID, the unified identifier for each user account
569
+ #
570
+ # @return Response containing Definition of Complete Backup Code data
571
+ # 18.25
572
+ def mfa_backup_code_by_uid(uid)
573
+ if isNullOrWhiteSpace(uid)
574
+ raise LoginRadius::Error.new, getValidationMessage('uid')
575
+ end
576
+
577
+ query_parameters = {}
578
+ query_parameters['apiKey'] = @api_key
579
+ query_parameters['apiSecret'] = @api_secret
580
+ query_parameters['uid'] = uid
581
+
582
+ resource_path = 'identity/v2/manage/account/2fa/backupcode'
583
+ get_request(resource_path, query_parameters, nil)
584
+ end
585
+
586
+ # This API is used to reset the backup codes on a given account via the UID. This API call will generate 10 new codes, each code can only be consumed once.
587
+ #
588
+ # @param uid - UID, the unified identifier for each user account
589
+ #
590
+ # @return Response containing Definition of Complete Backup Code data
591
+ # 18.26
592
+ def mfa_reset_backup_code_by_uid(uid)
593
+ if isNullOrWhiteSpace(uid)
594
+ raise LoginRadius::Error.new, getValidationMessage('uid')
595
+ end
596
+
597
+ query_parameters = {}
598
+ query_parameters['apiKey'] = @api_key
599
+ query_parameters['apiSecret'] = @api_secret
600
+ query_parameters['uid'] = uid
601
+
602
+ resource_path = 'identity/v2/manage/account/2fa/backupcode/reset'
603
+ get_request(resource_path, query_parameters, nil)
604
+ end
605
+ end
606
+ end