Integrating latest from github/staging

Integrating up through commit 5e1bdae
This commit is contained in:
alexpete
2021-03-26 14:31:50 -07:00
parent 9c54341af8
commit 36c4e827bd
764 changed files with 11453 additions and 20251 deletions
@@ -0,0 +1,16 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
constexpr char CognitoUserPoolIdResourceMappingKey[] = "AWSClientAuth.CognitoUserPoolId";
constexpr char CognitoAppClientIdResourceMappingKey[] = "AWSClientAuth.CognitoUserPoolAppClientId";
constexpr char CognitoIdentityPoolIdResourceMappingKey[] = "AWSClientAuth.CognitoIdentityPoolId";
@@ -23,8 +23,8 @@ namespace AWSClientAuth
: public AuthenticationProviderInterface
{
public:
AWSCognitoAuthenticationProvider();
virtual ~AWSCognitoAuthenticationProvider();
AWSCognitoAuthenticationProvider() = default;
virtual ~AWSCognitoAuthenticationProvider() = default;
// AuthenticationProviderInterface overrides
bool Initialize(AZStd::weak_ptr<AZ::SettingsRegistryInterface> settingsRegistry) override;
@@ -41,8 +41,8 @@ namespace AWSClientAuth
void UpdateTokens(const Aws::CognitoIdentityProvider::Model::AuthenticationResultType& authenticationResult);
protected:
AZStd::unique_ptr<AWSCognitoProviderSetting> m_settings;
AZStd::string m_session;
AZStd::string m_cognitoAppClientId;
};
} // namespace AWSClientAuth
@@ -68,35 +68,4 @@ namespace AWSClientAuth
->Field("OAuthTokensURL", &GoogleProviderSetting::m_oAuthTokensURL);
}
};
//! Holds AWS Cognito provider serialized Settings.
class AWSCognitoProviderSetting
{
public:
AWSCognitoProviderSetting() = default;
~AWSCognitoProviderSetting() = default;
AZ_TYPE_INFO(AWSCognitoProviderSetting, "{46EF239C-D3CF-4B17-BA68-FD6B3B249305}");
AZStd::string m_appClientId;
static void Reflect(AZ::SerializeContext& context)
{
context.Class<AWSCognitoProviderSetting>()
->Field("AppClientId", &AWSCognitoProviderSetting::m_appClientId)
;
AZ::EditContext* editContext = context.GetEditContext();
if (editContext)
{
editContext->Class<AWSCognitoProviderSetting>("AWSCognitoProviderSetting", "AWSCognitoProviderSetting Settings")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "AWSClientAuth")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
->DataElement(AZ::Edit::UIHandlers::Default, &AWSCognitoProviderSetting::m_appClientId, "ClientId", "Cognito User Pool App Client Id");
}
}
};
} // namespace AWSClientAuth
@@ -14,27 +14,25 @@
namespace AWSClientAuth
{
constexpr char OAUTH_CLIENT_ID_BODY_KEY[] = "client_id";
constexpr char OAUTH_CLIENT_SECRET_BODY_KEY[] = "client_secret";
constexpr char OAUTH_DEVICE_CODE_BODY_KEY[] = "device_code";
constexpr char OAUTH_SCOPE_BODY_KEY[] = "scope";
constexpr char OAUTH_SCOPE_BODY_VALUE[] = "profile";
constexpr char OAUTH_GRANT_TYPE_BODY_KEY[] = "grant_type";
constexpr char OAUTH_REFRESH_TOKEN_BODY_KEY[] = "refresh_token";
constexpr char OAUTH_REFRESH_TOKEN_BODY_VALUE[] = "refresh_token";
constexpr char OAUTH_RESPONSE_TYPE_BODY_KEY[] = "response_type";
constexpr char OAUTH_CONTENT_TYPE_HEADER_KEY[] = "Content-Type";
constexpr char OAUTH_CONTENT_TYPE_HEADER_VALUE[] = "application/x-www-form-urlencoded";
constexpr char OAUTH_CONTENT_LENGTH_HEADER_KEY[] = "Content-Length";
constexpr char OAUTH_USER_CODE_RESPONSE_KEY[] = "user_code";
constexpr char OAUTH_ID_TOKEN_RESPONSE_KEY[] = "id_token";
constexpr char OAUTH_ACCESS_TOKEN_RESPONSE_KEY[] = "access_token";
constexpr char OAUTH_REFRESH_TOKEN_RESPONSE_KEY[] = "refresh_token";
constexpr char OAUTH_EXPIRES_IN_RESPONSE_KEY[] = "expires_in";
constexpr char OAUTH_ERROR_RESPONSE_KEY[] = "error";
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
@@ -12,7 +12,6 @@
#pragma once
#include <Authorization/AWSCognitoAuthorizationTypes.h>
#include <aws/identity-management/auth/PersistentCognitoIdentityProvider.h>
namespace AWSClientAuth
@@ -13,7 +13,6 @@
#pragma once
#include <Authorization/AWSCognitoAuthorizationBus.h>
#include <Authorization/AWSCognitoAuthorizationTypes.h>
#include <Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h>
#include <Authentication/AuthenticationProviderBus.h>
#include <Credential/AWSCredentialBus.h>
@@ -34,7 +33,7 @@ namespace AWSClientAuth
virtual ~AWSCognitoAuthorizationController();
// AWSCognitoAuthorizationRequestsBus interface methods
bool Initialize(const AZStd::string& settingsRegistryPath) override;
bool Initialize() override;
void Reset() override;
AZStd::string GetIdentityId() override;
bool HasPersistedLogins() override;
@@ -54,12 +53,15 @@ namespace AWSClientAuth
int GetCredentialHandlerOrder() const override;
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetCredentialsProvider() override;
AZStd::unique_ptr<CognitoAuthorizationSettings> m_settings;
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentCognitoIdentityProvider;
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentAnonymousCognitoIdentityProvider;
std::shared_ptr<Aws::Auth::CognitoCachingAuthenticatedCredentialsProvider> m_cognitoCachingCredentialsProvider;
std::shared_ptr<Aws::Auth::CognitoCachingAnonymousCredentialsProvider> m_cognitoCachingAnonymousCredentialsProvider;
AZStd::string m_cognitoIdentityPoolId;
AZStd::string m_formattedCognitoUserPoolId;
AZStd::string m_awsAccountId;
private:
void PersistLoginsAndRefreshAWSCredentials(const AuthenticationTokens& authenticationTokens);
@@ -1,59 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Serialization/EditContext.h>
namespace AWSClientAuth
{
//! Holds Cognito Authorization Identity pool settings.
class CognitoAuthorizationSettings
{
public:
AZ_TYPE_INFO(CognitoAuthorizationSettings, "{2F2080CD-E575-42BD-9717-E42E43C13956}");
static void Reflect(AZ::SerializeContext& context)
{
context.Class<CognitoAuthorizationSettings>()
->Field("CognitoUserPoolId", &CognitoAuthorizationSettings::m_cognitoUserPoolId)
->Field("LoginWithAmazonId", &CognitoAuthorizationSettings::m_loginWithAmazonId)
->Field("GoogleId", &CognitoAuthorizationSettings::m_googleId)
->Field("AWSAccountId", &CognitoAuthorizationSettings::m_awsAccountId)
->Field("IdentityPoolId", &CognitoAuthorizationSettings::m_cognitoIdentityPoolId);
AZ::EditContext* editContext = context.GetEditContext();
if (editContext)
{
editContext->Class<CognitoAuthorizationSettings>("CognitoAuthorizationSettings", "CognitoAuthorizationSettings")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "AWSClientAuth")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
->DataElement(AZ::Edit::UIHandlers::Default, &CognitoAuthorizationSettings::m_cognitoUserPoolId, "CognitoUserPoolId", "Cognito User pool Id")
->DataElement(AZ::Edit::UIHandlers::Default, &CognitoAuthorizationSettings::m_loginWithAmazonId, "LoginWithAmazonId", "Login with Amazon id. default: www.amazon.com")
->DataElement(AZ::Edit::UIHandlers::Default, &CognitoAuthorizationSettings::m_googleId, "Google Endpoint", "Google endpoint. default: accounts.google.com")
->DataElement(AZ::Edit::UIHandlers::Default, &CognitoAuthorizationSettings::m_cognitoUserPoolId, "AWSAccountId", "AWS account Cognito for Cognito identity pool")
->DataElement(AZ::Edit::UIHandlers::Default, &CognitoAuthorizationSettings::m_cognitoUserPoolId, "IdentityPoolId", "Cognito Identity pool Id")
;
}
}
AZStd::string m_cognitoUserPoolId;
AZStd::string m_loginWithAmazonId = "www.amazon.com";
AZStd::string m_googleId = "accounts.google.com";
AZStd::string m_awsAccountId;
AZStd::string m_cognitoIdentityPoolId;
};
} // namespace AWSClientAuth
@@ -13,7 +13,6 @@
#pragma once
#include <UserManagement/AWSCognitoUserManagementBus.h>
#include <UserManagement/AWSCognitoUserManagementTypes.h>
namespace AWSClientAuth
{
@@ -27,7 +26,7 @@ namespace AWSClientAuth
virtual ~AWSCognitoUserManagementController();
// AWSCognitoUserManagementRequestsBus interface methods
bool Initialize(const AZStd::string& settingsRegistryPath);
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;
@@ -35,8 +34,13 @@ namespace AWSClientAuth
void ConfirmForgotPasswordAsync(const AZStd::string& userName, const AZStd::string& confirmationCode, const AZStd::string& newPassword) override;
void EnableMFAAsync(const AZStd::string& accessToken) override;
protected:
AZStd::unique_ptr<AWSCognitoUserManagementSetting> m_settings;
inline const AZStd::string& GetCognitoAppClientId() const
{
return m_cognitoAppClientId;
}
private:
AZStd::string m_cognitoAppClientId;
};
} // namespace AWSClientAuth
@@ -1,50 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Serialization/EditContext.h>
namespace AWSClientAuth
{
//! Holds AWS Cognito user management serialized Settings.
class AWSCognitoUserManagementSetting
{
public:
AWSCognitoUserManagementSetting() = default;
~AWSCognitoUserManagementSetting() = default;
AZ_TYPE_INFO(AWSCognitoUserManagementSetting, "{58FC34F1-B84B-4677-B986-45A226F0328D}");
AZStd::string m_appClientId;
static void Reflect(AZ::SerializeContext& context)
{
context.Class<AWSCognitoUserManagementSetting>()
->Field("AppClientId", &AWSCognitoUserManagementSetting::m_appClientId)
;
AZ::EditContext* editContext = context.GetEditContext();
if (editContext)
{
editContext->Class<AWSCognitoUserManagementSetting>("AWSCognitoUserManagementSetting", "AWSCognitoUserManagementSetting Settings")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "AWSClientAuth")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
->DataElement(AZ::Edit::UIHandlers::Default, &AWSCognitoUserManagementSetting::m_appClientId, "ClientId", "Cognito User Pool App Client Id")
;
}
}
};
} // namespace AWSClientAuth
@@ -27,7 +27,7 @@ namespace AWSClientAuth
//! Initializes settings for Cognito identity pool from settings registry.
//! @param settingsRegistryPath Path for the settings registry file to use.
virtual bool Initialize(const AZStd::string& settingsRegistryPath) = 0;
virtual bool Initialize() = 0;
//! Once credentials provider are set they cannot be reset. So recreates new Cognito credentials provider on reset.
//! Service clients need to be created with the new AWSCredentialsProvider after reset.
@@ -24,7 +24,7 @@ namespace AWSClientAuth
//! Initialize Cognito User pool.
//! @param settingsRegistryPath settingsRegistryPath Path for the settings registry file to use.
virtual bool Initialize(const AZStd::string& settingsRegistryPath) = 0;
virtual bool Initialize() = 0;
// Requests interface
//! Cognito user pool email sign up start.
@@ -16,7 +16,6 @@
#include <UserManagement/UserManagementNotificationBusBehaviorHandler.h>
#include <Authorization/AWSCognitoAuthorizationNotificationBusBehaviorHandler.h>
#include <Authorization/AWSCognitoAuthorizationController.h>
#include <Authorization/AWSCognitoAuthorizationTypes.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
@@ -25,7 +24,7 @@
namespace AWSClientAuth
{
constexpr char SERIALIZE_COMPONENT_NAME[] = "AWSClientAuth";
constexpr char SerializeComponentName[] = "AWSClientAuth";
void AWSClientAuthSystemComponent::Reflect(AZ::ReflectContext* context)
{
@@ -41,17 +40,14 @@ namespace AWSClientAuth
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
}
AWSClientAuth::AWSCognitoProviderSetting::Reflect(*serialize);
AWSClientAuth::LWAProviderSetting::Reflect(*serialize);
AWSClientAuth::GoogleProviderSetting::Reflect(*serialize);
AWSClientAuth::CognitoAuthorizationSettings::Reflect(*serialize);
AWSClientAuth::AWSCognitoUserManagementSetting::Reflect(*serialize);
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<AuthenticationProviderRequestBus>("AuthenticationProviderRequestBus")
->Attribute(AZ::Script::Attributes::Category, SERIALIZE_COMPONENT_NAME)
->Attribute(AZ::Script::Attributes::Category, SerializeComponentName)
->Event("Initialize", &AuthenticationProviderRequestBus::Events::Initialize)
->Event("IsSignedIn", &AuthenticationProviderRequestBus::Events::IsSignedIn)
->Event("GetAuthenticationTokens", &AuthenticationProviderRequestBus::Events::GetAuthenticationTokens)
@@ -64,7 +60,7 @@ namespace AWSClientAuth
->Event("SignOut", &AuthenticationProviderRequestBus::Events::SignOut);
behaviorContext->EBus<AWSCognitoAuthorizationRequestBus>("AWSCognitoAuthorizationRequestBus")
->Attribute(AZ::Script::Attributes::Category, SERIALIZE_COMPONENT_NAME)
->Attribute(AZ::Script::Attributes::Category, SerializeComponentName)
->Event("Initialize", &AWSCognitoAuthorizationRequestBus::Events::Initialize)
->Event("Reset", &AWSCognitoAuthorizationRequestBus::Events::Reset)
->Event("GetIdentityId", &AWSCognitoAuthorizationRequestBus::Events::GetIdentityId)
@@ -72,7 +68,7 @@ namespace AWSClientAuth
->Event("RequestAWSCredentialsAsync", &AWSCognitoAuthorizationRequestBus::Events::RequestAWSCredentialsAsync);
behaviorContext->EBus<AWSCognitoUserManagementRequestBus>("AWSCognitoUserManagementRequestBus")
->Attribute(AZ::Script::Attributes::Category, SERIALIZE_COMPONENT_NAME)
->Attribute(AZ::Script::Attributes::Category, SerializeComponentName)
->Event("Initialize", &AWSCognitoUserManagementRequestBus::Events::Initialize)
->Event("EmailSignUpAsync", &AWSCognitoUserManagementRequestBus::Events::EmailSignUpAsync)
->Event("PhoneSignUpAsync", &AWSCognitoUserManagementRequestBus::Events::PhoneSignUpAsync)
@@ -18,6 +18,8 @@
#include <Authentication/AuthenticationProviderBus.h>
#include <AWSClientAuthBus.h>
#include <AWSCoreBus.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <AWSClientAuthResourceMappingConstants.h>
#include <aws/cognito-idp/model/InitiateAuthRequest.h>
#include <aws/cognito-idp/model/InitiateAuthResult.h>
@@ -28,31 +30,18 @@
namespace AWSClientAuth
{
constexpr char COGNITO_IDP_SETTINGS_PATH[] = "/AWS/CognitoIDP";
constexpr char COGNITO_USERNAME_KEY[] = "USERNAME";
constexpr char COGNITO_PASSWORD_KEY[] = "PASSWORD";
constexpr char COGNITO_REFRESH_TOKEN_AUTHPARAM_KEY[] = "REFRESH_TOKEN";
constexpr char COGNITO_SMS_MFA_CODE_KEY[] = "SMS_MFA_CODE";
AWSCognitoAuthenticationProvider::AWSCognitoAuthenticationProvider()
{
m_settings = AZStd::make_unique<AWSCognitoProviderSetting>();
}
AWSCognitoAuthenticationProvider::~AWSCognitoAuthenticationProvider()
{
m_settings.reset();
}
constexpr char CognitoUsernameKey[] = "USERNAME";
constexpr char CognitoPasswordKey[] = "PASSWORD";
constexpr char CognitoRefreshTokenAuthParamKey[] = "REFRESH_TOKEN";
constexpr char CognitoSmsMfaCodeKey[] = "SMS_MFA_CODE";
bool AWSCognitoAuthenticationProvider::Initialize(AZStd::weak_ptr<AZ::SettingsRegistryInterface> settingsRegistry)
{
if (!settingsRegistry.lock()->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), COGNITO_IDP_SETTINGS_PATH))
{
AZ_Warning("AWSCognitoAuthenticationProvider", true, "Failed to get settings object for path %s", COGNITO_IDP_SETTINGS_PATH);
return false;
}
return true;
AZ_UNUSED(settingsRegistry);
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
m_cognitoAppClientId, &AWSCore::AWSResourceMappingRequests::GetResourceNameId, CognitoAppClientIdResourceMappingKey);
AZ_Warning("AWSCognitoAuthenticationProvider", m_cognitoAppClientId.empty(), "Missing Cognito App Client Id from resource mappings. Calls to Cognito will fail.");
return !m_cognitoAppClientId.empty();
}
@@ -128,9 +117,9 @@ namespace AWSClientAuth
// Set Request parameters for SMS Multi factor authentication.
// Note: Email MFA is no longer supported by Cognito, use SMS as MFA
Aws::CognitoIdentityProvider::Model::RespondToAuthChallengeRequest respondToAuthChallengeRequest;
respondToAuthChallengeRequest.SetClientId(m_settings->m_appClientId.c_str());
respondToAuthChallengeRequest.AddChallengeResponses(COGNITO_SMS_MFA_CODE_KEY, confirmationCode.c_str());
respondToAuthChallengeRequest.AddChallengeResponses(COGNITO_USERNAME_KEY, username.c_str());
respondToAuthChallengeRequest.SetClientId(m_cognitoAppClientId.c_str());
respondToAuthChallengeRequest.AddChallengeResponses(CognitoSmsMfaCodeKey, confirmationCode.c_str());
respondToAuthChallengeRequest.AddChallengeResponses(CognitoUsernameKey, username.c_str());
respondToAuthChallengeRequest.SetChallengeName(Aws::CognitoIdentityProvider::Model::ChallengeNameType::SMS_MFA);
respondToAuthChallengeRequest.SetSession(m_session.c_str());
@@ -177,13 +166,13 @@ namespace AWSClientAuth
{
// Set Request parameters.
Aws::CognitoIdentityProvider::Model::InitiateAuthRequest initiateAuthRequest;
initiateAuthRequest.SetClientId(m_settings->m_appClientId.c_str());
initiateAuthRequest.SetClientId(m_cognitoAppClientId.c_str());
initiateAuthRequest.SetAuthFlow(Aws::CognitoIdentityProvider::Model::AuthFlowType::REFRESH_TOKEN_AUTH);
// Set username and password for Password grant/ Initiate Auth flow.
Aws::Map<Aws::String, Aws::String> authParameters
{
{COGNITO_REFRESH_TOKEN_AUTHPARAM_KEY, GetAuthenticationTokens().GetRefreshToken().c_str()}
{CognitoRefreshTokenAuthParamKey, GetAuthenticationTokens().GetRefreshToken().c_str()}
};
initiateAuthRequest.SetAuthParameters(authParameters);
@@ -228,14 +217,14 @@ namespace AWSClientAuth
{
// Set Request parameters.
Aws::CognitoIdentityProvider::Model::InitiateAuthRequest initiateAuthRequest;
initiateAuthRequest.SetClientId(m_settings->m_appClientId.c_str());
initiateAuthRequest.SetClientId(m_cognitoAppClientId.c_str());
initiateAuthRequest.SetAuthFlow(Aws::CognitoIdentityProvider::Model::AuthFlowType::USER_PASSWORD_AUTH);
// Set username and password for Password grant/ Initiate Auth flow.
Aws::Map<Aws::String, Aws::String> authParameters
{
{COGNITO_USERNAME_KEY, username.c_str()},
{COGNITO_PASSWORD_KEY, password.c_str()}
{CognitoUsernameKey, username.c_str()},
{CognitoPasswordKey, password.c_str()}
};
initiateAuthRequest.SetAuthParameters(authParameters);
@@ -22,8 +22,8 @@
namespace AWSClientAuth
{
constexpr char GOOGLE_SETTINGS_PATH[] = "/AWS/Google";
constexpr char GOOGLE_VERIFICATION_URL_RESPONSE_KEY[] = "verification_url";
constexpr char GoogleSettingsPath[] = "/AWS/Google";
constexpr char GoogleVerificationUrlResponseKey[] = "verification_url";
GoogleAuthenticationProvider::GoogleAuthenticationProvider()
{
@@ -37,9 +37,9 @@ namespace AWSClientAuth
bool GoogleAuthenticationProvider::Initialize(AZStd::weak_ptr<AZ::SettingsRegistryInterface> settingsRegistry)
{
if (!settingsRegistry.lock()->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), GOOGLE_SETTINGS_PATH))
if (!settingsRegistry.lock()->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), GoogleSettingsPath))
{
AZ_Warning("AWSCognitoAuthenticationProvider", true, "Failed to get Google settings object for path %s", GOOGLE_SETTINGS_PATH);
AZ_Warning("AWSCognitoAuthenticationProvider", true, "Failed to get Google settings object for path %s", GoogleSettingsPath);
return false;
}
return true;
@@ -70,13 +70,13 @@ namespace AWSClientAuth
// Refer https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes.
void GoogleAuthenticationProvider::DeviceCodeGrantSignInAsync()
{
AZStd::string body = AZStd::string::format("%s=%s&%s=%s", OAUTH_CLIENT_ID_BODY_KEY, m_settings->m_appClientId.c_str()
, OAUTH_SCOPE_BODY_KEY, OAUTH_SCOPE_BODY_VALUE);
AZStd::string body = AZStd::string::format("%s=%s&%s=%s", OAuthClientIdBodyKey, m_settings->m_appClientId.c_str()
, OAuthScopeBodyKey, OAuthScopeBodyValue);
// Set headers and body for device sign in http requests.
AZStd::map<AZStd::string, AZStd::string> headers;
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthCodeURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -84,15 +84,15 @@ namespace AWSClientAuth
{
if (responseCode == Aws::Http::HttpResponseCode::OK)
{
m_cachedDeviceCode = jsonView.GetString(OAUTH_DEVICE_CODE_BODY_KEY).c_str();
m_cachedDeviceCode = jsonView.GetString(OAuthDeviceCodeBodyKey).c_str();
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnDeviceCodeGrantSignInSuccess
, jsonView.GetString(OAUTH_USER_CODE_RESPONSE_KEY).c_str(), jsonView.GetString(GOOGLE_VERIFICATION_URL_RESPONSE_KEY).c_str()
, jsonView.GetInteger(OAUTH_EXPIRES_IN_RESPONSE_KEY));
, jsonView.GetString(OAuthUserCodeResponseKey).c_str(), jsonView.GetString(GoogleVerificationUrlResponseKey).c_str()
, jsonView.GetInteger(OAuthExpiresInResponseKey));
}
else
{
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnDeviceCodeGrantSignInFail
, jsonView.GetString(OAUTH_ERROR_RESPONSE_KEY).c_str());
, jsonView.GetString(OAuthErrorResponseKey).c_str());
}
}
);
@@ -105,12 +105,12 @@ namespace AWSClientAuth
{
// Set headers and body for device confirm sign in http requests.
AZStd::map<AZStd::string, AZStd::string> headers;
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s&%s=%s", OAUTH_CLIENT_ID_BODY_KEY, m_settings->m_appClientId.c_str()
, OAUTH_CLIENT_SECRET_BODY_KEY, m_settings->m_clientSecret.c_str(), OAUTH_DEVICE_CODE_BODY_KEY, m_cachedDeviceCode.c_str()
, OAUTH_GRANT_TYPE_BODY_KEY, m_settings->m_grantType.c_str());
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s&%s=%s", OAuthClientIdBodyKey, m_settings->m_appClientId.c_str()
, OAuthClientSecretBodyKey, m_settings->m_clientSecret.c_str(), OAuthDeviceCodeBodyKey, m_cachedDeviceCode.c_str()
, OAuthGrantTypeBodyKey, m_settings->m_grantType.c_str());
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthTokensURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -125,7 +125,7 @@ namespace AWSClientAuth
else
{
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnDeviceCodeGrantConfirmSignInFail
, jsonView.GetString(OAUTH_ERROR_RESPONSE_KEY).c_str());
, jsonView.GetString(OAuthErrorResponseKey).c_str());
}
}
);
@@ -136,12 +136,12 @@ namespace AWSClientAuth
void GoogleAuthenticationProvider::RefreshTokensAsync()
{
AZStd::map<AZStd::string, AZStd::string> headers;
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s&%s=%s", OAUTH_CLIENT_ID_BODY_KEY, m_settings->m_appClientId.c_str()
, OAUTH_CLIENT_SECRET_BODY_KEY, m_settings->m_clientSecret.c_str()
, OAUTH_GRANT_TYPE_BODY_KEY, OAUTH_REFRESH_TOKEN_BODY_VALUE, OAUTH_REFRESH_TOKEN_BODY_KEY, m_authenticationTokens.GetRefreshToken().c_str());
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s&%s=%s", OAuthClientIdBodyKey, m_settings->m_appClientId.c_str()
, OAuthClientSecretBodyKey, m_settings->m_clientSecret.c_str()
, OAuthGrantTypeBodyKey, OAuthRefreshTokenBodyValue, OAuthRefreshTokenBodyKey, m_authenticationTokens.GetRefreshToken().c_str());
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthTokensURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -156,7 +156,7 @@ namespace AWSClientAuth
else
{
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnRefreshTokensFail
, jsonView.GetString(OAUTH_ERROR_RESPONSE_KEY).c_str());
, jsonView.GetString(OAuthErrorResponseKey).c_str());
}
}
);
@@ -164,9 +164,9 @@ namespace AWSClientAuth
void GoogleAuthenticationProvider::UpdateTokens(const Aws::Utils::Json::JsonView& jsonView)
{
m_authenticationTokens = AuthenticationTokens(jsonView.GetString(OAUTH_ACCESS_TOKEN_RESPONSE_KEY).c_str(),
jsonView.GetString(OAUTH_REFRESH_TOKEN_RESPONSE_KEY).c_str() ,jsonView.GetString(OAUTH_ID_TOKEN_RESPONSE_KEY).c_str(), ProviderNameEnum::Google
, jsonView.GetInteger(OAUTH_EXPIRES_IN_RESPONSE_KEY));
m_authenticationTokens = AuthenticationTokens(jsonView.GetString(OAuthAccessTokenResponseKey).c_str(),
jsonView.GetString(OAuthRefreshTokenResponseKey).c_str() ,jsonView.GetString(OAuthIdTokenResponseKey).c_str(), ProviderNameEnum::Google
, jsonView.GetInteger(OAuthExpiresInResponseKey));
}
} // namespace AWSClientAuth
@@ -21,8 +21,8 @@
namespace AWSClientAuth
{
constexpr char LWA_SETTINGS_PATH[] = "/AWS/LoginWithAmazon";
constexpr char LWA_VERIFICATION_URL_RESPONSE_KEY[] = "verification_uri";
constexpr char LwaSettingsPath[] = "/AWS/LoginWithAmazon";
constexpr char LwaVerificationUrlResponseKey[] = "verification_uri";
LWAAuthenticationProvider::LWAAuthenticationProvider()
{
@@ -36,9 +36,9 @@ namespace AWSClientAuth
bool LWAAuthenticationProvider::Initialize(AZStd::weak_ptr<AZ::SettingsRegistryInterface> settingsRegistry)
{
if (!settingsRegistry.lock()->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), LWA_SETTINGS_PATH))
if (!settingsRegistry.lock()->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), LwaSettingsPath))
{
AZ_Warning("AWSCognitoAuthenticationProvider", true, "Failed to get login with Amazon settings object for path %s", LWA_SETTINGS_PATH);
AZ_Warning("AWSCognitoAuthenticationProvider", true, "Failed to get login with Amazon settings object for path %s", LwaSettingsPath);
return false;
}
return true;
@@ -70,12 +70,12 @@ namespace AWSClientAuth
void LWAAuthenticationProvider::DeviceCodeGrantSignInAsync()
{
// Set headers and body for device sign in http requests.
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAUTH_RESPONSE_TYPE_BODY_KEY, m_settings->m_responseType.c_str()
, OAUTH_CLIENT_ID_BODY_KEY, m_settings->m_appClientId.c_str(), OAUTH_SCOPE_BODY_KEY, OAUTH_SCOPE_BODY_VALUE);
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAuthResponseTypeBodyKey, m_settings->m_responseType.c_str()
, OAuthClientIdBodyKey, m_settings->m_appClientId.c_str(), OAuthScopeBodyKey, OAuthScopeBodyValue);
AZStd::map<AZStd::string, AZStd::string> headers;
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthCodeURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -83,17 +83,17 @@ namespace AWSClientAuth
{
if (responseCode == Aws::Http::HttpResponseCode::OK)
{
m_cachedUserCode = jsonView.GetString(OAUTH_USER_CODE_RESPONSE_KEY).c_str();
m_cachedDeviceCode = jsonView.GetString(OAUTH_DEVICE_CODE_BODY_KEY).c_str();
m_cachedUserCode = jsonView.GetString(OAuthUserCodeResponseKey).c_str();
m_cachedDeviceCode = jsonView.GetString(OAuthDeviceCodeBodyKey).c_str();
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnDeviceCodeGrantSignInSuccess
, jsonView.GetString(OAUTH_USER_CODE_RESPONSE_KEY).c_str()
, jsonView.GetString(LWA_VERIFICATION_URL_RESPONSE_KEY).c_str()
, jsonView.GetInteger(OAUTH_EXPIRES_IN_RESPONSE_KEY));
, jsonView.GetString(OAuthUserCodeResponseKey).c_str()
, jsonView.GetString(LwaVerificationUrlResponseKey).c_str()
, jsonView.GetInteger(OAuthExpiresInResponseKey));
}
else
{
AuthenticationProviderNotificationBus::Broadcast(&AuthenticationProviderNotifications::OnDeviceCodeGrantSignInFail
, jsonView.GetString(OAUTH_ERROR_RESPONSE_KEY).c_str());
, jsonView.GetString(OAuthErrorResponseKey).c_str());
}
}
);
@@ -104,12 +104,12 @@ namespace AWSClientAuth
void LWAAuthenticationProvider::DeviceCodeGrantConfirmSignInAsync()
{
// Set headers and body for device confirm sign in http requests.
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAUTH_USER_CODE_RESPONSE_KEY, m_cachedUserCode.c_str()
, OAUTH_GRANT_TYPE_BODY_KEY, m_settings->m_grantType.c_str(), OAUTH_DEVICE_CODE_BODY_KEY, m_cachedDeviceCode.c_str());
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAuthUserCodeResponseKey, m_cachedUserCode.c_str()
, OAuthGrantTypeBodyKey, m_settings->m_grantType.c_str(), OAuthDeviceCodeBodyKey, m_cachedDeviceCode.c_str());
AZStd::map<AZStd::string, AZStd::string> headers;
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthTokensURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -136,12 +136,12 @@ namespace AWSClientAuth
void LWAAuthenticationProvider::RefreshTokensAsync()
{
// Set headers and body for device confirm sign in http requests.
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAUTH_CLIENT_ID_BODY_KEY, m_settings->m_appClientId.c_str(), OAUTH_GRANT_TYPE_BODY_KEY,
OAUTH_REFRESH_TOKEN_BODY_VALUE, OAUTH_REFRESH_TOKEN_BODY_KEY, m_authenticationTokens.GetRefreshToken().c_str());
AZStd::string body = AZStd::string::format("%s=%s&%s=%s&%s=%s", OAuthClientIdBodyKey, m_settings->m_appClientId.c_str(), OAuthGrantTypeBodyKey,
OAuthRefreshTokenBodyValue, OAuthRefreshTokenBodyKey, m_authenticationTokens.GetRefreshToken().c_str());
AZStd::map<AZStd::string, AZStd::string> headers;
headers[OAUTH_CONTENT_TYPE_HEADER_KEY] = OAUTH_CONTENT_TYPE_HEADER_VALUE;
headers[OAUTH_CONTENT_LENGTH_HEADER_KEY] = AZStd::to_string(body.length());
headers[OAuthContentTypeHeaderKey] = OAuthContentTypeHeaderValue;
headers[OAuthContentLengthHeaderKey] = AZStd::to_string(body.length());
HttpRequestor::HttpRequestorRequestBus::Broadcast(&HttpRequestor::HttpRequestorRequests::AddRequestWithHeadersAndBody, m_settings->m_oAuthTokensURL
, Aws::Http::HttpMethod::HTTP_POST, headers, body
@@ -165,9 +165,9 @@ namespace AWSClientAuth
void LWAAuthenticationProvider::UpdateTokens(const Aws::Utils::Json::JsonView& jsonView)
{
// For Login with Amazon openId and access tokens are the same.
m_authenticationTokens = AuthenticationTokens(jsonView.GetString(OAUTH_ACCESS_TOKEN_RESPONSE_KEY).c_str(), jsonView.GetString(OAUTH_REFRESH_TOKEN_RESPONSE_KEY).c_str(),
jsonView.GetString(OAUTH_ACCESS_TOKEN_RESPONSE_KEY).c_str(), ProviderNameEnum::LoginWithAmazon
, jsonView.GetInteger(OAUTH_EXPIRES_IN_RESPONSE_KEY));
m_authenticationTokens = AuthenticationTokens(jsonView.GetString(OAuthAccessTokenResponseKey).c_str(), jsonView.GetString(OAuthRefreshTokenResponseKey).c_str(),
jsonView.GetString(OAuthAccessTokenResponseKey).c_str(), ProviderNameEnum::LoginWithAmazon
, jsonView.GetInteger(OAuthExpiresInResponseKey));
}
} // namespace AWSClientAuth
@@ -13,6 +13,9 @@
#include <AWSClientAuthBus.h>
#include <AWSCoreBus.h>
#include <Authorization/AWSCognitoAuthorizationController.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <AWSClientAuthResourceMappingConstants.h>
#include <AzCore/EBus/Internal/BusContainer.h>
#include <AzCore/Jobs/JobFunction.h>
#include <AzCore/Interface/Interface.h>
@@ -22,7 +25,9 @@
namespace AWSClientAuth
{
constexpr char COGNITO_AUTHORIZATION_SETTINGS_PATH[] = "/AWS/CognitoIdentityPool";
constexpr char CognitoAmazonLoginsId[] = "www.amazon.com";
constexpr char CognitoGoogleLoginsId[] = "accounts.google.com";
constexpr char CognitoUserPoolIdFormat[] = "cognito-idp.%s.amazonaws.com/%s";
AWSCognitoAuthorizationController::AWSCognitoAuthorizationController()
{
@@ -31,8 +36,6 @@ namespace AWSClientAuth
AuthenticationProviderNotificationBus::Handler::BusConnect();
AWSCore::AWSCredentialRequestBus::Handler::BusConnect();
m_settings = AZStd::make_unique<CognitoAuthorizationSettings>();
m_persistentCognitoIdentityProvider = std::make_shared<AWSClientAuthPersistentCognitoIdentityProvider>();
m_persistentAnonymousCognitoIdentityProvider = std::make_shared<AWSClientAuthPersistentCognitoIdentityProvider>();
@@ -52,32 +55,39 @@ namespace AWSClientAuth
m_persistentCognitoIdentityProvider.reset();
m_persistentAnonymousCognitoIdentityProvider.reset();
m_settings.reset();
AWSCore::AWSCredentialRequestBus::Handler::BusDisconnect();
AuthenticationProviderNotificationBus::Handler::BusDisconnect();
AWSCognitoAuthorizationRequestBus::Handler::BusDisconnect();
AZ::Interface<IAWSCognitoAuthorizationRequests>::Unregister(this);
}
bool AWSCognitoAuthorizationController::Initialize(const AZStd::string& settingsRegistryPath)
bool AWSCognitoAuthorizationController::Initialize()
{
AZStd::unique_ptr<AZ::SettingsRegistryInterface> settingsRegistry = AZStd::make_unique<AZ::SettingsRegistryImpl>();
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
m_awsAccountId, &AWSCore::AWSResourceMappingRequests::GetDefaultAccountId);
if (!settingsRegistry->MergeSettingsFile(settingsRegistryPath, AZ::SettingsRegistryInterface::Format::JsonMergePatch))
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
m_cognitoIdentityPoolId, &AWSCore::AWSResourceMappingRequests::GetResourceNameId, CognitoIdentityPoolIdResourceMappingKey);
if (m_awsAccountId.empty() || m_cognitoIdentityPoolId.empty())
{
AZ_Error("AWSCognitoAuthorizationController", true, "Failed to merge settings file for path %s", settingsRegistryPath.c_str());
AZ_Warning("AWSCognitoUserManagementController", m_awsAccountId.empty(), "Missing AWS account id in resource mappings.");
AZ_Warning("AWSCognitoUserManagementController", m_cognitoIdentityPoolId.empty(), "Missing Cognito Identity pool id in resource mappings.");
return false;
}
if (!settingsRegistry->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), COGNITO_AUTHORIZATION_SETTINGS_PATH))
{
AZ_Error("AWSCognitoAuthorizationController", true, "Failed to get settings object for path %s", COGNITO_AUTHORIZATION_SETTINGS_PATH);
return false;
}
AZStd::string userPoolId;
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
userPoolId, &AWSCore::AWSResourceMappingRequests::GetResourceNameId, CognitoUserPoolIdResourceMappingKey);
AZ_Warning("AWSCognitoUserManagementController", userPoolId.empty(), "Missing Cognito USer pool id in resource mappings. Cognito IDP authenticated identities will no work.");
m_persistentCognitoIdentityProvider->Initialize(m_settings->m_awsAccountId.c_str(), m_settings->m_cognitoIdentityPoolId.c_str());
m_persistentAnonymousCognitoIdentityProvider->Initialize(m_settings->m_awsAccountId.c_str(), m_settings->m_cognitoIdentityPoolId.c_str());
AZStd::string defaultRegion;
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
defaultRegion, &AWSCore::AWSResourceMappingRequests::GetDefaultRegion);
m_formattedCognitoUserPoolId = AZStd::string::format(CognitoUserPoolIdFormat, defaultRegion.c_str(), userPoolId.c_str());
m_persistentCognitoIdentityProvider->Initialize(m_awsAccountId.c_str(), m_cognitoIdentityPoolId.c_str());
m_persistentAnonymousCognitoIdentityProvider->Initialize(m_awsAccountId.c_str(), m_cognitoIdentityPoolId.c_str());
return true;
}
@@ -182,15 +192,15 @@ namespace AWSClientAuth
{
case ProviderNameEnum::AWSCognitoIDP:
{
return m_settings->m_cognitoUserPoolId;
return m_formattedCognitoUserPoolId;
}
case ProviderNameEnum::LoginWithAmazon:
{
return m_settings->m_loginWithAmazonId;
return CognitoAmazonLoginsId;
}
case ProviderNameEnum::Google:
{
return m_settings->m_googleId;
return CognitoGoogleLoginsId;
}
default:
{
@@ -14,7 +14,9 @@
#include <UserManagement/AWSCognitoUserManagementController.h>
#include <AWSClientAuthBus.h>
#include <AWSClientAuthResourceMappingConstants.h>
#include <AWSCoreBus.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <aws/core/utils/Outcome.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
@@ -35,41 +37,25 @@
namespace AWSClientAuth
{
constexpr char COGNITO_USER_POOL[] = "/AWS/CognitoUserPool";
AWSCognitoUserManagementController::AWSCognitoUserManagementController()
{
AZ::Interface<IAWSCognitoUserManagementRequests>::Register(this);
AWSCognitoUserManagementRequestBus::Handler::BusConnect();
m_settings = AZStd::make_unique<AWSCognitoUserManagementSetting>();
}
AWSCognitoUserManagementController::~AWSCognitoUserManagementController()
{
m_settings.reset();
AWSCognitoUserManagementRequestBus::Handler::BusDisconnect();
AZ::Interface<IAWSCognitoUserManagementRequests>::Unregister(this);
}
bool AWSCognitoUserManagementController::Initialize(const AZStd::string& settingsRegistryPath)
bool AWSCognitoUserManagementController::Initialize()
{
AZStd::unique_ptr<AZ::SettingsRegistryInterface> settingsRegistry = AZStd::make_unique<AZ::SettingsRegistryImpl>();
if (!settingsRegistry->MergeSettingsFile(settingsRegistryPath, AZ::SettingsRegistryInterface::Format::JsonMergePatch))
{
AZ_Error("AWSCognitoUserManagementController", true, "Failed to merge settings file for path %s", settingsRegistryPath.c_str());
return false;
}
if (!settingsRegistry->GetObject(m_settings.get(), azrtti_typeid(m_settings.get()), COGNITO_USER_POOL))
{
AZ_Error("AWSCognitoUserManagementController", true, "Failed to get settings object for path %s", COGNITO_USER_POOL);
return false;
}
return true;
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
m_cognitoAppClientId, &AWSCore::AWSResourceMappingRequests::GetResourceNameId, CognitoAppClientIdResourceMappingKey);
AZ_Warning(
"AWSCognitoUserManagementController", m_cognitoAppClientId.empty(), "Missing Cognito App Client Id from resource mappings. Calls to Cognito will fail.");
return !m_cognitoAppClientId.empty();
}
// Call Cognito user pool sign up using email. Confirmation code sent to the email set.
@@ -85,7 +71,7 @@ namespace AWSClientAuth
AZ::Job* emailSignUpJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, username, password, email]()
{
Aws::CognitoIdentityProvider::Model::SignUpRequest signUpRequest;
signUpRequest.SetClientId(m_settings->m_appClientId.c_str());
signUpRequest.SetClientId(m_cognitoAppClientId.c_str());
signUpRequest.SetUsername(username.c_str());
signUpRequest.SetPassword(password.c_str());
@@ -123,7 +109,7 @@ namespace AWSClientAuth
AZ::Job* phoneSignUpJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, username, password, phoneNumber]()
{
Aws::CognitoIdentityProvider::Model::SignUpRequest signUpRequest;
signUpRequest.SetClientId(m_settings->m_appClientId.c_str());
signUpRequest.SetClientId(m_cognitoAppClientId.c_str());
signUpRequest.SetUsername(username.c_str());
signUpRequest.SetPassword(password.c_str());
@@ -163,7 +149,7 @@ namespace AWSClientAuth
AZ::Job* confirmSignUpJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, username, confirmationCode]()
{
Aws::CognitoIdentityProvider::Model::ConfirmSignUpRequest confirmSignupRequest;
confirmSignupRequest.SetClientId(m_settings->m_appClientId.c_str());
confirmSignupRequest.SetClientId(m_cognitoAppClientId.c_str());
confirmSignupRequest.SetUsername(username.c_str());
confirmSignupRequest.SetConfirmationCode(confirmationCode.c_str());
@@ -192,7 +178,7 @@ namespace AWSClientAuth
AZ::Job* forgotPasswordJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, username]()
{
Aws::CognitoIdentityProvider::Model::ForgotPasswordRequest forgotPasswordRequest;
forgotPasswordRequest.SetClientId(m_settings->m_appClientId.c_str());
forgotPasswordRequest.SetClientId(m_cognitoAppClientId.c_str());
forgotPasswordRequest.SetUsername(username.c_str());
Aws::CognitoIdentityProvider::Model::ForgotPasswordOutcome forgotPasswordOutcome{ cognitoIdentityProviderClient->ForgotPassword(forgotPasswordRequest) };
@@ -220,7 +206,7 @@ namespace AWSClientAuth
AZ::Job* confirmForgotPasswordJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, username, confirmationCode, newPassword]()
{
Aws::CognitoIdentityProvider::Model::ConfirmForgotPasswordRequest confirmForgotPasswordRequest;
confirmForgotPasswordRequest.SetClientId(m_settings->m_appClientId.c_str());
confirmForgotPasswordRequest.SetClientId(m_cognitoAppClientId.c_str());
confirmForgotPasswordRequest.SetUsername(username.c_str());
confirmForgotPasswordRequest.SetConfirmationCode(confirmationCode.c_str());
confirmForgotPasswordRequest.SetPassword(newPassword.c_str());
@@ -32,6 +32,7 @@
#include <Authorization/AWSCognitoAuthorizationBus.h>
#include <UserManagement/AWSCognitoUserManagementBus.h>
#include <AWSCoreBus.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <AWSClientAuthBus.h>
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
#include <HttpRequestor/HttpRequestorBus.h>
@@ -68,13 +69,14 @@ namespace AWSClientAuthUnitTest
constexpr char TEST_PASSWORD[] = "TestPassword";
constexpr char TEST_NEW_PASSWORD[] = "TestNewPassword";
constexpr char TEST_CODE[] = "TestCode";
constexpr char TEST_REGION[] = "us-east-1";
constexpr char TEST_EMAIL[] = "test@test.com";
constexpr char TEST_PHONE[] = "+11234567890";
constexpr char TEST_COGNITO_CLIENTID[] = "TestCognitoClientId";
constexpr char TEST_EXCEPTION[] = "TestException";
constexpr char TEST_SESSION[] = "TestSession";
constexpr char TEST_TOKEN[] = "TestToken";
constexpr char TEST_ACCOUNT_ID[] = "1234567890";
constexpr char TEST_ACCOUNT_ID[] = "TestAccountId";
constexpr char TEST_IDENTITY_POOL_ID[] = "TestIdenitityPoolId";
constexpr char TEST_IDENTITY_ID[] = "TestIdenitityId";
constexpr char TEST_ACCESS_TOKEN[] = "TestAccessToken";
@@ -82,6 +84,39 @@ namespace AWSClientAuthUnitTest
constexpr char TEST_ID_TOKEN[] = "TestIdToken";
constexpr char TEST_ACCESS_KEY_ID[] = "TestAccessKeyId";
constexpr char TEST_SECRET_KEY_ID[] = "TestSecretKeyId";
constexpr char TEST_RESOURCE_NAME_ID[] = "TestResourceNameId";
class AWSResourceMappingRequestBusMock
: public AWSCore::AWSResourceMappingRequestBus::Handler
{
public:
AWSResourceMappingRequestBusMock()
{
AWSCore::AWSResourceMappingRequestBus::Handler::BusConnect();
ON_CALL(*this, GetResourceRegion).WillByDefault(testing::Return(TEST_REGION));
ON_CALL(*this, GetDefaultAccountId).WillByDefault(testing::Return(TEST_ACCOUNT_ID));
ON_CALL(*this, GetResourceAccountId).WillByDefault(testing::Return(TEST_ACCOUNT_ID));
ON_CALL(*this, GetResourceNameId).WillByDefault(testing::Return(TEST_RESOURCE_NAME_ID));
ON_CALL(*this, GetDefaultRegion).WillByDefault(testing::Return(TEST_REGION));
}
~AWSResourceMappingRequestBusMock()
{
AWSCore::AWSResourceMappingRequestBus::Handler::BusDisconnect();
}
MOCK_CONST_METHOD0(GetDefaultAccountId, AZStd::string());
MOCK_CONST_METHOD0(GetDefaultRegion, AZStd::string());
MOCK_CONST_METHOD1(GetResourceAccountId, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceNameId, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceRegion, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceType, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetServiceUrlByServiceName, AZStd::string(const AZStd::string& serviceName));
MOCK_CONST_METHOD2(
GetServiceUrlByRESTApiIdAndStage,
AZStd::string(const AZStd::string& restApiIdKeyName, const AZStd::string& restApiStageKeyName));
MOCK_METHOD1(ReloadConfigFile, void(bool isReloadingConfigFileName));
};
class HttpRequestorRequestBusMock
: public HttpRequestor::HttpRequestorRequestBus::Handler
@@ -545,6 +580,7 @@ namespace AWSClientAuthUnitTest
AZ::BehaviorContext* GetBehaviorContext() override { return nullptr; }
const char* GetExecutableFolder() const override { return nullptr; }
const char* GetAppRoot() const override { return nullptr; }
const char* GetEngineRoot() const override { return nullptr; }
AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; }
void EnumerateEntities(const EntityCallback& /*callback*/) override {}
void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {}
@@ -14,7 +14,6 @@
#include <AzTest/Utils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AWSClientAuthSystemComponent.h>
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <AzCore/Component/Entity.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AWSClientAuthGemMock.h>
@@ -119,33 +118,6 @@ namespace AWSClientAuthUnitTest
};
}
class AWSResourceMappingRequestBusMock
: public AWSCore::AWSResourceMappingRequestBus::Handler
{
public:
AWSResourceMappingRequestBusMock()
{
AWSCore::AWSResourceMappingRequestBus::Handler::BusConnect();
ON_CALL(*this, GetResourceRegion).WillByDefault(testing::Return("us-east-1"));
}
~AWSResourceMappingRequestBusMock()
{
AWSCore::AWSResourceMappingRequestBus::Handler::BusDisconnect();
}
MOCK_CONST_METHOD0(GetDefaultAccountId, AZStd::string());
MOCK_CONST_METHOD0(GetDefaultRegion, AZStd::string());
MOCK_CONST_METHOD1(GetResourceAccountId, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceNameId, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceRegion, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetResourceType, AZStd::string(const AZStd::string& resourceKeyName));
MOCK_CONST_METHOD1(GetServiceUrlByServiceName, AZStd::string(const AZStd::string& serviceName));
MOCK_CONST_METHOD2(
GetServiceUrlByRESTApiIdAndStage, AZStd::string(const AZStd::string& restApiIdKeyName, const AZStd::string& restApiStageKeyName));
MOCK_METHOD1(ReloadConfigFile, void(bool isReloadingConfigFileName));
};
class AWSClientAuthSystemComponentTest
: public AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture
{
@@ -193,7 +165,7 @@ protected:
public:
testing::NiceMock<AWSClientAuthUnitTest::AWSClientAuthSystemComponentMock> *m_awsClientAuthSystemsComponent;
testing::NiceMock<AWSClientAuthUnitTest::AWSCoreSystemComponentMock> *m_awsCoreSystemsComponent;
testing::NiceMock<AWSResourceMappingRequestBusMock> m_awsResourceMappingRequestBusMock;
testing::NiceMock<AWSClientAuthUnitTest::AWSResourceMappingRequestBusMock> m_awsResourceMappingRequestBusMock;
AZ::Entity* m_entity = nullptr;
};
@@ -24,7 +24,7 @@ namespace AWSClientAuthUnitTest
: public AWSClientAuth::AWSCognitoAuthenticationProvider
{
public:
using AWSClientAuth::AWSCognitoAuthenticationProvider::m_settings;
using AWSClientAuth::AWSCognitoAuthenticationProvider::m_cognitoAppClientId;
};
}
@@ -36,22 +36,6 @@ class AWSCognitoAuthenticationProviderTest
{
AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture::SetUp();
AWSClientAuth::AWSCognitoProviderSetting::Reflect(*m_serializeContext);
AZStd::string path = AZStd::string::format("%s/%s/authenticationProvider.setreg",
m_testFolder->c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
CreateTestFile("authenticationProvider.setreg"
, R"({
"AWS":
{
"CognitoIDP":
{
"AppClientId": "TestCognitoClientId"
}
}
})");
m_settingsRegistry->MergeSettingsFile(path, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
m_cognitoAuthenticationProviderMock.Initialize(m_settingsRegistry);
AWSCore::AWSCoreRequestBus::Handler::BusConnect();
@@ -78,6 +62,7 @@ class AWSCognitoAuthenticationProviderTest
public:
AWSClientAuthUnitTest::AWSCognitoAuthenticationProviderrLocalMock m_cognitoAuthenticationProviderMock;
testing::NiceMock<AWSClientAuthUnitTest::AWSResourceMappingRequestBusMock> m_awsResourceMappingRequestBusMock;
void AssertAuthenticationTokensPopulated()
{
@@ -116,9 +101,10 @@ public:
TEST_F(AWSCognitoAuthenticationProviderTest, Initialize_Success)
{
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1);
AWSClientAuthUnitTest::AWSCognitoAuthenticationProviderrLocalMock mock;
ASSERT_TRUE(mock.Initialize(m_settingsRegistry));
ASSERT_EQ(mock.m_settings->m_appClientId, AWSClientAuthUnitTest::TEST_COGNITO_CLIENTID);
ASSERT_EQ(mock.m_cognitoAppClientId, AWSClientAuthUnitTest::TEST_RESOURCE_NAME_ID);
}
TEST_F(AWSCognitoAuthenticationProviderTest, PasswordGrantSingleFactorSignInAsync_Success)
@@ -275,15 +261,9 @@ TEST_F(AWSCognitoAuthenticationProviderTest, SignOut_Success)
AssertAuthenticationTokensEmpty();
}
TEST_F(AWSCognitoAuthenticationProviderTest, Initialize_Fail_EmptyRegistry)
TEST_F(AWSCognitoAuthenticationProviderTest, Initialize_Fail_EmptyResourceName)
{
AWSClientAuthUnitTest::AWSCognitoAuthenticationProviderrLocalMock mock;
AZStd::shared_ptr<AZ::SettingsRegistryImpl> registry = AZStd::make_shared<AZ::SettingsRegistryImpl>();
registry->SetContext(m_serializeContext.get());
ASSERT_FALSE(mock.Initialize(registry));
ASSERT_EQ(mock.m_settings->m_appClientId, "");
registry.reset();
// Restore
mock.Initialize(m_settingsRegistry);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1).WillOnce(testing::Return(""));
ASSERT_FALSE(mock.Initialize(m_settingsRegistry));
}
@@ -66,7 +66,6 @@ protected:
{
AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture::SetUp();
AWSClientAuth::AWSCognitoProviderSetting::Reflect(*m_serializeContext);
AWSClientAuth::LWAProviderSetting::Reflect(*m_serializeContext);
AWSClientAuth::GoogleProviderSetting::Reflect(*m_serializeContext);
@@ -93,10 +92,6 @@ protected:
"Scope": "profile",
"OAuthCodeURL": "https://oauth2.googleapis.com/device/code",
"OAuthTokensURL": "https://oauth2.googleapis.com/token"
},
"CognitoIDP":
{
"AppClientId": "TestCognitoClientId"
}
}
})");
@@ -24,11 +24,13 @@ namespace AWSClientAuthUnitTest
{
public:
using AWSClientAuth::AWSCognitoAuthorizationController::m_settings;
using AWSClientAuth::AWSCognitoAuthorizationController::m_persistentCognitoIdentityProvider;
using AWSClientAuth::AWSCognitoAuthorizationController::m_persistentAnonymousCognitoIdentityProvider;
using AWSClientAuth::AWSCognitoAuthorizationController::m_cognitoCachingCredentialsProvider;
using AWSClientAuth::AWSCognitoAuthorizationController::m_cognitoCachingAnonymousCredentialsProvider;
using AWSClientAuth::AWSCognitoAuthorizationController::m_cognitoIdentityPoolId;
using AWSClientAuth::AWSCognitoAuthorizationController::m_formattedCognitoUserPoolId;
using AWSClientAuth::AWSCognitoAuthorizationController::m_awsAccountId;
};
}
@@ -39,9 +41,6 @@ protected:
void SetUp() override
{
AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture::SetUp();
AWSClientAuth::CognitoAuthorizationSettings::Reflect(*m_serializeContext);
m_mockController = AZStd::make_unique<AWSClientAuthUnitTest::AWSCognitoAuthorizationControllerTestLocalMock>();
}
@@ -53,26 +52,18 @@ protected:
public:
AZStd::unique_ptr<AWSClientAuthUnitTest::AWSCognitoAuthorizationControllerTestLocalMock> m_mockController;
testing::NiceMock<AWSClientAuthUnitTest::AWSResourceMappingRequestBusMock> m_awsResourceMappingRequestBusMock;
};
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Success)
{
AZStd::string path = AZStd::string::format("%s/%s/awsCognitoAuthorization.setreg",
m_testFolder->c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
CreateTestFile("awsCognitoAuthorization.setreg"
, R"({
"AWS": {
"CognitoIdentityPool": {
"CognitoUserPoolId": "TestUserPoolId",
"LoginWithAmazonId": "www.amazon.com",
"AWSAccountId": "1234567890",
"IdentityPoolId": "TestIdentityPoolId"
}
}
})");
ASSERT_TRUE(m_mockController->Initialize(path));
ASSERT_TRUE(m_mockController->m_settings->m_cognitoUserPoolId == "TestUserPoolId");
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(2);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultRegion()).Times(1);
ASSERT_TRUE(m_mockController->Initialize());
ASSERT_TRUE(m_mockController->m_formattedCognitoUserPoolId.find(AWSClientAuthUnitTest::TEST_RESOURCE_NAME_ID) != AZStd::string::npos);
ASSERT_TRUE(m_mockController->m_awsAccountId == AWSClientAuthUnitTest::TEST_ACCOUNT_ID);
ASSERT_TRUE(m_mockController->m_cognitoIdentityPoolId == AWSClientAuthUnitTest::TEST_RESOURCE_NAME_ID);
}
TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_WithLogins_Success)
@@ -438,9 +429,17 @@ TEST_F(AWSCognitoAuthorizationControllerTest, GetCredentialHandlerOrder_Call_Alw
EXPECT_EQ(order, AWSCore::CredentialHandlerOrder::COGNITO_IDENITY_POOL_CREDENTIAL_HANDLER);
}
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Fail_InvalidPath)
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Fail_GetResourceNameEmpty)
{
AZ_TEST_START_TRACE_SUPPRESSION;
ASSERT_FALSE(m_mockController->Initialize(""));
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1).WillOnce(testing::Return(""));
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1);
ASSERT_FALSE(m_mockController->Initialize());
}
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Fail_GetAWSAccountEmpty)
{
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1).WillOnce(testing::Return(""));
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultRegion()).Times(0);
ASSERT_FALSE(m_mockController->Initialize());
}
@@ -16,17 +16,6 @@
#include <AWSClientAuthGemMock.h>
#include <aws/cognito-idp/CognitoIdentityProviderErrors.h>
namespace AWSClientAuthUnitTest
{
class AWSCognitoUserManagementControllerLocalMock
: public AWSClientAuth::AWSCognitoUserManagementController
{
public:
using AWSClientAuth::AWSCognitoUserManagementController::m_settings;
};
}
class AWSCognitoUserManagementControllerTest
: public AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture
, public AWSCore::AWSCoreRequestBus::Handler
@@ -35,8 +24,7 @@ protected:
void SetUp() override
{
AWSClientAuthUnitTest::AWSClientAuthGemAllocatorFixture::SetUp();
AWSClientAuth::AWSCognitoUserManagementSetting::Reflect(*m_serializeContext);
m_mockController = AZStd::make_unique<AWSClientAuthUnitTest::AWSCognitoUserManagementControllerLocalMock>();
m_mockController = AZStd::make_unique<AWSClientAuth::AWSCognitoUserManagementController>();
AWSCore::AWSCoreRequestBus::Handler::BusConnect();
}
@@ -61,26 +49,15 @@ protected:
}
public:
AZStd::unique_ptr<AWSClientAuthUnitTest::AWSCognitoUserManagementControllerLocalMock> m_mockController;
AZStd::unique_ptr<AWSClientAuth::AWSCognitoUserManagementController> m_mockController;
testing::NiceMock<AWSClientAuthUnitTest::AWSResourceMappingRequestBusMock> m_awsResourceMappingRequestBusMock;
};
TEST_F(AWSCognitoUserManagementControllerTest, Initialize_Success)
{
AZStd::string path = AZStd::string::format("%s/%s/awsCognitoUserManagement.setreg",
m_testFolder->c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
CreateTestFile("awsCognitoUserManagement.setreg"
, R"({"AWS":
{
"CognitoUserPool":
{
"AppClientId": "TestClientId",
"SignUpConfirmationType": "email"
}
}
})");
ASSERT_TRUE(m_mockController->Initialize(path));
ASSERT_EQ(m_mockController->m_settings->m_appClientId, "TestClientId");
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1);
ASSERT_TRUE(m_mockController->Initialize());
ASSERT_EQ(m_mockController->GetCognitoAppClientId(), AWSClientAuthUnitTest::TEST_RESOURCE_NAME_ID);
}
TEST_F(AWSCognitoUserManagementControllerTest, EmailSignUp_Success)
@@ -203,9 +180,8 @@ TEST_F(AWSCognitoUserManagementControllerTest, ConfirmForgotPassword_Fail_Confir
m_mockController->ConfirmForgotPasswordAsync(AWSClientAuthUnitTest::TEST_USERNAME, AWSClientAuthUnitTest::TEST_CODE, AWSClientAuthUnitTest::TEST_NEW_PASSWORD);
}
TEST_F(AWSCognitoUserManagementControllerTest, Initialize_Fail_InvalidPath)
TEST_F(AWSCognitoUserManagementControllerTest, Initialize_Fail_GetResourceNameEmpty)
{
AZ_TEST_START_TRACE_SUPPRESSION;
ASSERT_FALSE(m_mockController->Initialize(""));
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1).WillOnce(testing::Return(""));
ASSERT_FALSE(m_mockController->Initialize());
}
@@ -18,16 +18,15 @@ set(FILES
Include/Private/AWSClientAuthSystemComponent.h
Include/Private/AWSClientAuthBus.h
Include/Private/AWSClientAuthResourceMappingConstants.h
Include/Private/Authentication/AuthenticationProviderTypes.h
Include/Private/Authentication/AuthenticationProviderManager.h
Include/Private/Authentication/AuthenticationNotificationBusBehaviorHandler.h
Include/Private/Authorization/AWSCognitoAuthorizationTypes.h
Include/Private/Authorization/AWSCognitoAuthorizationController.h
Include/Private/Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h
Include/Private/Authorization/AWSCognitoAuthorizationNotificationBusBehaviorHandler.h
Include/Private/UserManagement/AWSCognitoUserManagementTypes.h
Include/Private/UserManagement/AWSCognitoUserManagementController.h
Include/Private/UserManagement/UserManagementNotificationBusBehaviorHandler.h