AWSCognitoAuthenticationProvider.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 <Authentication/AuthenticationProviderInterface.h>
  10. #include <Authentication/AuthenticationProviderTypes.h>
  11. #include <aws/core/utils/Outcome.h>
  12. #include <aws/cognito-idp/CognitoIdentityProviderClient.h>
  13. namespace AWSClientAuth
  14. {
  15. //! Implements AWS Cognito User pool authentication
  16. class AWSCognitoAuthenticationProvider
  17. : public AuthenticationProviderInterface
  18. {
  19. public:
  20. AWSCognitoAuthenticationProvider() = default;
  21. virtual ~AWSCognitoAuthenticationProvider() = default;
  22. // AuthenticationProviderInterface overrides
  23. bool Initialize() override;
  24. void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
  25. void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
  26. void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) override;
  27. void DeviceCodeGrantSignInAsync() override;
  28. void DeviceCodeGrantConfirmSignInAsync() override;
  29. void RefreshTokensAsync() override;
  30. private:
  31. void InitiateAuthInternalAsync(const AZStd::string& username, const AZStd::string& password
  32. , AZStd::function<void(Aws::CognitoIdentityProvider::Model::InitiateAuthOutcome outcome)> outcomeCallback);
  33. void UpdateTokens(const Aws::CognitoIdentityProvider::Model::AuthenticationResultType& authenticationResult);
  34. protected:
  35. AZStd::string m_session;
  36. AZStd::string m_cognitoAppClientId;
  37. };
  38. } // namespace AWSClientAuth