login_radius 11.0.0 → 11.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -21
  3. data/README.md +58 -58
  4. data/lib/login_radius/api/account/account_api.rb +581 -581
  5. data/lib/login_radius/api/account/role_api.rb +330 -330
  6. data/lib/login_radius/api/account/sott_api.rb +47 -47
  7. data/lib/login_radius/api/advanced/configuration_api.rb +57 -57
  8. data/lib/login_radius/api/advanced/consent_management_api.rb +161 -161
  9. data/lib/login_radius/api/advanced/custom_object_api.rb +316 -316
  10. data/lib/login_radius/api/advanced/custom_registration_data_api.rb +195 -195
  11. data/lib/login_radius/api/advanced/multi_factor_authentication_api.rb +942 -606
  12. data/lib/login_radius/api/advanced/re_authentication_api.rb +317 -243
  13. data/lib/login_radius/api/advanced/web_hook_api.rb +101 -101
  14. data/lib/login_radius/api/authentication/authentication_api.rb +1036 -989
  15. data/lib/login_radius/api/authentication/one_touch_login_api.rb +160 -160
  16. data/lib/login_radius/api/authentication/password_less_login_api.rb +202 -158
  17. data/lib/login_radius/api/authentication/phone_authentication_api.rb +329 -329
  18. data/lib/login_radius/api/authentication/pin_authentication_api.rb +316 -316
  19. data/lib/login_radius/api/authentication/risk_based_authentication_api.rb +286 -286
  20. data/lib/login_radius/api/authentication/smart_login_api.rb +146 -146
  21. data/lib/login_radius/api/social/native_social_api.rb +255 -255
  22. data/lib/login_radius/api/social/social_api.rb +784 -806
  23. data/lib/login_radius/error.rb +7 -7
  24. data/lib/login_radius/request_client.rb +311 -295
  25. data/lib/login_radius/response.rb +18 -12
  26. data/lib/login_radius/version.rb +2 -2
  27. data/lib/login_radius.rb +30 -30
  28. data/login_radius.gemspec +25 -28
  29. metadata +7 -7
@@ -1,606 +1,942 @@
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
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, {})
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, {})
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, {})
221
+ end
222
+
223
+ # This API is created to send the OTP to the email if email OTP authenticator is enabled in app's MFA configuration.
224
+ #
225
+ # @param access_token - access_token
226
+ # @param email_id - EmailId
227
+ # @param email_template2_f_a - EmailTemplate2FA
228
+ #
229
+ # @return Response containing Definition of Complete Validation data
230
+ # 5.17
231
+ def mfa_email_otp_by_access_token(access_token, email_id, email_template2_f_a = '')
232
+ if isNullOrWhiteSpace(access_token)
233
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
234
+ end
235
+ if isNullOrWhiteSpace(email_id)
236
+ raise LoginRadius::Error.new, getValidationMessage('email_id')
237
+ end
238
+
239
+ query_parameters = {}
240
+ query_parameters['access_token'] = access_token
241
+ query_parameters['apiKey'] = @api_key
242
+ query_parameters['emailId'] = email_id
243
+ unless isNullOrWhiteSpace(email_template2_f_a)
244
+ query_parameters['emailTemplate2FA'] = email_template2_f_a
245
+ end
246
+
247
+ resource_path = 'identity/v2/auth/account/2fa/otp/email'
248
+ get_request(resource_path, query_parameters, {})
249
+ end
250
+
251
+ # This API is used to set up MFA Email OTP authenticator on profile after login.
252
+ #
253
+ # @param access_token - access_token
254
+ # @param multi_factor_auth_model_by_email_otp_with_lockout - payload
255
+ #
256
+ # @return Response containing Definition for Complete profile data
257
+ # 5.18
258
+ def mfa_validate_email_otp_by_access_token(access_token, multi_factor_auth_model_by_email_otp_with_lockout)
259
+ if isNullOrWhiteSpace(access_token)
260
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
261
+ end
262
+ if multi_factor_auth_model_by_email_otp_with_lockout.blank?
263
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_by_email_otp_with_lockout')
264
+ end
265
+
266
+ query_parameters = {}
267
+ query_parameters['access_token'] = access_token
268
+ query_parameters['apiKey'] = @api_key
269
+
270
+ resource_path = 'identity/v2/auth/account/2fa/verification/otp/email'
271
+ put_request(resource_path, query_parameters, multi_factor_auth_model_by_email_otp_with_lockout)
272
+ end
273
+
274
+ # This API is used to reset the Email OTP Authenticator settings for an MFA-enabled user
275
+ #
276
+ # @param access_token - access_token
277
+ #
278
+ # @return Response containing Definition of Delete Request
279
+ # 5.19
280
+ def mfa_reset_email_otp_authenticator_by_access_token(access_token)
281
+ if isNullOrWhiteSpace(access_token)
282
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
283
+ end
284
+
285
+ query_parameters = {}
286
+ query_parameters['access_token'] = access_token
287
+ query_parameters['apiKey'] = @api_key
288
+
289
+ resource_path = 'identity/v2/auth/account/2fa/authenticator/otp/email'
290
+ delete_request(resource_path, query_parameters, {})
291
+ end
292
+
293
+ # This API is used to set up MFA Security Question authenticator on profile after login.
294
+ #
295
+ # @param access_token - access_token
296
+ # @param security_question_answer_model_by_access_token - payload
297
+ #
298
+ # @return Response containing Definition of Complete Validation data
299
+ # 5.20
300
+ def mfa_security_question_answer_by_access_token(access_token, security_question_answer_model_by_access_token)
301
+ if isNullOrWhiteSpace(access_token)
302
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
303
+ end
304
+ if security_question_answer_model_by_access_token.blank?
305
+ raise LoginRadius::Error.new, getValidationMessage('security_question_answer_model_by_access_token')
306
+ end
307
+
308
+ query_parameters = {}
309
+ query_parameters['access_token'] = access_token
310
+ query_parameters['apiKey'] = @api_key
311
+
312
+ resource_path = 'identity/v2/auth/account/2fa/securityquestionanswer'
313
+ put_request(resource_path, query_parameters, security_question_answer_model_by_access_token)
314
+ end
315
+
316
+ # This API is used to Reset MFA Security Question Authenticator By Access Token
317
+ #
318
+ # @param access_token - access_token
319
+ #
320
+ # @return Response containing Definition of Delete Request
321
+ # 5.21
322
+ def mfa_reset_security_question_authenticator_by_access_token(access_token)
323
+ if isNullOrWhiteSpace(access_token)
324
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
325
+ end
326
+
327
+ query_parameters = {}
328
+ query_parameters['access_token'] = access_token
329
+ query_parameters['apiKey'] = @api_key
330
+
331
+ resource_path = 'identity/v2/auth/account/2fa/authenticator/securityquestionanswer'
332
+ delete_request(resource_path, query_parameters, {})
333
+ end
334
+
335
+ # This API can be used to login by emailid on a Multi-factor authentication enabled LoginRadius site.
336
+ #
337
+ # @param email - user's email
338
+ # @param password - Password for the email
339
+ # @param email_template - Email template name
340
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
341
+ # @param login_url - Url where the user is logging from
342
+ # @param sms_template - SMS Template name
343
+ # @param sms_template2_f_a - SMS Template Name
344
+ # @param verification_url - Email verification url
345
+ # @param email_template2_f_a - 2FA Email Template name
346
+ #
347
+ # @return Complete user UserProfile data
348
+ # 9.8.1
349
+ def mfa_login_by_email(email, password, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '', email_template2_f_a = '')
350
+ if isNullOrWhiteSpace(email)
351
+ raise LoginRadius::Error.new, getValidationMessage('email')
352
+ end
353
+ if isNullOrWhiteSpace(password)
354
+ raise LoginRadius::Error.new, getValidationMessage('password')
355
+ end
356
+
357
+ query_parameters = {}
358
+ query_parameters['apiKey'] = @api_key
359
+ unless isNullOrWhiteSpace(email_template)
360
+ query_parameters['emailTemplate'] = email_template
361
+ end
362
+ unless isNullOrWhiteSpace(fields)
363
+ query_parameters['fields'] = fields
364
+ end
365
+ unless isNullOrWhiteSpace(login_url)
366
+ query_parameters['loginUrl'] = login_url
367
+ end
368
+ unless isNullOrWhiteSpace(sms_template)
369
+ query_parameters['smsTemplate'] = sms_template
370
+ end
371
+ unless isNullOrWhiteSpace(sms_template2_f_a)
372
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
373
+ end
374
+ unless isNullOrWhiteSpace(verification_url)
375
+ query_parameters['verificationUrl'] = verification_url
376
+ end
377
+ unless isNullOrWhiteSpace(email_template2_f_a)
378
+ query_parameters['emailTemplate2FA'] = email_template2_f_a
379
+ end
380
+
381
+ body_parameters = {}
382
+ body_parameters['email'] = email
383
+ body_parameters['password'] = password
384
+
385
+ resource_path = 'identity/v2/auth/login/2fa'
386
+ post_request(resource_path, query_parameters, body_parameters)
387
+ end
388
+
389
+ # This API can be used to login by username on a Multi-factor authentication enabled LoginRadius site.
390
+ #
391
+ # @param password - Password for the email
392
+ # @param username - Username of the user
393
+ # @param email_template - Email template name
394
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
395
+ # @param login_url - Url where the user is logging from
396
+ # @param sms_template - SMS Template name
397
+ # @param sms_template2_f_a - SMS Template Name
398
+ # @param verification_url - Email verification url
399
+ # @param email_template2_f_a - 2FA Email Template name
400
+ #
401
+ # @return Complete user UserProfile data
402
+ # 9.8.2
403
+ def mfa_login_by_user_name(password, username, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '', email_template2_f_a = '')
404
+ if isNullOrWhiteSpace(password)
405
+ raise LoginRadius::Error.new, getValidationMessage('password')
406
+ end
407
+ if isNullOrWhiteSpace(username)
408
+ raise LoginRadius::Error.new, getValidationMessage('username')
409
+ end
410
+
411
+ query_parameters = {}
412
+ query_parameters['apiKey'] = @api_key
413
+ unless isNullOrWhiteSpace(email_template)
414
+ query_parameters['emailTemplate'] = email_template
415
+ end
416
+ unless isNullOrWhiteSpace(fields)
417
+ query_parameters['fields'] = fields
418
+ end
419
+ unless isNullOrWhiteSpace(login_url)
420
+ query_parameters['loginUrl'] = login_url
421
+ end
422
+ unless isNullOrWhiteSpace(sms_template)
423
+ query_parameters['smsTemplate'] = sms_template
424
+ end
425
+ unless isNullOrWhiteSpace(sms_template2_f_a)
426
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
427
+ end
428
+ unless isNullOrWhiteSpace(verification_url)
429
+ query_parameters['verificationUrl'] = verification_url
430
+ end
431
+ unless isNullOrWhiteSpace(email_template2_f_a)
432
+ query_parameters['emailTemplate2FA'] = email_template2_f_a
433
+ end
434
+
435
+ body_parameters = {}
436
+ body_parameters['password'] = password
437
+ body_parameters['username'] = username
438
+
439
+ resource_path = 'identity/v2/auth/login/2fa'
440
+ post_request(resource_path, query_parameters, body_parameters)
441
+ end
442
+
443
+ # This API can be used to login by Phone on a Multi-factor authentication enabled LoginRadius site.
444
+ #
445
+ # @param password - Password for the email
446
+ # @param phone - New Phone Number
447
+ # @param email_template - Email template name
448
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
449
+ # @param login_url - Url where the user is logging from
450
+ # @param sms_template - SMS Template name
451
+ # @param sms_template2_f_a - SMS Template Name
452
+ # @param verification_url - Email verification url
453
+ # @param email_template2_f_a - 2FA Email Template name
454
+ #
455
+ # @return Complete user UserProfile data
456
+ # 9.8.3
457
+ def mfa_login_by_phone(password, phone, email_template = '', fields = '', login_url = '', sms_template = '', sms_template2_f_a = '', verification_url = '', email_template2_f_a = '')
458
+ if isNullOrWhiteSpace(password)
459
+ raise LoginRadius::Error.new, getValidationMessage('password')
460
+ end
461
+ if isNullOrWhiteSpace(phone)
462
+ raise LoginRadius::Error.new, getValidationMessage('phone')
463
+ end
464
+
465
+ query_parameters = {}
466
+ query_parameters['apiKey'] = @api_key
467
+ unless isNullOrWhiteSpace(email_template)
468
+ query_parameters['emailTemplate'] = email_template
469
+ end
470
+ unless isNullOrWhiteSpace(fields)
471
+ query_parameters['fields'] = fields
472
+ end
473
+ unless isNullOrWhiteSpace(login_url)
474
+ query_parameters['loginUrl'] = login_url
475
+ end
476
+ unless isNullOrWhiteSpace(sms_template)
477
+ query_parameters['smsTemplate'] = sms_template
478
+ end
479
+ unless isNullOrWhiteSpace(sms_template2_f_a)
480
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
481
+ end
482
+ unless isNullOrWhiteSpace(verification_url)
483
+ query_parameters['verificationUrl'] = verification_url
484
+ end
485
+ unless isNullOrWhiteSpace(email_template2_f_a)
486
+ query_parameters['emailTemplate2FA'] = email_template2_f_a
487
+ end
488
+
489
+ body_parameters = {}
490
+ body_parameters['password'] = password
491
+ body_parameters['phone'] = phone
492
+
493
+ resource_path = 'identity/v2/auth/login/2fa'
494
+ post_request(resource_path, query_parameters, body_parameters)
495
+ end
496
+
497
+ # This API is used to login via Multi-factor authentication by passing the One Time Password received via SMS
498
+ #
499
+ # @param multi_factor_auth_model_with_lockout - Model Class containing Definition of payload for MultiFactorAuthModel With Lockout API
500
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
501
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
502
+ # @param sms_template2_f_a - SMS Template Name
503
+ # @param rba_browser_email_template -
504
+ # @param rba_city_email_template -
505
+ # @param rba_country_email_template -
506
+ # @param rba_ip_email_template -
507
+ #
508
+ # @return Complete user UserProfile data
509
+ # 9.12
510
+ def mfa_validate_otp_by_phone(multi_factor_auth_model_with_lockout, second_factor_authentication_token, fields = '', sms_template2_f_a = '' ,rba_browser_email_template = '', rba_city_email_template = '', rba_country_email_template = '', rba_ip_email_template = '')
511
+ if multi_factor_auth_model_with_lockout.blank?
512
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_with_lockout')
513
+ end
514
+ if isNullOrWhiteSpace(second_factor_authentication_token)
515
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
516
+ end
517
+
518
+ query_parameters = {}
519
+ query_parameters['apiKey'] = @api_key
520
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
521
+ unless isNullOrWhiteSpace(fields)
522
+ query_parameters['fields'] = fields
523
+ end
524
+ unless isNullOrWhiteSpace(sms_template2_f_a)
525
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
526
+ end
527
+ unless isNullOrWhiteSpace(rba_browser_email_template)
528
+ query_parameters['rbaBrowserEmailTemplate'] = rba_browser_email_template
529
+ end
530
+ unless isNullOrWhiteSpace(rba_city_email_template)
531
+ query_parameters['rbaCityEmailTemplate'] = rba_city_email_template
532
+ end
533
+ unless isNullOrWhiteSpace(rba_country_email_template)
534
+ query_parameters['rbaCountryEmailTemplate'] = rba_country_email_template
535
+ end
536
+ unless isNullOrWhiteSpace(rba_ip_email_template)
537
+ query_parameters['rbaIpEmailTemplate'] = rba_ip_email_template
538
+ end
539
+
540
+ resource_path = 'identity/v2/auth/login/2fa/verification/otp'
541
+ put_request(resource_path, query_parameters, multi_factor_auth_model_with_lockout)
542
+ end
543
+
544
+ # This API is used to login via Multi-factor-authentication by passing the google authenticator code.
545
+ #
546
+ # @param google_authenticator_code - The code generated by google authenticator app after scanning QR code
547
+ # @param second_factor_authentication_token - SecondFactorAuthenticationToken
548
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
549
+ # @param rba_browser_email_template - RbaBrowserEmailTemplate
550
+ # @param rba_city_email_template - RbaCityEmailTemplate
551
+ # @param rba_country_email_template - RbaCountryEmailTemplate
552
+ # @param rba_ip_email_template - RbaIpEmailTemplate
553
+ #
554
+ # @return Complete user UserProfile data
555
+ # 9.13
556
+ def mfa_validate_google_auth_code(google_authenticator_code, second_factor_authentication_token, fields = '', rba_browser_email_template = '', rba_city_email_template = '', rba_country_email_template = '', rba_ip_email_template = '')
557
+ if isNullOrWhiteSpace(google_authenticator_code)
558
+ raise LoginRadius::Error.new, getValidationMessage('google_authenticator_code')
559
+ end
560
+ if isNullOrWhiteSpace(second_factor_authentication_token)
561
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
562
+ end
563
+
564
+ query_parameters = {}
565
+ query_parameters['apiKey'] = @api_key
566
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
567
+ unless isNullOrWhiteSpace(fields)
568
+ query_parameters['fields'] = fields
569
+ end
570
+ unless isNullOrWhiteSpace(rba_browser_email_template)
571
+ query_parameters['rbaBrowserEmailTemplate'] = rba_browser_email_template
572
+ end
573
+ unless isNullOrWhiteSpace(rba_city_email_template)
574
+ query_parameters['rbaCityEmailTemplate'] = rba_city_email_template
575
+ end
576
+ unless isNullOrWhiteSpace(rba_country_email_template)
577
+ query_parameters['rbaCountryEmailTemplate'] = rba_country_email_template
578
+ end
579
+ unless isNullOrWhiteSpace(rba_ip_email_template)
580
+ query_parameters['rbaIpEmailTemplate'] = rba_ip_email_template
581
+ end
582
+
583
+ body_parameters = {}
584
+ body_parameters['googleAuthenticatorCode'] = google_authenticator_code
585
+
586
+ resource_path = 'identity/v2/auth/login/2fa/verification/googleauthenticatorcode'
587
+ put_request(resource_path, query_parameters, body_parameters)
588
+ end
589
+
590
+ # 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
591
+ #
592
+ # @param multi_factor_auth_model_by_backup_code - Model Class containing Definition of payload for MultiFactorAuth By BackupCode API
593
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
594
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
595
+ # @param rba_browser_email_template -
596
+ # @param rba_city_email_template -
597
+ # @param rba_country_email_template -
598
+ # @param rba_ip_email_template -
599
+ #
600
+ # @return Complete user UserProfile data
601
+ # 9.14
602
+ def mfa_validate_backup_code(multi_factor_auth_model_by_backup_code, second_factor_authentication_token, fields = '', rba_browser_email_template = '', rba_city_email_template = '', rba_country_email_template = '', rba_ip_email_template = '')
603
+ if multi_factor_auth_model_by_backup_code.blank?
604
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_by_backup_code')
605
+ end
606
+ if isNullOrWhiteSpace(second_factor_authentication_token)
607
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
608
+ end
609
+
610
+ query_parameters = {}
611
+ query_parameters['apiKey'] = @api_key
612
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
613
+ unless isNullOrWhiteSpace(fields)
614
+ query_parameters['fields'] = fields
615
+ end
616
+ unless isNullOrWhiteSpace(rba_browser_email_template)
617
+ query_parameters['rbaBrowserEmailTemplate'] = rba_browser_email_template
618
+ end
619
+ unless isNullOrWhiteSpace(rba_city_email_template)
620
+ query_parameters['rbaCityEmailTemplate'] = rba_city_email_template
621
+ end
622
+ unless isNullOrWhiteSpace(rba_country_email_template)
623
+ query_parameters['rbaCountryEmailTemplate'] = rba_country_email_template
624
+ end
625
+ unless isNullOrWhiteSpace(rba_ip_email_template)
626
+ query_parameters['rbaIpEmailTemplate'] = rba_ip_email_template
627
+ end
628
+
629
+ resource_path = 'identity/v2/auth/login/2fa/verification/backupcode'
630
+ put_request(resource_path, query_parameters, multi_factor_auth_model_by_backup_code)
631
+ end
632
+
633
+ # 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
634
+ #
635
+ # @param phone_no2_f_a - Phone Number For 2FA
636
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
637
+ # @param sms_template2_f_a - SMS Template Name
638
+ #
639
+ # @return Response containing Definition for Complete SMS data
640
+ # 9.16
641
+ def mfa_update_phone_number(phone_no2_f_a, second_factor_authentication_token, sms_template2_f_a = '')
642
+ if isNullOrWhiteSpace(phone_no2_f_a)
643
+ raise LoginRadius::Error.new, getValidationMessage('phone_no2_f_a')
644
+ end
645
+ if isNullOrWhiteSpace(second_factor_authentication_token)
646
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
647
+ end
648
+
649
+ query_parameters = {}
650
+ query_parameters['apiKey'] = @api_key
651
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
652
+ unless isNullOrWhiteSpace(sms_template2_f_a)
653
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
654
+ end
655
+
656
+ body_parameters = {}
657
+ body_parameters['phoneNo2FA'] = phone_no2_f_a
658
+
659
+ resource_path = 'identity/v2/auth/login/2fa'
660
+ put_request(resource_path, query_parameters, body_parameters)
661
+ end
662
+
663
+ # This API is used to resending the verification OTP to the provided phone number
664
+ #
665
+ # @param second_factor_authentication_token - A Uniquely generated MFA identifier token after successful authentication
666
+ # @param sms_template2_f_a - SMS Template Name
667
+ #
668
+ # @return Response containing Definition for Complete SMS data
669
+ # 9.17
670
+ def mfa_resend_otp(second_factor_authentication_token, sms_template2_f_a = '')
671
+ if isNullOrWhiteSpace(second_factor_authentication_token)
672
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
673
+ end
674
+
675
+ query_parameters = {}
676
+ query_parameters['apiKey'] = @api_key
677
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
678
+ unless isNullOrWhiteSpace(sms_template2_f_a)
679
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
680
+ end
681
+
682
+ resource_path = 'identity/v2/auth/login/2fa/resend'
683
+ get_request(resource_path, query_parameters, {})
684
+ end
685
+
686
+ # An API designed to send the MFA Email OTP to the email.
687
+ #
688
+ # @param email_id_model - payload
689
+ # @param second_factor_authentication_token - SecondFactorAuthenticationToken
690
+ # @param email_template2_f_a - EmailTemplate2FA
691
+ #
692
+ # @return Response containing Definition of Complete Validation data
693
+ # 9.18
694
+ def mfa_email_otp(email_id_model, second_factor_authentication_token, email_template2_f_a = '')
695
+ if email_id_model.blank?
696
+ raise LoginRadius::Error.new, getValidationMessage('email_id_model')
697
+ end
698
+ if isNullOrWhiteSpace(second_factor_authentication_token)
699
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
700
+ end
701
+
702
+ query_parameters = {}
703
+ query_parameters['apiKey'] = @api_key
704
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
705
+ unless isNullOrWhiteSpace(email_template2_f_a)
706
+ query_parameters['emailTemplate2FA'] = email_template2_f_a
707
+ end
708
+
709
+ resource_path = 'identity/v2/auth/login/2fa/otp/email'
710
+ post_request(resource_path, query_parameters, email_id_model)
711
+ end
712
+
713
+ # This API is used to Verify MFA Email OTP by MFA Token
714
+ #
715
+ # @param multi_factor_auth_model_by_email_otp - payload
716
+ # @param second_factor_authentication_token - SecondFactorAuthenticationToken
717
+ # @param rba_browser_email_template - RbaBrowserEmailTemplate
718
+ # @param rba_city_email_template - RbaCityEmailTemplate
719
+ # @param rba_country_email_template - RbaCountryEmailTemplate
720
+ # @param rba_ip_email_template - RbaIpEmailTemplate
721
+ #
722
+ # @return Response Containing Access Token and Complete Profile Data
723
+ # 9.25
724
+ def mfa_validate_email_otp(multi_factor_auth_model_by_email_otp, second_factor_authentication_token, rba_browser_email_template = '', rba_city_email_template = '', rba_country_email_template = '', rba_ip_email_template = '')
725
+ if multi_factor_auth_model_by_email_otp.blank?
726
+ raise LoginRadius::Error.new, getValidationMessage('multi_factor_auth_model_by_email_otp')
727
+ end
728
+ if isNullOrWhiteSpace(second_factor_authentication_token)
729
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
730
+ end
731
+
732
+ query_parameters = {}
733
+ query_parameters['apiKey'] = @api_key
734
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
735
+ unless isNullOrWhiteSpace(rba_browser_email_template)
736
+ query_parameters['rbaBrowserEmailTemplate'] = rba_browser_email_template
737
+ end
738
+ unless isNullOrWhiteSpace(rba_city_email_template)
739
+ query_parameters['rbaCityEmailTemplate'] = rba_city_email_template
740
+ end
741
+ unless isNullOrWhiteSpace(rba_country_email_template)
742
+ query_parameters['rbaCountryEmailTemplate'] = rba_country_email_template
743
+ end
744
+ unless isNullOrWhiteSpace(rba_ip_email_template)
745
+ query_parameters['rbaIpEmailTemplate'] = rba_ip_email_template
746
+ end
747
+
748
+ resource_path = 'identity/v2/auth/login/2fa/verification/otp/email'
749
+ put_request(resource_path, query_parameters, multi_factor_auth_model_by_email_otp)
750
+ end
751
+
752
+ # This API is used to set the security questions on the profile with the MFA token when MFA flow is required.
753
+ #
754
+ # @param security_question_answer_update_model - payload
755
+ # @param second_factor_authentication_token - SecondFactorAuthenticationToken
756
+ #
757
+ # @return Response Containing Access Token and Complete Profile Data
758
+ # 9.26
759
+ def mfa_security_question_answer(security_question_answer_update_model, second_factor_authentication_token)
760
+ if security_question_answer_update_model.blank?
761
+ raise LoginRadius::Error.new, getValidationMessage('security_question_answer_update_model')
762
+ end
763
+ if isNullOrWhiteSpace(second_factor_authentication_token)
764
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
765
+ end
766
+
767
+ query_parameters = {}
768
+ query_parameters['apiKey'] = @api_key
769
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
770
+
771
+ resource_path = 'identity/v2/auth/login/2fa/securityquestionanswer'
772
+ put_request(resource_path, query_parameters, security_question_answer_update_model)
773
+ end
774
+
775
+ # This API is used to resending the verification OTP to the provided phone number
776
+ #
777
+ # @param security_question_answer_update_model - payload
778
+ # @param second_factor_authentication_token - SecondFactorAuthenticationToken
779
+ # @param rba_browser_email_template - RbaBrowserEmailTemplate
780
+ # @param rba_city_email_template - RbaCityEmailTemplate
781
+ # @param rba_country_email_template - RbaCountryEmailTemplate
782
+ # @param rba_ip_email_template - RbaIpEmailTemplate
783
+ #
784
+ # @return Response Containing Access Token and Complete Profile Data
785
+ # 9.27
786
+ def mfa_security_question_answer_verification(security_question_answer_update_model, second_factor_authentication_token, rba_browser_email_template = '', rba_city_email_template = '', rba_country_email_template = '', rba_ip_email_template = '')
787
+ if security_question_answer_update_model.blank?
788
+ raise LoginRadius::Error.new, getValidationMessage('security_question_answer_update_model')
789
+ end
790
+ if isNullOrWhiteSpace(second_factor_authentication_token)
791
+ raise LoginRadius::Error.new, getValidationMessage('second_factor_authentication_token')
792
+ end
793
+
794
+ query_parameters = {}
795
+ query_parameters['apiKey'] = @api_key
796
+ query_parameters['secondFactorAuthenticationToken'] = second_factor_authentication_token
797
+ unless isNullOrWhiteSpace(rba_browser_email_template)
798
+ query_parameters['rbaBrowserEmailTemplate'] = rba_browser_email_template
799
+ end
800
+ unless isNullOrWhiteSpace(rba_city_email_template)
801
+ query_parameters['rbaCityEmailTemplate'] = rba_city_email_template
802
+ end
803
+ unless isNullOrWhiteSpace(rba_country_email_template)
804
+ query_parameters['rbaCountryEmailTemplate'] = rba_country_email_template
805
+ end
806
+ unless isNullOrWhiteSpace(rba_ip_email_template)
807
+ query_parameters['rbaIpEmailTemplate'] = rba_ip_email_template
808
+ end
809
+
810
+ resource_path = 'identity/v2/auth/login/2fa/verification/securityquestionanswer'
811
+ post_request(resource_path, query_parameters, security_question_answer_update_model)
812
+ end
813
+
814
+ # This API resets the SMS Authenticator configurations on a given account via the UID.
815
+ #
816
+ # @param otpauthenticator - Pass 'otpauthenticator' to remove SMS Authenticator
817
+ # @param uid - UID, the unified identifier for each user account
818
+ #
819
+ # @return Response containing Definition of Delete Request
820
+ # 18.21.1
821
+ def mfa_reset_sms_authenticator_by_uid(otpauthenticator, uid)
822
+ if isNullOrWhiteSpace(uid)
823
+ raise LoginRadius::Error.new, getValidationMessage('uid')
824
+ end
825
+
826
+ query_parameters = {}
827
+ query_parameters['apiKey'] = @api_key
828
+ query_parameters['apiSecret'] = @api_secret
829
+ query_parameters['uid'] = uid
830
+
831
+ body_parameters = {}
832
+ body_parameters['otpauthenticator'] = otpauthenticator
833
+
834
+ resource_path = 'identity/v2/manage/account/2fa/authenticator'
835
+ delete_request(resource_path, query_parameters, body_parameters)
836
+ end
837
+
838
+ # This API resets the Google Authenticator configurations on a given account via the UID.
839
+ #
840
+ # @param googleauthenticator - boolean type value,Enable google Authenticator Code.
841
+ # @param uid - UID, the unified identifier for each user account
842
+ #
843
+ # @return Response containing Definition of Delete Request
844
+ # 18.21.2
845
+ def mfa_reset_google_authenticator_by_uid(googleauthenticator, uid)
846
+ if isNullOrWhiteSpace(uid)
847
+ raise LoginRadius::Error.new, getValidationMessage('uid')
848
+ end
849
+
850
+ query_parameters = {}
851
+ query_parameters['apiKey'] = @api_key
852
+ query_parameters['apiSecret'] = @api_secret
853
+ query_parameters['uid'] = uid
854
+
855
+ body_parameters = {}
856
+ body_parameters['googleauthenticator'] = googleauthenticator
857
+
858
+ resource_path = 'identity/v2/manage/account/2fa/authenticator'
859
+ delete_request(resource_path, query_parameters, body_parameters)
860
+ end
861
+
862
+ # 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.
863
+ #
864
+ # @param uid - UID, the unified identifier for each user account
865
+ #
866
+ # @return Response containing Definition of Complete Backup Code data
867
+ # 18.25
868
+ def mfa_backup_code_by_uid(uid)
869
+ if isNullOrWhiteSpace(uid)
870
+ raise LoginRadius::Error.new, getValidationMessage('uid')
871
+ end
872
+
873
+ query_parameters = {}
874
+ query_parameters['apiKey'] = @api_key
875
+ query_parameters['apiSecret'] = @api_secret
876
+ query_parameters['uid'] = uid
877
+
878
+ resource_path = 'identity/v2/manage/account/2fa/backupcode'
879
+ get_request(resource_path, query_parameters, {})
880
+ end
881
+
882
+ # 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.
883
+ #
884
+ # @param uid - UID, the unified identifier for each user account
885
+ #
886
+ # @return Response containing Definition of Complete Backup Code data
887
+ # 18.26
888
+ def mfa_reset_backup_code_by_uid(uid)
889
+ if isNullOrWhiteSpace(uid)
890
+ raise LoginRadius::Error.new, getValidationMessage('uid')
891
+ end
892
+
893
+ query_parameters = {}
894
+ query_parameters['apiKey'] = @api_key
895
+ query_parameters['apiSecret'] = @api_secret
896
+ query_parameters['uid'] = uid
897
+
898
+ resource_path = 'identity/v2/manage/account/2fa/backupcode/reset'
899
+ get_request(resource_path, query_parameters, {})
900
+ end
901
+
902
+ # This API is used to reset the Email OTP Authenticator settings for an MFA-enabled user.
903
+ #
904
+ # @param uid - UID, the unified identifier for each user account
905
+ #
906
+ # @return Response containing Definition of Delete Request
907
+ # 18.42
908
+ def mfa_reset_email_otp_authenticator_by_uid(uid)
909
+ if isNullOrWhiteSpace(uid)
910
+ raise LoginRadius::Error.new, getValidationMessage('uid')
911
+ end
912
+
913
+ query_parameters = {}
914
+ query_parameters['apiKey'] = @api_key
915
+ query_parameters['apiSecret'] = @api_secret
916
+ query_parameters['uid'] = uid
917
+
918
+ resource_path = 'identity/v2/manage/account/2fa/authenticator/otp/email'
919
+ delete_request(resource_path, query_parameters, {})
920
+ end
921
+
922
+ # This API is used to reset the Security Question Authenticator settings for an MFA-enabled user.
923
+ #
924
+ # @param uid - UID, the unified identifier for each user account
925
+ #
926
+ # @return Response containing Definition of Delete Request
927
+ # 18.43
928
+ def mfa_reset_security_question_authenticator_by_uid(uid)
929
+ if isNullOrWhiteSpace(uid)
930
+ raise LoginRadius::Error.new, getValidationMessage('uid')
931
+ end
932
+
933
+ query_parameters = {}
934
+ query_parameters['apiKey'] = @api_key
935
+ query_parameters['apiSecret'] = @api_secret
936
+ query_parameters['uid'] = uid
937
+
938
+ resource_path = 'identity/v2/manage/account/2fa/authenticator/securityquestionanswer'
939
+ delete_request(resource_path, query_parameters, {})
940
+ end
941
+ end
942
+ end