Move the header files in the AWS ClientAuth gem based on the latest gem structure guideline" (#5177)
Signed-off-by: Junbo Liang <68558268+junbo75@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Aws
|
||||
{
|
||||
namespace CognitoIdentityProvider
|
||||
{
|
||||
class CognitoIdentityProviderClient;
|
||||
}
|
||||
|
||||
namespace CognitoIdentity
|
||||
{
|
||||
class CognitoIdentityClient;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Abstract class for AWS client auth requests.
|
||||
class IAWSClientAuthRequests
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(IAWSClientAuthRequests, "{1798CB8B-A334-40BD-913A-4739BF939201}");
|
||||
|
||||
//! std shared_ptr as the ownership has to be shared with AWS Native SDK.
|
||||
//! @return AWS Native SDK Cognito IDP client
|
||||
virtual std::shared_ptr<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient> GetCognitoIDPClient() = 0;
|
||||
|
||||
//! std shared_ptr as the ownership has to be shared with AWS Native SDK.
|
||||
//! @return AWS Native SDK Cognito Identity client
|
||||
virtual std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> GetCognitoIdentityClient() = 0;
|
||||
};
|
||||
|
||||
//! Responsible for fetching AWS Cognito IDP and Identity service client objetcs.
|
||||
class AWSClientAuthRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
using MutexType = AZ::NullMutex;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
using AWSClientAuthRequestBus = AZ::EBus<IAWSClientAuthRequests, AWSClientAuthRequests>;
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Module/Module.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Entry point for the Gem.
|
||||
class AWSClientAuthModule
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSClientAuthModule, "{85AD4C5F-A40A-4503-9202-4B8BE6AF0DCD}", AZ::Module);
|
||||
|
||||
AWSClientAuthModule();
|
||||
virtual ~AWSClientAuthModule() override = default;
|
||||
virtual AZ::ComponentTypeList GetRequiredSystemComponents() const override;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
constexpr char CognitoUserPoolIdResourceMappingKey[] = "AWSClientAuth.CognitoUserPoolId";
|
||||
constexpr char CognitoAppClientIdResourceMappingKey[] = "AWSClientAuth.CognitoUserPoolAppClientId";
|
||||
constexpr char CognitoIdentityPoolIdResourceMappingKey[] = "AWSClientAuth.CognitoIdentityPoolId";
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <Authorization/AWSCognitoAuthorizationController.h>
|
||||
#include <Authentication/AuthenticationProviderManager.h>
|
||||
#include <UserManagement/AWSCognitoUserManagementController.h>
|
||||
#include <AWSClientAuthBus.h>
|
||||
#include <AWSCoreBus.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Gem System Component. Responsible for instantiating and managing Authentication and Authroziation Controller
|
||||
class AWSClientAuthSystemComponent
|
||||
: public AZ::Component
|
||||
, public AWSCore::AWSCoreNotificationsBus::Handler
|
||||
, public AWSClientAuthRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~AWSClientAuthSystemComponent() = default;
|
||||
|
||||
AZ_COMPONENT(AWSClientAuthSystemComponent, "{0C2660C8-1B4A-4474-BE65-B487E2DE8649}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
protected:
|
||||
// AZ::Component interface implementation
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// AWSCoreNotification interface
|
||||
void OnSDKInitialized() override;
|
||||
void OnSDKShutdownStarted() override {}
|
||||
|
||||
// AWSClientAuthRequests interface
|
||||
std::shared_ptr<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient> GetCognitoIDPClient() override;
|
||||
std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> GetCognitoIdentityClient() override;
|
||||
|
||||
AZStd::vector<ProviderNameEnum> m_enabledProviderNames;
|
||||
AZStd::unique_ptr<AuthenticationProviderManager> m_authenticationProviderManager;
|
||||
AZStd::unique_ptr<AWSCognitoUserManagementController> m_awsCognitoUserManagementController;
|
||||
AZStd::unique_ptr<AWSCognitoAuthorizationController> m_awsCognitoAuthorizationController;
|
||||
|
||||
std::shared_ptr<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient> m_cognitoIdentityProviderClient;
|
||||
std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> m_cognitoIdentityClient;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Authentication/AuthenticationProviderInterface.h>
|
||||
#include <Authentication/AuthenticationProviderTypes.h>
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/cognito-idp/CognitoIdentityProviderClient.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Implements AWS Cognito User pool authentication
|
||||
class AWSCognitoAuthenticationProvider
|
||||
: public AuthenticationProviderInterface
|
||||
{
|
||||
public:
|
||||
AWSCognitoAuthenticationProvider() = default;
|
||||
virtual ~AWSCognitoAuthenticationProvider() = default;
|
||||
|
||||
// AuthenticationProviderInterface overrides
|
||||
bool Initialize() override;
|
||||
void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void DeviceCodeGrantSignInAsync() override;
|
||||
void DeviceCodeGrantConfirmSignInAsync() override;
|
||||
void RefreshTokensAsync() override;
|
||||
|
||||
private:
|
||||
void InitiateAuthInternalAsync(const AZStd::string& username, const AZStd::string& password
|
||||
, AZStd::function<void(Aws::CognitoIdentityProvider::Model::InitiateAuthOutcome outcome)> outcomeCallback);
|
||||
void UpdateTokens(const Aws::CognitoIdentityProvider::Model::AuthenticationResultType& authenticationResult);
|
||||
|
||||
protected:
|
||||
AZStd::string m_session;
|
||||
AZStd::string m_cognitoAppClientId;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Authentication/AuthenticationProviderBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Authentication behavior EBus handler
|
||||
class AuthenticationNotificationBusBehaviorHandler
|
||||
: public AuthenticationProviderNotificationBus::Handler
|
||||
, public AZ::BehaviorEBusHandler
|
||||
{
|
||||
public:
|
||||
AZ_EBUS_BEHAVIOR_BINDER(
|
||||
AuthenticationNotificationBusBehaviorHandler, "{221D74E0-B55A-4086-8B83-B52070A57217}", AZ::SystemAllocator,
|
||||
OnPasswordGrantSingleFactorSignInSuccess, OnPasswordGrantSingleFactorSignInFail,
|
||||
OnPasswordGrantMultiFactorSignInSuccess, OnPasswordGrantMultiFactorSignInFail,
|
||||
OnPasswordGrantMultiFactorConfirmSignInSuccess, OnPasswordGrantMultiFactorConfirmSignInFail,
|
||||
OnDeviceCodeGrantSignInSuccess, OnDeviceCodeGrantSignInFail,
|
||||
OnDeviceCodeGrantConfirmSignInSuccess, OnDeviceCodeGrantConfirmSignInFail,
|
||||
OnRefreshTokensSuccess, OnRefreshTokensFail
|
||||
);
|
||||
|
||||
void OnPasswordGrantSingleFactorSignInSuccess(const AuthenticationTokens& authenticationToken) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([authenticationToken, this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantSingleFactorSignInSuccess, authenticationToken);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPasswordGrantSingleFactorSignInFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantSingleFactorSignInFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPasswordGrantMultiFactorSignInSuccess() override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantMultiFactorSignInSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPasswordGrantMultiFactorSignInFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantMultiFactorSignInFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPasswordGrantMultiFactorConfirmSignInSuccess(const AuthenticationTokens& authenticationToken) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([authenticationToken, this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantMultiFactorConfirmSignInSuccess, authenticationToken);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPasswordGrantMultiFactorConfirmSignInFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnPasswordGrantMultiFactorConfirmSignInFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnDeviceCodeGrantSignInSuccess(
|
||||
const AZStd::string& userCode, const AZStd::string& verificationUrl, const int codeExpiresInSeconds) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([userCode, verificationUrl, codeExpiresInSeconds, this]()
|
||||
{
|
||||
Call(FN_OnDeviceCodeGrantSignInSuccess, userCode, verificationUrl, codeExpiresInSeconds);
|
||||
});
|
||||
}
|
||||
|
||||
void OnDeviceCodeGrantSignInFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnDeviceCodeGrantSignInFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnDeviceCodeGrantConfirmSignInSuccess(const AuthenticationTokens& authenticationToken) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([authenticationToken, this]()
|
||||
{
|
||||
Call(FN_OnDeviceCodeGrantConfirmSignInSuccess, authenticationToken);
|
||||
});
|
||||
}
|
||||
|
||||
void OnDeviceCodeGrantConfirmSignInFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnDeviceCodeGrantConfirmSignInFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnRefreshTokensSuccess(const AuthenticationTokens& authenticationToken) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([authenticationToken, this]()
|
||||
{
|
||||
Call(FN_OnRefreshTokensSuccess, authenticationToken);
|
||||
});
|
||||
}
|
||||
|
||||
void OnRefreshTokensFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnRefreshTokensFail, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/std/smart_ptr/weak_ptr.h>
|
||||
#include <Authentication/AuthenticationTokens.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
|
||||
//! Interface to be implemented by AuthenticationProviders to interact with AuthenticationManager.
|
||||
//! Follows grant types for password and device from following: https://oauth.net/2/grant-types/
|
||||
class AuthenticationProviderInterface
|
||||
{
|
||||
public:
|
||||
AuthenticationProviderInterface() = default;
|
||||
virtual ~AuthenticationProviderInterface() = default;
|
||||
|
||||
//! Extract required settings for the provider from setting registry.
|
||||
//! @return bool True: if provider can parse required settings and validate. False: fails to parse required settings.
|
||||
virtual bool Initialize() = 0;
|
||||
|
||||
//! Call sign in endpoint for provider password grant flow.
|
||||
//! @param username Username to use to for sign in.
|
||||
//! @param password Password to use to for sign in.
|
||||
virtual void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) = 0;
|
||||
|
||||
//! Call sign in endpoint for provider password grant multi factor authentication flow.
|
||||
//! @param username Username to use for MFA sign in.
|
||||
//! @param password Password to use for MFA sign in.
|
||||
virtual void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) = 0;
|
||||
|
||||
//! Call confirm endpoint for provider password grant multi factor authentication flow .
|
||||
//! @param username Username to use for MFA confirm.
|
||||
//! @param confirmationCode Confirmation code (sent to email/text) to use for MFA confirm.
|
||||
virtual void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) = 0;
|
||||
|
||||
//! Call code-pair endpoint for provider device grant flow.
|
||||
virtual void DeviceCodeGrantSignInAsync() = 0;
|
||||
|
||||
//! Call tokens endpoint for provider device grant flow.
|
||||
virtual void DeviceCodeGrantConfirmSignInAsync() = 0;
|
||||
|
||||
//! Call refresh endpoint for provider refresh grant flow.
|
||||
virtual void RefreshTokensAsync() = 0;
|
||||
|
||||
//! @return Authentication tokens from last successful sign in.
|
||||
virtual AuthenticationTokens GetAuthenticationTokens();
|
||||
|
||||
//! Clears all cached tokens and expiry
|
||||
virtual void SignOut();
|
||||
|
||||
protected:
|
||||
AuthenticationTokens m_authenticationTokens;
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include <AzCore/std/containers/map.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <Authentication/AuthenticationProviderBus.h>
|
||||
#include <Authentication/AuthenticationProviderScriptCanvasBus.h>
|
||||
#include <Authentication/AuthenticationProviderInterface.h>
|
||||
#include <Authentication/AuthenticationTokens.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Manages various authentication provider implementations and implements AuthenticationProvider Request bus.
|
||||
class AuthenticationProviderManager
|
||||
: public AuthenticationProviderRequestBus::Handler
|
||||
, public AuthenticationProviderScriptCanvasRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AuthenticationProviderManager, "{45813BA5-9A46-4A2A-A923-C79CFBA0E63D}", IAuthenticationProviderRequests);
|
||||
AuthenticationProviderManager();
|
||||
virtual ~AuthenticationProviderManager();
|
||||
|
||||
protected:
|
||||
// AuthenticationProviderRequestsBus Interface
|
||||
bool Initialize(const AZStd::vector<ProviderNameEnum>& providerNames) override;
|
||||
void PasswordGrantSingleFactorSignInAsync(const ProviderNameEnum& providerName, const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorSignInAsync(const ProviderNameEnum& providerName, const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorConfirmSignInAsync(const ProviderNameEnum& providerName, const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void DeviceCodeGrantSignInAsync(const ProviderNameEnum& providerName) override;
|
||||
void DeviceCodeGrantConfirmSignInAsync(const ProviderNameEnum& providerName) override;
|
||||
void RefreshTokensAsync(const ProviderNameEnum& providerName) override;
|
||||
void GetTokensWithRefreshAsync(const ProviderNameEnum& providerName) override;
|
||||
bool IsSignedIn(const ProviderNameEnum& providerName) override;
|
||||
bool SignOut(const ProviderNameEnum& providerName) override;
|
||||
AuthenticationTokens GetAuthenticationTokens(const ProviderNameEnum& providerName) override;
|
||||
|
||||
// AuthenticationProviderScriptCanvasRequest interface
|
||||
bool Initialize(const AZStd::vector<AZStd::string>& providerNames) override;
|
||||
void PasswordGrantSingleFactorSignInAsync(
|
||||
const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorSignInAsync(
|
||||
const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorConfirmSignInAsync(
|
||||
const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void DeviceCodeGrantSignInAsync(const AZStd::string& providerName) override;
|
||||
void DeviceCodeGrantConfirmSignInAsync(const AZStd::string& providerName) override;
|
||||
void RefreshTokensAsync(const AZStd::string& providerName) override;
|
||||
void GetTokensWithRefreshAsync(const AZStd::string& providerName) override;
|
||||
bool IsSignedIn(const AZStd::string& providerName) override;
|
||||
bool SignOut(const AZStd::string& providerName) override;
|
||||
AuthenticationTokens GetAuthenticationTokens(const AZStd::string& providerName) override;
|
||||
|
||||
virtual AZStd::unique_ptr<AuthenticationProviderInterface> CreateAuthenticationProviderObject(const ProviderNameEnum& providerName);
|
||||
AZStd::map<ProviderNameEnum, AZStd::unique_ptr<AuthenticationProviderInterface>> m_authenticationProvidersMap;
|
||||
|
||||
private:
|
||||
bool IsProviderInitialized(const ProviderNameEnum& providerName);
|
||||
void ResetProviders();
|
||||
ProviderNameEnum GetProviderNameEnum(AZStd::string name);
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <Authentication/AuthenticationTokens.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Abstract class for authentication provider script canvas requests.
|
||||
//! Private class to allow provide names to be string type instead of an enum as behavior context does not work well with enum's.
|
||||
class IAuthenticationProviderScriptCanvasRequests
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(IAuthenticationProviderRequests, "{A8FD915F-9FF2-4BA3-8AA0-8CF7A94A323B}");
|
||||
|
||||
//! Parse the settings file for required settings for authentication providers. Instantiate and initialize authentication providers
|
||||
//! @param providerNames List of provider names to instantiate and initialize for Authentication.
|
||||
//! @return bool True: if all providers initialized successfully. False: If any provider fails initialization.
|
||||
virtual bool Initialize(const AZStd::vector<AZStd::string>& providerNames) = 0;
|
||||
|
||||
//! Checks if user is signed in.
|
||||
//! If access tokens are available and not expired.
|
||||
//! @param providerName Provider to check signed in for
|
||||
//! @return bool True if valid access token available, else False
|
||||
virtual bool IsSignedIn(const AZStd::string& providerName) = 0;
|
||||
|
||||
//! Get cached tokens from last last successful sign-in for the provider.
|
||||
//! @param providerName Provider to get authentication tokens
|
||||
//! @return AuthenticationTokens tokens from successful authentication.
|
||||
virtual AuthenticationTokens GetAuthenticationTokens(const AZStd::string& providerName) = 0;
|
||||
|
||||
// Below methods have corresponding notifications for success and failures.
|
||||
|
||||
//! Call sign in endpoint for provider password grant flow.
|
||||
//! @param providerName Provider to call sign in.
|
||||
//! @param username Username to use to for sign in.
|
||||
//! @param password Password to use to for sign in.
|
||||
virtual void PasswordGrantSingleFactorSignInAsync(const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& password) = 0;
|
||||
|
||||
//! Call sign in endpoint for provider password grant multi factor authentication flow.
|
||||
//! @param providerName Provider to call MFA sign in.
|
||||
//! @param username Username to use for MFA sign in.
|
||||
//! @param password Password to use for MFA sign in.
|
||||
virtual void PasswordGrantMultiFactorSignInAsync(const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& password) = 0;
|
||||
|
||||
//! Call confirm endpoint for provider password grant multi factor authentication flow .
|
||||
//! @param providerName Provider to call MFA confirm sign in.
|
||||
//! @param username Username to use for MFA confirm.
|
||||
//! @param confirmationCode Confirmation code (sent to email/text) to use for MFA confirm.
|
||||
virtual void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& providerName, const AZStd::string& username, const AZStd::string& confirmationCode) = 0;
|
||||
|
||||
//! Call code-pair endpoint for provider device grant flow.
|
||||
//! @param providerName Provider to call device sign in.
|
||||
virtual void DeviceCodeGrantSignInAsync(const AZStd::string& providerName) = 0;
|
||||
|
||||
//! Call tokens endpoint for provider device grant flow.
|
||||
//! @param providerName Provider to call device confirm sign in.
|
||||
virtual void DeviceCodeGrantConfirmSignInAsync(const AZStd::string& providerName) = 0;
|
||||
|
||||
//! Call refresh endpoint for provider refresh grant flow.
|
||||
//! @param providerName Provider to call refresh tokens.
|
||||
virtual void RefreshTokensAsync(const AZStd::string& providerName) = 0;
|
||||
|
||||
//! Call refresh token if token not valid. If token valid, fires corresponding event.
|
||||
//! @param providerName Provider to get access token for.
|
||||
//! events: OnRefreshTokensSuccess, OnRefreshTokensFail
|
||||
virtual void GetTokensWithRefreshAsync(const AZStd::string& providerName) = 0;
|
||||
|
||||
//! Signs user out.
|
||||
//! Clears all cached tokens.
|
||||
//! @param providerName Provider to sign out.
|
||||
//! @return bool True: Successfully sign out.
|
||||
virtual bool SignOut(const AZStd::string& providerName) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
//! Authentication Request bus for different supported providers.
|
||||
class AuthenticationProviderScriptCanvasRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
using MutexType = AZ::NullMutex;
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
using AuthenticationProviderScriptCanvasRequestBus = AZ::EBus<IAuthenticationProviderScriptCanvasRequests, AuthenticationProviderScriptCanvasRequests>;
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
constexpr char ProvideNameEnumStringNone[] = "None";
|
||||
constexpr char ProvideNameEnumStringAWSCognitoIDP[] = "AWSCognitoIDP";
|
||||
constexpr char ProvideNameEnumStringLoginWithAmazon[] = "LoginWithAmazon";
|
||||
constexpr char ProvideNameEnumStringGoogle[] = "Google";
|
||||
constexpr char ProvideNameEnumStringApple[] = "Apple";
|
||||
constexpr char ProvideNameEnumStringFacebook[] = "Facebook";
|
||||
constexpr char ProvideNameEnumStringTwitch[] = "Twitch";
|
||||
|
||||
//! Holds Login with Amazon provider serialized settings
|
||||
class LWAProviderSetting
|
||||
{
|
||||
public:
|
||||
LWAProviderSetting() = default;
|
||||
|
||||
~LWAProviderSetting() = default;
|
||||
|
||||
AZ_TYPE_INFO(LWAProviderSetting, "{AA7A0B0E-626B-4D87-B862-8961BA0C843E}");
|
||||
|
||||
AZStd::string m_appClientId;
|
||||
AZStd::string m_responseType;
|
||||
AZStd::string m_grantType;
|
||||
AZStd::string m_oAuthCodeURL;
|
||||
AZStd::string m_oAuthTokensURL;
|
||||
|
||||
static void Reflect(AZ::SerializeContext& context)
|
||||
{
|
||||
context.Class<LWAProviderSetting>()
|
||||
->Field("AppClientId", &LWAProviderSetting::m_appClientId)
|
||||
->Field("ResponseType", &LWAProviderSetting::m_responseType)
|
||||
->Field("GrantType", &LWAProviderSetting::m_grantType)
|
||||
->Field("OAuthCodeURL", &LWAProviderSetting::m_oAuthCodeURL)
|
||||
->Field("OAuthTokensURL", &LWAProviderSetting::m_oAuthTokensURL);
|
||||
}
|
||||
};
|
||||
|
||||
//! Holds Google provider serialized settings
|
||||
class GoogleProviderSetting
|
||||
{
|
||||
public:
|
||||
GoogleProviderSetting() = default;
|
||||
|
||||
~GoogleProviderSetting() = default;
|
||||
|
||||
AZ_TYPE_INFO(GoogleProviderSetting, "{C501E0DB-EEA5-4BC9-8E2E-CAE037AEE95F}");
|
||||
|
||||
AZStd::string m_appClientId;
|
||||
AZStd::string m_clientSecret;
|
||||
AZStd::string m_grantType;
|
||||
AZStd::string m_oAuthCodeURL;
|
||||
AZStd::string m_oAuthTokensURL;
|
||||
|
||||
static void Reflect(AZ::SerializeContext& context)
|
||||
{
|
||||
context.Class<GoogleProviderSetting>()
|
||||
->Field("AppClientId", &GoogleProviderSetting::m_appClientId)
|
||||
->Field("ClientSecret", &GoogleProviderSetting::m_clientSecret)
|
||||
->Field("GrantType", &GoogleProviderSetting::m_grantType)
|
||||
->Field("OAuthCodeURL", &GoogleProviderSetting::m_oAuthCodeURL)
|
||||
->Field("OAuthTokensURL", &GoogleProviderSetting::m_oAuthTokensURL);
|
||||
}
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Authentication/AuthenticationProviderInterface.h>
|
||||
#include <Authentication/AuthenticationProviderTypes.h>
|
||||
#include <aws/core/utils/json/JsonSerializer.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Implements OAuth2.0 device flow for Google authentication service.
|
||||
class GoogleAuthenticationProvider
|
||||
: public AuthenticationProviderInterface
|
||||
{
|
||||
public:
|
||||
GoogleAuthenticationProvider();
|
||||
virtual ~GoogleAuthenticationProvider();
|
||||
|
||||
// AuthenticationProviderInterface overrides
|
||||
bool Initialize() override;
|
||||
void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void DeviceCodeGrantSignInAsync() override;
|
||||
void DeviceCodeGrantConfirmSignInAsync() override;
|
||||
void RefreshTokensAsync() override;
|
||||
|
||||
private:
|
||||
void UpdateTokens(const Aws::Utils::Json::JsonView& jsonView);
|
||||
|
||||
protected:
|
||||
AZStd::unique_ptr<GoogleProviderSetting> m_settings;
|
||||
|
||||
private:
|
||||
AZStd::string m_cachedDeviceCode;
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Authentication/AuthenticationProviderInterface.h>
|
||||
#include <Authentication/AuthenticationProviderTypes.h>
|
||||
#include <aws/core/utils/json/JsonSerializer.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Implements OAuth2.0 device flow for Login with Amazon authentication service.
|
||||
class LWAAuthenticationProvider
|
||||
: public AuthenticationProviderInterface
|
||||
{
|
||||
public:
|
||||
LWAAuthenticationProvider();
|
||||
virtual ~LWAAuthenticationProvider();
|
||||
|
||||
// AuthenticationProviderInterface overrides
|
||||
bool Initialize() override;
|
||||
void PasswordGrantSingleFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorSignInAsync(const AZStd::string& username, const AZStd::string& password) override;
|
||||
void PasswordGrantMultiFactorConfirmSignInAsync(const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void DeviceCodeGrantSignInAsync() override;
|
||||
void DeviceCodeGrantConfirmSignInAsync() override;
|
||||
void RefreshTokensAsync() override;
|
||||
|
||||
private:
|
||||
void UpdateTokens(const Aws::Utils::Json::JsonView& jsonView);
|
||||
|
||||
protected:
|
||||
AZStd::unique_ptr<LWAProviderSetting> m_settings;
|
||||
|
||||
private:
|
||||
AZStd::string m_cachedUserCode;
|
||||
AZStd::string m_cachedDeviceCode;
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
constexpr char OAuthClientIdBodyKey[] = "client_id";
|
||||
constexpr char OAuthClientSecretBodyKey[] = "client_secret";
|
||||
constexpr char OAuthDeviceCodeBodyKey[] = "device_code";
|
||||
constexpr char OAuthScopeBodyKey[] = "scope";
|
||||
constexpr char OAuthScopeBodyValue[] = "profile";
|
||||
constexpr char OAuthGrantTypeBodyKey[] = "grant_type";
|
||||
constexpr char OAuthRefreshTokenBodyKey[] = "refresh_token";
|
||||
constexpr char OAuthRefreshTokenBodyValue[] = "refresh_token";
|
||||
constexpr char OAuthResponseTypeBodyKey[] = "response_type";
|
||||
|
||||
constexpr char OAuthContentTypeHeaderKey[] = "Content-Type";
|
||||
constexpr char OAuthContentTypeHeaderValue[] = "application/x-www-form-urlencoded";
|
||||
constexpr char OAuthContentLengthHeaderKey[] = "Content-Length";
|
||||
|
||||
constexpr char OAuthUserCodeResponseKey[] = "user_code";
|
||||
constexpr char OAuthIdTokenResponseKey[] = "id_token";
|
||||
constexpr char OAuthAccessTokenResponseKey[] = "access_token";
|
||||
constexpr char OAuthRefreshTokenResponseKey[] = "refresh_token";
|
||||
constexpr char OAuthExpiresInResponseKey[] = "expires_in";
|
||||
constexpr char OAuthErrorResponseKey[] = "error";
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aws/cognito-identity/CognitoIdentityClient.h>
|
||||
#include <aws/identity-management/auth/CognitoCachingCredentialsProvider.h>
|
||||
#include <aws/identity-management/auth/PersistentCognitoIdentityProvider.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Cognito Caching Credentials Provider implementation that is derived from AWS Native SDK.
|
||||
//! For use with authenticated credentials.
|
||||
class AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider
|
||||
: public Aws::Auth::CognitoCachingCredentialsProvider
|
||||
{
|
||||
public:
|
||||
AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient = nullptr);
|
||||
|
||||
protected:
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome GetCredentialsFromCognito() const override;
|
||||
};
|
||||
|
||||
//! Cognito Caching Credentials Provider implementation that is eventually derived from AWS Native SDK.
|
||||
//! For use with anonymous credentials.
|
||||
class AWSClientAuthCachingAnonymousCredsProvider : public AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider
|
||||
{
|
||||
public:
|
||||
AWSClientAuthCachingAnonymousCredsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient = nullptr);
|
||||
|
||||
protected:
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome GetCredentialsFromCognito() const override;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aws/identity-management/auth/PersistentCognitoIdentityProvider.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Persistent Cognito Identity provider implementation that is shared with AWS Native SDK client.
|
||||
//! Use std::shared_ptr to create instance.
|
||||
class AWSClientAuthPersistentCognitoIdentityProvider
|
||||
: public Aws::Auth::PersistentCognitoIdentityProvider
|
||||
{
|
||||
public:
|
||||
AWSClientAuthPersistentCognitoIdentityProvider() = default;
|
||||
virtual ~AWSClientAuthPersistentCognitoIdentityProvider();
|
||||
// PersistentCognitoIdentityProvider Interface
|
||||
void Initialize(const Aws::String& awsAccountId, const Aws::String& identityPoolId);
|
||||
bool HasIdentityId() const override;
|
||||
bool HasLogins() const override;
|
||||
Aws::String GetIdentityId() const override;
|
||||
Aws::Map<Aws::String, Aws::Auth::LoginAccessTokens> GetLogins() override;
|
||||
Aws::String GetAccountId() const override;
|
||||
Aws::String GetIdentityPoolId() const override;
|
||||
void PersistIdentityId(const Aws::String&) override;
|
||||
void PersistLogins(const Aws::Map<Aws::String, Aws::Auth::LoginAccessTokens>&) override;
|
||||
|
||||
void RemoveLogin(const Aws::String&);
|
||||
|
||||
private:
|
||||
Aws::Map<Aws::String, Aws::Auth::LoginAccessTokens> m_logins;
|
||||
Aws::String m_identityId;
|
||||
Aws::String m_awsAccountId;
|
||||
Aws::String m_identityPoolId;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Authorization/AWSCognitoAuthorizationBus.h>
|
||||
#include <Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.h>
|
||||
#include <Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h>
|
||||
#include <Authentication/AuthenticationProviderBus.h>
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
#include <aws/cognito-identity/CognitoIdentityClient.h>
|
||||
#include <aws/identity-management/auth/CognitoCachingCredentialsProvider.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Implements AWS Cognito Identity pool authorization.
|
||||
class AWSCognitoAuthorizationController
|
||||
: public AWSCognitoAuthorizationRequestBus::Handler
|
||||
, public AuthenticationProviderNotificationBus::Handler
|
||||
, public AWSCore::AWSCredentialRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSCognitoAuthorizationController, "{0E731ED1-2F08-4B3C-9282-D452700F58D1}", IAWSCognitoAuthorizationRequests);
|
||||
AWSCognitoAuthorizationController();
|
||||
virtual ~AWSCognitoAuthorizationController();
|
||||
|
||||
// AWSCognitoAuthorizationRequestsBus interface methods
|
||||
bool Initialize() override;
|
||||
void Reset() override;
|
||||
AZStd::string GetIdentityId() override;
|
||||
bool HasPersistedLogins() override;
|
||||
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetCognitoCredentialsProvider() override;
|
||||
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetAnonymousCognitoCredentialsProvider() override;
|
||||
void RequestAWSCredentialsAsync() override;
|
||||
|
||||
protected:
|
||||
// AuthenticationProviderNotificationsBus interface. Update persistent login tokens on successful sign in.
|
||||
void OnPasswordGrantSingleFactorSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
|
||||
void OnPasswordGrantMultiFactorConfirmSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
|
||||
void OnDeviceCodeGrantConfirmSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
|
||||
void OnRefreshTokensSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
|
||||
void OnSignOut(const ProviderNameEnum& provideName) override;
|
||||
|
||||
// AWSCredentialRequestBus interface implementation
|
||||
int GetCredentialHandlerOrder() const override;
|
||||
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetCredentialsProvider() override;
|
||||
|
||||
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentCognitoIdentityProvider;
|
||||
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentAnonymousCognitoIdentityProvider;
|
||||
std::shared_ptr<AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider> m_cognitoCachingCredentialsProvider;
|
||||
std::shared_ptr<AWSClientAuthCachingAnonymousCredsProvider> m_cognitoCachingAnonymousCredentialsProvider;
|
||||
|
||||
AZStd::string m_cognitoIdentityPoolId;
|
||||
AZStd::string m_formattedCognitoUserPoolId;
|
||||
AZStd::string m_awsAccountId;
|
||||
|
||||
private:
|
||||
void PersistLoginsAndRefreshAWSCredentials(const AuthenticationTokens& authenticationTokens);
|
||||
|
||||
AZStd::string GetAuthenticationProviderId(const ProviderNameEnum& providerName);
|
||||
AZStd::mutex m_persistentCognitoIdentityProviderMutex;
|
||||
AZStd::mutex m_persistentAnonymousCognitoIdentityProviderMutex;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Authorization/AWSCognitoAuthorizationBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Authorization behavior EBus handler
|
||||
class AWSCognitoAuthorizationNotificationBusBehaviorHandler
|
||||
: public AWSCognitoAuthorizationNotificationBus::Handler
|
||||
, public AZ::BehaviorEBusHandler
|
||||
{
|
||||
public:
|
||||
AZ_EBUS_BEHAVIOR_BINDER(AWSCognitoAuthorizationNotificationBusBehaviorHandler, "{F2BCAB42-97FD-41AC-AF7A-7E3BD64B7089}", AZ::SystemAllocator,
|
||||
OnRequestAWSCredentialsSuccess, OnRequestAWSCredentialsFail
|
||||
);
|
||||
|
||||
void OnRequestAWSCredentialsSuccess(const ClientAuthAWSCredentials& awsCredentials) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([awsCredentials, this]()
|
||||
{
|
||||
Call(FN_OnRequestAWSCredentialsSuccess, awsCredentials);
|
||||
});
|
||||
}
|
||||
|
||||
void OnRequestAWSCredentialsFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]()
|
||||
{
|
||||
Call(FN_OnRequestAWSCredentialsFail, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <UserManagement/AWSCognitoUserManagementBus.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Implements AWS Cognito User pool user management.
|
||||
class AWSCognitoUserManagementController
|
||||
: public AWSCognitoUserManagementRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSCognitoUserManagementController, "{2645D1CC-EB55-4A8D-8F45-5DFE94032813}", IAWSCognitoUserManagementRequests);
|
||||
AWSCognitoUserManagementController();
|
||||
virtual ~AWSCognitoUserManagementController();
|
||||
|
||||
// AWSCognitoUserManagementRequestsBus interface methods
|
||||
bool Initialize() override;
|
||||
void EmailSignUpAsync(const AZStd::string& username, const AZStd::string& password, const AZStd::string& email) override;
|
||||
void PhoneSignUpAsync(const AZStd::string& username, const AZStd::string& password, const AZStd::string& phoneNumber) override;
|
||||
void ConfirmSignUpAsync(const AZStd::string& username, const AZStd::string& confirmationCode) override;
|
||||
void ForgotPasswordAsync(const AZStd::string& username) override;
|
||||
void ConfirmForgotPasswordAsync(const AZStd::string& userName, const AZStd::string& confirmationCode, const AZStd::string& newPassword) override;
|
||||
void EnableMFAAsync(const AZStd::string& accessToken) override;
|
||||
|
||||
inline const AZStd::string& GetCognitoAppClientId() const
|
||||
{
|
||||
return m_cognitoAppClientId;
|
||||
}
|
||||
|
||||
private:
|
||||
AZStd::string m_cognitoAppClientId;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <UserManagement/AWSCognitoUserManagementBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! User management behavior EBus handler
|
||||
class UserManagementNotificationBusBehaviorHandler
|
||||
: public AWSCognitoUserManagementNotificationBus::Handler
|
||||
, public AZ::BehaviorEBusHandler
|
||||
{
|
||||
public:
|
||||
AZ_EBUS_BEHAVIOR_BINDER(UserManagementNotificationBusBehaviorHandler, "{57289595-2CDC-4834-8017-4A96B983E028}", AZ::SystemAllocator,
|
||||
OnEmailSignUpSuccess, OnEmailSignUpFail,
|
||||
OnPhoneSignUpSuccess, OnPhoneSignUpFail,
|
||||
OnConfirmSignUpSuccess, OnConfirmSignUpFail,
|
||||
OnForgotPasswordSuccess, OnForgotPasswordFail,
|
||||
OnConfirmForgotPasswordSuccess, OnConfirmForgotPasswordFail,
|
||||
OnEnableMFASuccess, OnEnableMFAFail
|
||||
);
|
||||
|
||||
void OnEmailSignUpSuccess(const AZStd::string& uuid) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([uuid, this]() {
|
||||
Call(FN_OnEmailSignUpSuccess, uuid);
|
||||
});
|
||||
}
|
||||
|
||||
void OnEmailSignUpFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnEmailSignUpFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPhoneSignUpSuccess(const AZStd::string& uuid) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([uuid, this]() {
|
||||
Call(FN_OnPhoneSignUpSuccess, uuid);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPhoneSignUpFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnPhoneSignUpFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnConfirmSignUpSuccess() override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this]() {
|
||||
Call(FN_OnConfirmSignUpSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
void OnConfirmSignUpFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnConfirmSignUpFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnForgotPasswordSuccess() override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this]() {
|
||||
Call(FN_OnForgotPasswordSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
void OnForgotPasswordFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnForgotPasswordFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnConfirmForgotPasswordSuccess() override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this]() {
|
||||
Call(FN_OnConfirmForgotPasswordSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
void OnConfirmForgotPasswordFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnConfirmForgotPasswordFail, error);
|
||||
});
|
||||
}
|
||||
|
||||
void OnEnableMFASuccess() override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([this]() {
|
||||
Call(FN_OnEnableMFASuccess);
|
||||
});
|
||||
}
|
||||
|
||||
void OnEnableMFAFail(const AZStd::string& error) override
|
||||
{
|
||||
AZ::TickBus::QueueFunction([error, this]() {
|
||||
Call(FN_OnEnableMFAFail, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
} // namespace AWSClientAuth
|
||||
Reference in New Issue
Block a user