AuthenticationProviderInterface.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/Settings/SettingsRegistry.h>
  10. #include <AzCore/std/smart_ptr/weak_ptr.h>
  11. #include <Authentication/AuthenticationTokens.h>
  12. namespace AWSClientAuth
  13. {
  14. //! Interface to be implemented by AuthenticationProviders to interact with AuthenticationManager.
  15. //! Follows grant types for password and device from following: https://oauth.net/2/grant-types/
  16. class AuthenticationProviderInterface
  17. {
  18. public:
  19. AuthenticationProviderInterface() = default;
  20. virtual ~AuthenticationProviderInterface() = default;
  21. //! Extract required settings for the provider from setting registry.
  22. //! @return bool True: if provider can parse required settings and validate. False: fails to parse required settings.
  23. virtual bool Initialize() = 0;
  24. //! Call sign in endpoint for provider password grant flow.
  25. //! @param username Username to use to for sign in.
  26. //! @param password Password to use to for sign in.
  27. virtual void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) = 0;
  28. //! Call sign in endpoint for provider password grant multi factor authentication flow.
  29. //! @param username Username to use for MFA sign in.
  30. //! @param password Password to use for MFA sign in.
  31. virtual void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) = 0;
  32. //! Call confirm endpoint for provider password grant multi factor authentication flow .
  33. //! @param username Username to use for MFA confirm.
  34. //! @param confirmationCode Confirmation code (sent to email/text) to use for MFA confirm.
  35. virtual void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) = 0;
  36. //! Call code-pair endpoint for provider device grant flow.
  37. virtual void DeviceCodeGrantSignInAsync() = 0;
  38. //! Call tokens endpoint for provider device grant flow.
  39. virtual void DeviceCodeGrantConfirmSignInAsync() = 0;
  40. //! Call refresh endpoint for provider refresh grant flow.
  41. virtual void RefreshTokensAsync() = 0;
  42. //! @return Authentication tokens from last successful sign in.
  43. virtual AuthenticationTokens GetAuthenticationTokens();
  44. //! Clears all cached tokens and expiry
  45. virtual void SignOut();
  46. protected:
  47. AuthenticationTokens m_authenticationTokens;
  48. };
  49. } // namespace AWSClientAuth