Lesson 35 - Get Compute Auth Token Working
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthScheme.h>
|
||||
#include <smithy/identity/auth/built-in/BearerTokenAuthSchemeOption.h>
|
||||
#include <smithy/identity/identity/AwsBearerTokenIdentityBase.h>
|
||||
#include <smithy/identity/resolver/AwsBearerTokenIdentityResolver.h>
|
||||
#include <smithy/identity/signer/built-in/BearerTokenSigner.h>
|
||||
namespace smithy
|
||||
{
|
||||
class BearerTokenAuthScheme : public AuthScheme<AwsBearerTokenIdentityBase>
|
||||
{
|
||||
public:
|
||||
using AwsCredentialIdentityResolverT = IdentityResolverBase<IdentityT>;
|
||||
using AwsCredentialSignerT = AwsSignerBase<IdentityT>;
|
||||
using BearerTokenAuthSchemeParameters = DefaultAuthSchemeResolverParameters;
|
||||
|
||||
// This allows to override the identity resolver
|
||||
explicit BearerTokenAuthScheme(
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver,
|
||||
const Aws::String &serviceName, const Aws::String ®ion)
|
||||
: AuthScheme("smithy.api#HTTPBearerAuth"),
|
||||
m_identityResolver{identityResolver},
|
||||
m_signer{Aws::MakeShared<smithy::BearerTokenSigner>(
|
||||
"BearerTokenAuthScheme", serviceName, region)}
|
||||
{
|
||||
assert(m_identityResolver);
|
||||
assert(m_signer);
|
||||
}
|
||||
|
||||
explicit BearerTokenAuthScheme(const Aws::String &serviceName,
|
||||
const Aws::String ®ion)
|
||||
: BearerTokenAuthScheme(
|
||||
Aws::MakeShared<DefaultAwsBearerTokenIdentityResolver>(
|
||||
"BearerTokenAuthScheme"),
|
||||
serviceName, region)
|
||||
{
|
||||
assert(m_identityResolver);
|
||||
|
||||
assert(m_signer);
|
||||
}
|
||||
|
||||
virtual ~BearerTokenAuthScheme() = default;
|
||||
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver() override
|
||||
{
|
||||
return m_identityResolver;
|
||||
}
|
||||
|
||||
std::shared_ptr<AwsCredentialSignerT> signer() override { return m_signer; }
|
||||
|
||||
protected:
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> m_identityResolver;
|
||||
std::shared_ptr<AwsCredentialSignerT> m_signer;
|
||||
};
|
||||
} // namespace smithy
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthSchemeOption.h>
|
||||
namespace smithy
|
||||
{
|
||||
struct BearerTokenAuthSchemeOption
|
||||
{
|
||||
static AuthSchemeOption bearerTokenAuthSchemeOption;
|
||||
};
|
||||
|
||||
AuthSchemeOption BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption =
|
||||
AuthSchemeOption("smithy.api#HTTPBearerAuth");
|
||||
} // namespace smithy
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthSchemeResolverBase.h>
|
||||
#include <smithy/identity/auth/built-in/BearerTokenAuthSchemeOption.h>
|
||||
|
||||
namespace smithy
|
||||
{
|
||||
template <typename ServiceAuthSchemeParametersT =
|
||||
DefaultAuthSchemeResolverParameters>
|
||||
class BearerTokenAuthSchemeResolver
|
||||
: public AuthSchemeResolverBase<ServiceAuthSchemeParametersT>
|
||||
{
|
||||
public:
|
||||
using ServiceAuthSchemeParameters = ServiceAuthSchemeParametersT;
|
||||
virtual ~BearerTokenAuthSchemeResolver() = default;
|
||||
|
||||
Aws::Vector<AuthSchemeOption> resolveAuthScheme(
|
||||
const ServiceAuthSchemeParameters &identityProperties) override
|
||||
{
|
||||
AWS_UNREFERENCED_PARAM(identityProperties);
|
||||
return {BearerTokenAuthSchemeOption::bearerTokenAuthSchemeOption};
|
||||
}
|
||||
};
|
||||
} // namespace smithy
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthScheme.h>
|
||||
#include <smithy/identity/auth/built-in/SigV4AuthSchemeOption.h>
|
||||
|
||||
#include <smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h>
|
||||
|
||||
#include <smithy/identity/identity/AwsCredentialIdentityBase.h>
|
||||
#include <smithy/identity/signer/built-in/SigV4Signer.h>
|
||||
#include <smithy/identity/auth/built-in/SigV4AuthScheme.h>
|
||||
|
||||
|
||||
namespace smithy {
|
||||
constexpr char SIGV4[] = "aws.auth#sigv4";
|
||||
|
||||
class SigV4AuthScheme : public AuthScheme<AwsCredentialIdentityBase>
|
||||
{
|
||||
public:
|
||||
using AwsCredentialIdentityResolverT = IdentityResolverBase<IdentityT>;
|
||||
using AwsCredentialSignerT = AwsSignerBase<IdentityT>;
|
||||
using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters;
|
||||
|
||||
//This allows to override the identity resolver
|
||||
explicit SigV4AuthScheme(std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver,
|
||||
const Aws::String& serviceName,
|
||||
const Aws::String& region)
|
||||
: AuthScheme(SIGV4),
|
||||
m_identityResolver{identityResolver},
|
||||
m_signer{Aws::MakeShared<AwsSigV4Signer>("SigV4AuthScheme", serviceName, region)}
|
||||
{
|
||||
assert(m_identityResolver);
|
||||
assert(m_signer);
|
||||
}
|
||||
|
||||
//delegate constructor
|
||||
explicit SigV4AuthScheme(const Aws::String& serviceName,
|
||||
const Aws::String& region)
|
||||
: SigV4AuthScheme(Aws::MakeShared<DefaultAwsCredentialIdentityResolver>("SigV4AuthScheme"),
|
||||
serviceName,
|
||||
region)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SigV4AuthScheme() = default;
|
||||
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver() override
|
||||
{
|
||||
return m_identityResolver;
|
||||
}
|
||||
|
||||
std::shared_ptr<AwsCredentialSignerT> signer() override
|
||||
{
|
||||
return m_signer;
|
||||
}
|
||||
protected:
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> m_identityResolver;
|
||||
std::shared_ptr<AwsCredentialSignerT> m_signer;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/Smithy_EXPORTS.h>
|
||||
#include <smithy/identity/auth/AuthSchemeOption.h>
|
||||
|
||||
namespace smithy {
|
||||
struct SigV4AuthSchemeOption
|
||||
{
|
||||
static SMITHY_API AuthSchemeOption sigV4AuthSchemeOption;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthSchemeResolverBase.h>
|
||||
#include <smithy/identity/auth/built-in/SigV4AuthSchemeOption.h>
|
||||
|
||||
|
||||
namespace smithy {
|
||||
template<typename ServiceAuthSchemeParametersT = DefaultAuthSchemeResolverParameters>
|
||||
class SigV4AuthSchemeResolver : public AuthSchemeResolverBase<ServiceAuthSchemeParametersT>
|
||||
{
|
||||
public:
|
||||
using ServiceAuthSchemeParameters = ServiceAuthSchemeParametersT;
|
||||
virtual ~SigV4AuthSchemeResolver() = default;
|
||||
|
||||
Aws::Vector<AuthSchemeOption> resolveAuthScheme(const ServiceAuthSchemeParameters& identityProperties) override
|
||||
{
|
||||
AWS_UNREFERENCED_PARAM(identityProperties);
|
||||
return {SigV4AuthSchemeOption::sigV4AuthSchemeOption};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthScheme.h>
|
||||
#include <smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h>
|
||||
|
||||
#include <smithy/identity/resolver/built-in/DefaultAwsCredentialIdentityResolver.h>
|
||||
|
||||
#include <smithy/identity/identity/AwsCredentialIdentityBase.h>
|
||||
#include <smithy/identity/signer/built-in/SigV4aSigner.h>
|
||||
|
||||
|
||||
namespace smithy {
|
||||
constexpr char SIGV4A[] = "aws.auth#sigv4a";
|
||||
|
||||
|
||||
class SigV4aAuthScheme : public AuthScheme<AwsCredentialIdentityBase>
|
||||
{
|
||||
public:
|
||||
using AwsCredentialIdentityResolverT = IdentityResolverBase<IdentityT>;
|
||||
using AwsCredentialSignerT = AwsSignerBase<IdentityT>;
|
||||
using SigV4aAuthSchemeParameters = DefaultAuthSchemeResolverParameters;
|
||||
|
||||
//This allows to override the identity resolver
|
||||
explicit SigV4aAuthScheme(std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver,
|
||||
const Aws::String& serviceName,
|
||||
const Aws::String& region)
|
||||
: AuthScheme(SIGV4A),
|
||||
m_identityResolver{identityResolver},
|
||||
m_signer{Aws::MakeShared<AwsSigV4aSigner>("SigV4aAuthScheme", serviceName, region)}
|
||||
{
|
||||
assert(m_identityResolver);
|
||||
assert(m_signer);
|
||||
}
|
||||
|
||||
explicit SigV4aAuthScheme(const Aws::String& serviceName,
|
||||
const Aws::String& region)
|
||||
: SigV4aAuthScheme(Aws::MakeShared<DefaultAwsCredentialIdentityResolver>("SigV4aAuthScheme"), serviceName, region)
|
||||
{
|
||||
assert(m_identityResolver);
|
||||
|
||||
assert(m_signer);
|
||||
}
|
||||
|
||||
virtual ~SigV4aAuthScheme() = default;
|
||||
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver() override
|
||||
{
|
||||
return m_identityResolver;
|
||||
}
|
||||
|
||||
std::shared_ptr<AwsCredentialSignerT> signer() override
|
||||
{
|
||||
return m_signer;
|
||||
}
|
||||
protected:
|
||||
std::shared_ptr<AwsCredentialIdentityResolverT> m_identityResolver;
|
||||
std::shared_ptr<AwsCredentialSignerT> m_signer;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/Smithy_EXPORTS.h>
|
||||
#include <smithy/identity/auth/AuthSchemeOption.h>
|
||||
|
||||
namespace smithy {
|
||||
struct SigV4aAuthSchemeOption
|
||||
{
|
||||
static SMITHY_API AuthSchemeOption sigV4aAuthSchemeOption;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <smithy/identity/auth/AuthSchemeResolverBase.h>
|
||||
#include <smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h>
|
||||
|
||||
|
||||
namespace smithy {
|
||||
template<typename ServiceAuthSchemeParametersT = DefaultAuthSchemeResolverParameters>
|
||||
class SigV4aAuthSchemeResolver : public AuthSchemeResolverBase<ServiceAuthSchemeParametersT>
|
||||
{
|
||||
public:
|
||||
using ServiceAuthSchemeParameters = ServiceAuthSchemeParametersT;
|
||||
virtual ~SigV4aAuthSchemeResolver() = default;
|
||||
|
||||
Aws::Vector<AuthSchemeOption> resolveAuthScheme(const ServiceAuthSchemeParameters& identityProperties) override
|
||||
{
|
||||
AWS_UNREFERENCED_PARAM(identityProperties);
|
||||
return {SigV4aAuthSchemeOption::sigV4aAuthSchemeOption};
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user