-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smithy reference architecture identity base APIs
- Loading branch information
1 parent
53259b8
commit ffea689
Showing
13 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/aws-cpp-sdk-core/include/aws/core/utils/FutureOutcome.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <aws/core/utils/Outcome.h> | ||
|
||
namespace Aws | ||
{ | ||
namespace Utils | ||
{ | ||
|
||
/** | ||
* Template class representing the std::future object of outcome of calling some other API. | ||
* It will contain a future of an either a successful result or the failure error. | ||
* The caller must check whether the outcome of the request was a success before attempting to access | ||
* the result or the error. | ||
*/ | ||
template<typename R, typename E> // Result, Error | ||
using FutureOutcome = Aws::Utils::Outcome<R, E>; | ||
} // namespace Utils | ||
} // namespace Aws |
22 changes: 22 additions & 0 deletions
22
src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentity.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsBearerTokenIdentityBase.h> | ||
|
||
namespace smithy { | ||
class AwsBearerTokenIdentity : public AwsBearerTokenIdentityBase { | ||
public: | ||
virtual Aws::String token() override; | ||
|
||
virtual Aws::Crt::Optional<AwsIdentity::DateTime> expiration() override; | ||
|
||
protected: | ||
Aws::String m_token; | ||
Aws::Crt::Optional<AwsIdentity::DateTime> m_expiration; | ||
}; | ||
} | ||
|
||
#include <smithy/identity/identity/impl/AwsBearerTokenIdentityImpl.h> |
16 changes: 16 additions & 0 deletions
16
src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsBearerTokenIdentityBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsIdentity.h> | ||
|
||
namespace smithy { | ||
class AwsBearerTokenIdentityBase : public AwsIdentity { | ||
public: | ||
virtual Aws::String token() = 0; | ||
|
||
virtual Aws::Crt::Optional<AwsIdentity::DateTime> expiration() override = 0 ; | ||
}; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsCredentialIdentity.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsCredentialIdentityBase.h> | ||
|
||
namespace smithy { | ||
class AwsCredentialIdentity : public AwsCredentialIdentityBase { | ||
public: | ||
virtual Aws::String accessKeyId() override; | ||
virtual Aws::String secretAccessKey() override; | ||
virtual Aws::Crt::Optional<Aws::String> sessionToken() override; | ||
|
||
virtual Aws::Crt::Optional<AwsIdentity::DateTime> expiration() override; | ||
|
||
protected: | ||
Aws::String m_accessKeyId; | ||
Aws::String m_secretAccessKey; | ||
Aws::Crt::Optional<Aws::String> m_sessionToken; | ||
Aws::Crt::Optional<AwsIdentity::DateTime> m_expiration; | ||
}; | ||
} | ||
|
||
#include <smithy/identity/identity/impl/AwsCredentialIdentityImpl.h> |
18 changes: 18 additions & 0 deletions
18
src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsCredentialIdentityBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsIdentity.h> | ||
|
||
namespace smithy { | ||
class AwsCredentialIdentityBase : public AwsIdentity { | ||
public: | ||
virtual Aws::String accessKeyId() = 0; | ||
virtual Aws::String secretAccessKey() = 0; | ||
virtual Aws::Crt::Optional<Aws::String> sessionToken() = 0; | ||
|
||
virtual Aws::Crt::Optional<AwsIdentity::DateTime> expiration() override = 0 ; | ||
}; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/aws-cpp-sdk-core/include/smithy/identity/identity/AwsIdentity.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <aws/crt/Optional.h> | ||
|
||
#include <aws/core/utils/DateTime.h> | ||
|
||
namespace smithy { | ||
class AwsIdentity { | ||
public: | ||
using DateTime = Aws::Utils::DateTime; | ||
|
||
virtual ~AwsIdentity(){}; | ||
virtual Aws::Crt::Optional<DateTime> expiration() { | ||
return Aws::Crt::Optional<DateTime>(); | ||
}; | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/aws-cpp-sdk-core/include/smithy/identity/identity/impl/AwsBearerTokenIdentityImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsBearerTokenIdentity.h> | ||
|
||
namespace smithy { | ||
Aws::String AwsBearerTokenIdentity::token() { | ||
return m_token; | ||
} | ||
|
||
Aws::Crt::Optional<AwsIdentity::DateTime> AwsBearerTokenIdentity::expiration() { | ||
return m_expiration; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/aws-cpp-sdk-core/include/smithy/identity/identity/impl/AwsCredentialIdentityImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsCredentialIdentity.h> | ||
|
||
namespace smithy { | ||
Aws::String AwsCredentialIdentity::accessKeyId() { | ||
return m_accessKeyId; | ||
} | ||
|
||
Aws::String AwsCredentialIdentity::secretAccessKey() { | ||
return m_secretAccessKey; | ||
} | ||
|
||
Aws::Crt::Optional<Aws::String> AwsCredentialIdentity::sessionToken() { | ||
return m_sessionToken; | ||
} | ||
|
||
Aws::Crt::Optional<AwsIdentity::DateTime> AwsCredentialIdentity::expiration() { | ||
return m_expiration; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsBearerTokenIdentityResolver.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/resolver/AwsIdentityResolverBase.h> | ||
|
||
#include <smithy/identity/identity/AwsBearerTokenIdentity.h> | ||
|
||
namespace smithy { | ||
class AwsBearerTokenIdentityResolver : public IdentityResolverBase<AwsBearerTokenIdentity> { | ||
public: | ||
using IdentityT = AwsBearerTokenIdentity; | ||
virtual ~AwsBearerTokenIdentityResolver() = default; | ||
|
||
virtual ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, const AdditionalParameters& additionalParameters) = 0; | ||
}; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsCredentialIdentityResolver.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/resolver/AwsIdentityResolverBase.h> | ||
|
||
#include <smithy/identity/identity/AwsCredentialIdentity.h> | ||
|
||
namespace smithy { | ||
class AwsCredentialIdentityResolver : public IdentityResolverBase<AwsCredentialIdentity> { | ||
public: | ||
using IdentityT = AwsCredentialIdentity; | ||
virtual ~AwsCredentialIdentityResolver() = default; | ||
|
||
virtual ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, const AdditionalParameters& additionalParameters) = 0; | ||
}; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/aws-cpp-sdk-core/include/smithy/identity/resolver/AwsIdentityResolverBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <aws/crt/Optional.h> | ||
#include <aws/crt/Variant.h> | ||
|
||
#include <aws/core/client/CoreErrors.h> | ||
#include <aws/core/utils/FutureOutcome.h> | ||
|
||
#include <aws/core/utils/memory/stl/AWSString.h> | ||
#include <aws/core/utils/memory/stl/AWSMap.h> | ||
|
||
#include <aws/core/utils/DateTime.h> | ||
|
||
namespace smithy { | ||
template<typename IDENTITY_T> | ||
class IdentityResolverBase { | ||
public: | ||
using IdentityT = IDENTITY_T; | ||
|
||
virtual ~IdentityResolverBase(){}; | ||
|
||
using IdentityProperties = Aws::UnorderedMap<Aws::String, Aws::Crt::Variant<Aws::String, bool>>; | ||
// IdentityResolvers are asynchronous. | ||
using ResolveIdentityFutureOutcome = Aws::Utils::FutureOutcome<IdentityT, Aws::Client::AWSError<Aws::Client::CoreErrors>>; | ||
using AdditionalParameters = Aws::UnorderedMap<Aws::String, Aws::Crt::Variant<Aws::String, bool>>; | ||
|
||
// Each Identity has one or more identity resolvers that are able to load the customer’s | ||
// Identity. An identity resolver might load the identity from a remote service (e.g. STS), a local | ||
// service (e.g. IMDS), local disk (e.g. a configuration file) or local memory (e.g. environment variables). | ||
virtual ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, const AdditionalParameters& additionalParameters) = 0; | ||
}; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/aws-cpp-sdk-core/include/smithy/identity/signer/AwsSignerBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
|
||
#include <smithy/identity/identity/AwsIdentity.h> | ||
|
||
#include <aws/crt/Variant.h> | ||
#include <aws/core/client/AWSError.h> | ||
#include <aws/core/http/HttpRequest.h> | ||
#include <aws/core/utils/FutureOutcome.h> | ||
#include <aws/core/utils/memory/stl/AWSMap.h> | ||
|
||
|
||
namespace smithy { | ||
template<typename IDENTITY_T> | ||
class AwsSignerBase { | ||
public: | ||
using IdentityT = IDENTITY_T; | ||
static_assert(std::is_base_of<AwsIdentity, IDENTITY_T>::value_type, "Identity type should inherit AwsIdentity"); | ||
using SigningProperties = Aws::UnorderedMap<Aws::String, Aws::String>; | ||
using AdditionalParameters = Aws::UnorderedMap<Aws::String, Aws::Crt::Variant<Aws::String, bool>>; | ||
using HttpRequest = Aws::Http::HttpRequest; | ||
using SigningFutureOutcome = Aws::Utils::FutureOutcome<HttpRequest, Aws::Client::AWSError<Aws::Client::CoreErrors>>; | ||
|
||
|
||
virtual SigningFutureOutcome sign(const HttpRequest& httpRequest, const IdentityT& identity, SigningProperties properties, const AdditionalParameters& additionalParameters) = 0; | ||
|
||
virtual ~AwsSignerBase(){}; | ||
}; | ||
} |