AWSCognitoUserManagementBus.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/EBus/EBus.h>
  10. #include <AzCore/Settings/SettingsRegistryImpl.h>
  11. namespace AWSClientAuth
  12. {
  13. //! Abstract class for AWS Cognito user management requests.
  14. class IAWSCognitoUserManagementRequests
  15. {
  16. public:
  17. AZ_TYPE_INFO(IAWSCognitoUserManagementRequests, "{A4C90F21-7056-4827-8C6B-401E6945697D}");
  18. //! Initialize Cognito User pool using settings from resource mappings.
  19. //! @param settingsRegistryPath settingsRegistryPath Path for the settings registry file to use.
  20. virtual bool Initialize() = 0;
  21. // Requests interface
  22. //! Cognito user pool email sign up start.
  23. //! @param username User name to use for sign up.
  24. //! @param password Password to use for sign up.
  25. //! @param email Email used to send confirmation code.
  26. virtual void EmailSignUpAsync(const AZStd::string& userName, const AZStd::string& password, const AZStd::string& email) = 0;
  27. //! Cognito user pool phone sign up start.
  28. //! @param username User name to use for sign up.
  29. //! @param password Password to use for sign up.
  30. //! @param phoneNumber Phone number used to send confirmation code.
  31. virtual void PhoneSignUpAsync(const AZStd::string& userName, const AZStd::string& password, const AZStd::string& phoneNumber) = 0;
  32. //! Cognito user pool confirm sign up with confirmation code. Used to confirm email or phone sign up.
  33. //! @param username User name to use to confirm sign up.
  34. //! @param confirmationCode Code sent to email/phone from sign up call.
  35. virtual void ConfirmSignUpAsync(const AZStd::string& userName, const AZStd::string& confirmationCode) = 0;
  36. //! Cognito user forgot password start
  37. //! @param username User name to use to reset password for.
  38. virtual void ForgotPasswordAsync(const AZStd::string& userName) = 0;
  39. //! Cognito user pool confirm forgot password with confirmation code.
  40. //! @param username User name to use to confirm reset password for.
  41. //! @param confirmationCode Code sent to email/phone for forgot password step.
  42. //! @param newPassword New password to set the changed value to.
  43. virtual void ConfirmForgotPasswordAsync(const AZStd::string& userName, const AZStd::string& confirmationCode, const AZStd::string& newPassword) = 0;
  44. //! Cognito user pool enable multi factor authentication for signed in user.
  45. //! @param accessToken Access token from successful sign in.
  46. virtual void EnableMFAAsync(const AZStd::string& accessToken) = 0;
  47. };
  48. //! Implements AWS Cognito user pool user management requests.
  49. class AWSCognitoUserManagementRequests
  50. : public AZ::EBusTraits
  51. {
  52. public:
  53. //////////////////////////////////////////////////////////////////////////
  54. // EBusTraits overrides
  55. using MutexType = AZ::NullMutex;
  56. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  57. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  58. //////////////////////////////////////////////////////////////////////////
  59. };
  60. using AWSCognitoUserManagementRequestBus = AZ::EBus<IAWSCognitoUserManagementRequests, AWSCognitoUserManagementRequests>;
  61. class AWSCognitoUserManagementNotifications
  62. : public AZ::EBusTraits
  63. {
  64. public:
  65. //////////////////////////////////////////////////////////////////////////
  66. // EBusTraits overrides
  67. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  68. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  69. //////////////////////////////////////////////////////////////////////////
  70. ////////////////////////////ss//////////////////////////////////////////////
  71. // Notifications interface
  72. //! Event for Cognito user pool email sign up success
  73. //! @param uuid Unique identified from Cognito User pool for new user
  74. virtual void OnEmailSignUpSuccess(const AZStd::string& uuid)
  75. {
  76. AZ_UNUSED(uuid);
  77. }
  78. //! Event for Cognito user pool email sign up fail
  79. //! @param error Error message
  80. virtual void OnEmailSignUpFail(const AZStd::string& error)
  81. {
  82. AZ_UNUSED(error);
  83. }
  84. //! Event for Cognito user pool phone sign up success
  85. //! @param error Error message
  86. virtual void OnPhoneSignUpSuccess(const AZStd::string& uuid)
  87. {
  88. AZ_UNUSED(uuid);
  89. }
  90. //! Event for Cognito user pool phone sign up fail
  91. //! @param error Error message
  92. virtual void OnPhoneSignUpFail(const AZStd::string& error)
  93. {
  94. AZ_UNUSED(error);
  95. }
  96. //! Event for Cognito confirm sign up success
  97. virtual void OnConfirmSignUpSuccess()
  98. {
  99. }
  100. //! Event for Cognito confirm sign up fail
  101. //! @param error Error message
  102. virtual void OnConfirmSignUpFail(const AZStd::string& error)
  103. {
  104. AZ_UNUSED(error);
  105. }
  106. //! Event for Cognito forgot password success
  107. virtual void OnForgotPasswordSuccess()
  108. {
  109. }
  110. //! Event for Cognito forgot password fail
  111. //! @param error Error message
  112. virtual void OnForgotPasswordFail(const AZStd::string& error)
  113. {
  114. AZ_UNUSED(error);
  115. }
  116. //! Event for Cognito confirm forgot password success
  117. virtual void OnConfirmForgotPasswordSuccess()
  118. {
  119. }
  120. //! Event for Cognito confirm forgot password fail
  121. //! @param error Error message
  122. virtual void OnConfirmForgotPasswordFail(const AZStd::string& error)
  123. {
  124. AZ_UNUSED(error);
  125. }
  126. //! Event for Cognito enable mfa success
  127. virtual void OnEnableMFASuccess()
  128. {
  129. }
  130. //! Event for Cognito enable mfa fail
  131. //! @param error Error message
  132. virtual void OnEnableMFAFail(const AZStd::string& error)
  133. {
  134. AZ_UNUSED(error);
  135. }
  136. //////////////////////////////////////////////////////////////////////////
  137. };
  138. using AWSCognitoUserManagementNotificationBus = AZ::EBus<AWSCognitoUserManagementNotifications>;
  139. } // namespace AWSClientAuth