Commit d79865e1 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/dms_refresh_token with refs/heads/master into...

Merge branch feature/jorgen.lind/dms_refresh_token with refs/heads/master into refs/merge-requests/434/train
parents 874fad90 5066702a
Pipeline #49316 passed with stages
in 20 minutes and 4 seconds
......@@ -33,7 +33,7 @@ The recognised keys for ``s3`` connection string are
- Region
- EndpointOverride
- AccessKeyId
- SecretKey
- SecretKey or SecretAccessKey
- SessionToken
- Expiration (Note: AWS SDK only accepts 'Z' timezone for ISO 8601 time)
- LogFilenamePrefix
......@@ -42,6 +42,9 @@ The recognised keys for ``s3`` connection string are
- RequestTimeoutMs
- DisableInitApi (This will disable init/deinit of AWS sdk. Possible values: 1, On, True, Yes (case insensitive), all other values are false.)
Note: Key values for S3 can be specified in `CamelCase` or `snake_case`
``azure`` has two modes. The connection string mode or the bearer token mode.
If the connection string contains a key with name BearerToken it will parse the
string and extract following parameters:
......@@ -62,10 +65,28 @@ The Token is the OAuth2 token.
``sd`` will accept the following keys
- sdauthorityurl
- sdapikey
- sdtoken
- loglevel
- SdAuthorityUrl
- SdApiKey
- SdToken
- LogLevel
The token `SdToken` is typically a short lived token. The sd IO backend also
supports using a `RefreshToken` flow. Then its not needed to specify the sdtoken
but following key/value pairs have to specified:
- AuthTokenUrl
- ClientId
- ClientSecret
- RefreshToken
When these paramaters are provided OpenVDS will send a "x-www-form-urlencoded"
http request to `AuthTokenUrl` with supplied values and also added:
grant_type=refresh_token&scope=openid email. The used refresh token will be
updated If the response contains a refresh_token member. It is the access_token
member of the return that will be used as the sdtoken until it expires.
NOTE: Key values for `sd` can use `snake_case` instead of `CammelCase` to match the
look and feel of the response from the token provider.
``azureSAS`` will accept the following keys
......
......@@ -68,7 +68,8 @@ py::register_exception<InvalidArgument>(m, "InvalidArgument");
// IMPLEMENTED : // IndexOutOfRangeException
// IMPLEMENTED : py::class_<IndexOutOfRangeException, Exception>
// IMPLEMENTED : IndexOutOfRangeException_(m,"IndexOutOfRangeException", OPENVDS_DOCSTRING(IndexOutOfRangeException));
// IMPLEMENTED : py::class_<IndexOutOfRangeException, MessageBufferException>
// IMPLEMENTED : IndexOutOfRangeException_.def(py::init<const char * >(), py::arg("errorMessage").none(false), OPENVDS_DOCSTRING(IndexOutOfRangeException_IndexOutOfRangeException));
// IMPLEMENTED : IndexOutOfRangeException_.def("getErrorMessage" , static_cast<const char *(IndexOutOfRangeException::*)() const>(&IndexOutOfRangeException::GetErrorMessage), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IndexOutOfRangeException_GetErrorMessage));
// IMPLEMENTED : IndexOutOfRangeException_.def_property_readonly("errorMessage", &IndexOutOfRangeException::GetErrorMessage, OPENVDS_DOCSTRING(IndexOutOfRangeException_GetErrorMessage));
py::register_exception<IndexOutOfRangeException>(m, "IndexOutOfRangeException");
......
......@@ -53,6 +53,7 @@ PyGlobal::initModule(py::module& m)
OpenOptions_ConnectionType_.value("AWS" , OpenOptions::ConnectionType::AWS , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_AWS));
OpenOptions_ConnectionType_.value("Azure" , OpenOptions::ConnectionType::Azure , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_Azure));
OpenOptions_ConnectionType_.value("AzureSdkForCpp" , OpenOptions::ConnectionType::AzureSdkForCpp, OPENVDS_DOCSTRING(OpenOptions_ConnectionType_AzureSdkForCpp));
OpenOptions_ConnectionType_.value("AzurePresigned" , OpenOptions::ConnectionType::AzurePresigned, OPENVDS_DOCSTRING(OpenOptions_ConnectionType_AzurePresigned));
OpenOptions_ConnectionType_.value("GoogleStorage" , OpenOptions::ConnectionType::GoogleStorage, OPENVDS_DOCSTRING(OpenOptions_ConnectionType_GoogleStorage));
OpenOptions_ConnectionType_.value("DMS" , OpenOptions::ConnectionType::DMS , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_DMS));
......@@ -67,7 +68,7 @@ PyGlobal::initModule(py::module& m)
AWSOpenOptions_(m,"AWSOpenOptions", OPENVDS_DOCSTRING(AWSOpenOptions));
AWSOpenOptions_.def(py::init< >(), OPENVDS_DOCSTRING(AWSOpenOptions_AWSOpenOptions));
AWSOpenOptions_.def(py::init<const std::string &, const std::string &, const std::string &, const std::string &, int, int>(), py::arg("bucket").none(false), py::arg("key").none(false), py::arg("region").none(false), py::arg("endpointOverride").none(false), py::arg("connectionTimeoutMs") = 3000, py::arg("requestTimeoutMs") = 6000, OPENVDS_DOCSTRING(AWSOpenOptions_AWSOpenOptions_2));
AWSOpenOptions_.def(py::init<const std::string &, const std::string &, const std::string &, const std::string &, int, int, bool>(), py::arg("bucket").none(false), py::arg("key").none(false), py::arg("region").none(false), py::arg("endpointOverride").none(false), py::arg("connectionTimeoutMs") = 3000, py::arg("requestTimeoutMs") = 6000, py::arg("disableInitApi") = false, OPENVDS_DOCSTRING(AWSOpenOptions_AWSOpenOptions_2));
AWSOpenOptions_.def_readwrite("bucket" , &AWSOpenOptions::bucket , OPENVDS_DOCSTRING(AWSOpenOptions_bucket));
AWSOpenOptions_.def_readwrite("key" , &AWSOpenOptions::key , OPENVDS_DOCSTRING(AWSOpenOptions_key));
AWSOpenOptions_.def_readwrite("region" , &AWSOpenOptions::region , OPENVDS_DOCSTRING(AWSOpenOptions_region));
......@@ -80,6 +81,7 @@ PyGlobal::initModule(py::module& m)
AWSOpenOptions_.def_readwrite("loglevel" , &AWSOpenOptions::loglevel , OPENVDS_DOCSTRING(AWSOpenOptions_loglevel));
AWSOpenOptions_.def_readwrite("connectionTimeoutMs" , &AWSOpenOptions::connectionTimeoutMs, OPENVDS_DOCSTRING(AWSOpenOptions_connectionTimeoutMs));
AWSOpenOptions_.def_readwrite("requestTimeoutMs" , &AWSOpenOptions::requestTimeoutMs, OPENVDS_DOCSTRING(AWSOpenOptions_requestTimeoutMs));
AWSOpenOptions_.def_readwrite("disableInitApi" , &AWSOpenOptions::disableInitApi, OPENVDS_DOCSTRING(AWSOpenOptions_disableInitApi));
// AzureOpenOptions
py::class_<AzureOpenOptions, OpenOptions>
......@@ -188,12 +190,16 @@ PyGlobal::initModule(py::module& m)
DMSOpenOptions_(m,"DMSOpenOptions", OPENVDS_DOCSTRING(DMSOpenOptions));
DMSOpenOptions_.def(py::init< >(), OPENVDS_DOCSTRING(DMSOpenOptions_DMSOpenOptions));
DMSOpenOptions_.def(py::init<const std::string &, const std::string &, const std::string &, const std::string &, int>(), py::arg("sdAuthorityUrl").none(false), py::arg("sdApiKey").none(false), py::arg("sdToken").none(false), py::arg("datasetPath").none(false), py::arg("logLevel").none(false), OPENVDS_DOCSTRING(DMSOpenOptions_DMSOpenOptions_2));
DMSOpenOptions_.def(py::init<const std::string &, const std::string &, const std::string &, const std::string &, int, const std::string &, const std::string &, const std::string &, const std::string &>(), py::arg("sdAuthorityUrl").none(false), py::arg("sdApiKey").none(false), py::arg("sdToken").none(false), py::arg("datasetPath").none(false), py::arg("logLevel").none(false), py::arg("authTokenUrl").none(false), py::arg("refreshToken").none(false), py::arg("clientId").none(false), py::arg("clientSecret").none(false), OPENVDS_DOCSTRING(DMSOpenOptions_DMSOpenOptions_2));
DMSOpenOptions_.def_readwrite("sdAuthorityUrl" , &DMSOpenOptions::sdAuthorityUrl, OPENVDS_DOCSTRING(DMSOpenOptions_sdAuthorityUrl));
DMSOpenOptions_.def_readwrite("sdApiKey" , &DMSOpenOptions::sdApiKey , OPENVDS_DOCSTRING(DMSOpenOptions_sdApiKey));
DMSOpenOptions_.def_readwrite("sdToken" , &DMSOpenOptions::sdToken , OPENVDS_DOCSTRING(DMSOpenOptions_sdToken));
DMSOpenOptions_.def_readwrite("datasetPath" , &DMSOpenOptions::datasetPath , OPENVDS_DOCSTRING(DMSOpenOptions_datasetPath));
DMSOpenOptions_.def_readwrite("logLevel" , &DMSOpenOptions::logLevel , OPENVDS_DOCSTRING(DMSOpenOptions_logLevel));
DMSOpenOptions_.def_readwrite("authTokenUrl" , &DMSOpenOptions::authTokenUrl , OPENVDS_DOCSTRING(DMSOpenOptions_authTokenUrl));
DMSOpenOptions_.def_readwrite("refreshToken" , &DMSOpenOptions::refreshToken , OPENVDS_DOCSTRING(DMSOpenOptions_refreshToken));
DMSOpenOptions_.def_readwrite("clientId" , &DMSOpenOptions::clientId , OPENVDS_DOCSTRING(DMSOpenOptions_clientId));
DMSOpenOptions_.def_readwrite("clientSecret" , &DMSOpenOptions::clientSecret , OPENVDS_DOCSTRING(DMSOpenOptions_clientSecret));
// HttpOpenOptions
py::class_<HttpOpenOptions, OpenOptions>
......@@ -271,6 +277,8 @@ PyGlobal::initModule(py::module& m)
m.def("getLayout" , static_cast<native::VolumeDataLayout *(*)(native::VDSHandle)>(&GetLayout), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetLayout));
m.def("getAccessManagerInterface" , static_cast<native::IVolumeDataAccessManager *(*)(native::VDSHandle)>(&GetAccessManagerInterface), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetAccessManagerInterface));
m.def("getAccessManager" , static_cast<native::VolumeDataAccessManager(*)(native::VDSHandle)>(&GetAccessManager), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetAccessManager));
m.def("getCompressionMethod" , static_cast<native::CompressionMethod(*)(native::VDSHandle)>(&GetCompressionMethod), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetCompressionMethod));
m.def("getCompressionTolerance" , static_cast<float(*)(native::VDSHandle)>(&GetCompressionTolerance), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetCompressionTolerance));
m.def("close" , static_cast<void(*)(native::VDSHandle)>(&Close), py::arg("handle").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(Close));
m.def("getGlobalState" , static_cast<native::GlobalState *(*)()>(&GetGlobalState), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(GetGlobalState));
//AUTOGEN-END
......
......@@ -33,6 +33,7 @@ PyVolumeDataAccessManager::initModule(py::module& m)
IVolumeDataAccessManager_.def("getVolumeDataLayout" , static_cast<const native::VolumeDataLayout *(IVolumeDataAccessManager::*)()>(&IVolumeDataAccessManager::GetVolumeDataLayout), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_GetVolumeDataLayout));
IVolumeDataAccessManager_.def_property_readonly("volumeDataLayout", &IVolumeDataAccessManager::GetVolumeDataLayout, OPENVDS_DOCSTRING(IVolumeDataAccessManager_GetVolumeDataLayout));
IVolumeDataAccessManager_.def("getVDSProduceStatus" , static_cast<native::VDSProduceStatus(IVolumeDataAccessManager::*)(native::DimensionsND, int, int)>(&IVolumeDataAccessManager::GetVDSProduceStatus), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_GetVDSProduceStatus));
IVolumeDataAccessManager_.def("getVDSChunkCount" , static_cast<int64_t(IVolumeDataAccessManager::*)(native::DimensionsND, int, int)>(&IVolumeDataAccessManager::GetVDSChunkCount), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_GetVDSChunkCount));
IVolumeDataAccessManager_.def("createVolumeDataPageAccessor", static_cast<native::VolumeDataPageAccessor *(IVolumeDataAccessManager::*)(native::DimensionsND, int, int, int, VolumeDataPageAccessor::AccessMode, int)>(&IVolumeDataAccessManager::CreateVolumeDataPageAccessor), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::arg("maxPages").none(false), py::arg("accessMode").none(false), py::arg("chunkMetadataPageSize") = 1024, py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_CreateVolumeDataPageAccessor));
IVolumeDataAccessManager_.def("destroyVolumeDataPageAccessor", static_cast<void(IVolumeDataAccessManager::*)(native::VolumeDataPageAccessor *)>(&IVolumeDataAccessManager::DestroyVolumeDataPageAccessor), py::arg("volumeDataPageAccessor").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_DestroyVolumeDataPageAccessor));
IVolumeDataAccessManager_.def("destroyVolumeDataAccessor" , static_cast<void(IVolumeDataAccessManager::*)(native::IVolumeDataAccessor *)>(&IVolumeDataAccessManager::DestroyVolumeDataAccessor), py::arg("accessor").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(IVolumeDataAccessManager_DestroyVolumeDataAccessor));
......@@ -153,6 +154,7 @@ PyVolumeDataAccessManager::initModule(py::module& m)
VolumeDataAccessManager_.def("getVolumeDataLayout" , static_cast<const native::VolumeDataLayout *(VolumeDataAccessManager::*)()>(&VolumeDataAccessManager::GetVolumeDataLayout), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeDataLayout));
VolumeDataAccessManager_.def_property_readonly("volumeDataLayout", &VolumeDataAccessManager::GetVolumeDataLayout, OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeDataLayout));
VolumeDataAccessManager_.def("getVDSProduceStatus" , static_cast<native::VDSProduceStatus(VolumeDataAccessManager::*)(native::DimensionsND, int, int) const>(&VolumeDataAccessManager::GetVDSProduceStatus), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVDSProduceStatus));
VolumeDataAccessManager_.def("getVDSChunkCount" , static_cast<int64_t(VolumeDataAccessManager::*)(native::DimensionsND, int, int) const>(&VolumeDataAccessManager::GetVDSChunkCount), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVDSChunkCount));
VolumeDataAccessManager_.def("createVolumeDataPageAccessor", static_cast<native::VolumeDataPageAccessor *(VolumeDataAccessManager::*)(native::DimensionsND, int, int, int, native::VolumeDataAccessManager::AccessMode, int)>(&VolumeDataAccessManager::CreateVolumeDataPageAccessor), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::arg("maxPages").none(false), py::arg("accessMode").none(false), py::arg("chunkMetadataPageSize") = 1024, py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_CreateVolumeDataPageAccessor));
VolumeDataAccessManager_.def("destroyVolumeDataPageAccessor", static_cast<void(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *)>(&VolumeDataAccessManager::DestroyVolumeDataPageAccessor), py::arg("volumeDataPageAccessor").none(false), py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_DestroyVolumeDataPageAccessor));
VolumeDataAccessManager_.def("createVolumeData2DInterpolatingAccessorR64", static_cast<native::VolumeData2DInterpolatingAccessorR64(VolumeDataAccessManager::*)(native::DimensionsND, int, int, native::InterpolationMethod, int, optional<float>)>(&VolumeDataAccessManager::CreateVolumeData2DInterpolatingAccessorR64), py::arg("dimensionsND").none(false), py::arg("LOD").none(false), py::arg("channel").none(false), py::arg("interpolationMethod").none(false), py::arg("maxPages").none(false), py::arg("replacementNoValue") = nullptr, py::call_guard<py::gil_scoped_release>(), OPENVDS_DOCSTRING(VolumeDataAccessManager_CreateVolumeData2DInterpolatingAccessorR64));
......
......@@ -58,6 +58,8 @@ static const char *__doc_OpenVDS_AWSOpenOptions_bucket = R"doc()doc";
static const char *__doc_OpenVDS_AWSOpenOptions_connectionTimeoutMs = R"doc()doc";
static const char *__doc_OpenVDS_AWSOpenOptions_disableInitApi = R"doc()doc";
static const char *__doc_OpenVDS_AWSOpenOptions_endpointOverride = R"doc()doc";
static const char *__doc_OpenVDS_AWSOpenOptions_expiration = R"doc()doc";
......@@ -674,10 +676,18 @@ static const char *__doc_OpenVDS_DMSOpenOptions_DMSOpenOptions = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_DMSOpenOptions_2 = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_authTokenUrl = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_clientId = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_clientSecret = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_datasetPath = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_logLevel = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_refreshToken = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_sdApiKey = R"doc()doc";
static const char *__doc_OpenVDS_DMSOpenOptions_sdAuthorityUrl = R"doc()doc";
......@@ -806,6 +816,32 @@ Returns:
--------
The VolumeDataAccessManagerInterface of the VDS)doc";
static const char *__doc_OpenVDS_GetCompressionMethod =
R"doc(Get the primary CompressionMethod for a VDS
Parameters:
-----------
handle :
The handle of the VDS
Returns:
--------
The CompressionMethod used for the VDS)doc";
static const char *__doc_OpenVDS_GetCompressionTolerance =
R"doc(Get the primary compression tolerance used for a VDS
Parameters:
-----------
handle :
The handle of the VDS
Returns:
--------
The compression tolerance used for the VDS)doc";
static const char *__doc_OpenVDS_GetGlobalState =
R"doc(Get the GlobalState interface
......@@ -1330,6 +1366,27 @@ Returns:
--------
The buffer size needed.)doc";
static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVDSChunkCount =
R"doc(Get the chunk count for the specific DimensionsND/LOD/Channel
combination.
Parameters:
-----------
dimensionsND :
The dimensions group we're getting the chunk count for.
LOD :
The LOD level we're getting the chunk count status for.
channel :
The channel index we're getting the chunk count status for.
Returns:
--------
The chunk count for the specific DimensionsND/LOD/Channel
combination.)doc";
static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVDSProduceStatus =
R"doc(Get the produce status for the specific DimensionsND/LOD/Channel
combination.
......@@ -1761,6 +1818,10 @@ static const char *__doc_OpenVDS_IndexOutOfRangeException = R"doc()doc";
static const char *__doc_OpenVDS_IndexOutOfRangeException_GetErrorMessage = R"doc()doc";
static const char *__doc_OpenVDS_IndexOutOfRangeException_IndexOutOfRangeException = R"doc()doc";
static const char *__doc_OpenVDS_IndexOutOfRangeException_m_errorMessage = R"doc()doc";
static const char *__doc_OpenVDS_IndexRegion = R"doc()doc";
static const char *__doc_OpenVDS_IndexRegion_IndexRegion = R"doc()doc";
......@@ -2523,6 +2584,8 @@ static const char *__doc_OpenVDS_OpenOptions_ConnectionType_Azure = R"doc()doc";
static const char *__doc_OpenVDS_OpenOptions_ConnectionType_AzurePresigned = R"doc()doc";
static const char *__doc_OpenVDS_OpenOptions_ConnectionType_AzureSdkForCpp = R"doc()doc";
static const char *__doc_OpenVDS_OpenOptions_ConnectionType_ConnectionTypeCount = R"doc()doc";
static const char *__doc_OpenVDS_OpenOptions_ConnectionType_DMS = R"doc()doc";
......@@ -3159,6 +3222,27 @@ Returns:
static const char *__doc_OpenVDS_VolumeDataAccessManager_GetProjectedVolumeSubsetBufferSize_2 = R"doc()doc";
static const char *__doc_OpenVDS_VolumeDataAccessManager_GetVDSChunkCount =
R"doc(Get the chunk count for the specific DimensionsND/LOD/Channel
combination.
Parameters:
-----------
dimensionsND :
The dimensions group we're getting the chunk count for.
LOD :
The LOD level we're getting the chunk count status for.
channel :
The channel index we're getting the chunk count status for.
Returns:
--------
The chunk count for the specific DimensionsND/LOD/Channel
combination.)doc";
static const char *__doc_OpenVDS_VolumeDataAccessManager_GetVDSProduceStatus =
R"doc(Get the produce status for the specific DimensionsND/LOD/Channel
combination.
......
......@@ -44,7 +44,7 @@ set(SOURCE_FILES
VDS/VolumeIndexer.cpp
VDS/Env.cpp
${COMMON_DIR}/Base64/Base64.cpp
)
"IO/IORefreshToken.cpp")
set (PRIVATE_HEADER_FILES
IO/File.h
......@@ -98,7 +98,7 @@ set (PRIVATE_HEADER_FILES
VDS/GlobalStateImpl.h
${COMMON_DIR}/Base64/Base64.h
${COMMON_DIR}/ThreadPool/ThreadPool.h
)
"IO/IORefreshToken.h")
file(GLOB EXPORTED_HEADER_FILES OpenVDS/*.h)
......
......@@ -10,6 +10,9 @@
#endif
#include <SDException.h>
#include "IOManagerCurl.h"
#include "IORefreshToken.h"
namespace OpenVDS
{
GetHeadRequestDms::GetHeadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr<TransferDownloadHandler>& handler)
......@@ -178,6 +181,12 @@ namespace OpenVDS
});
}
std::string IOManagerDms::AuthProviderCallback(const void* data)
{
IOManagerDms* iomanager = static_cast<IOManagerDms*>(const_cast<void*>(data));
return iomanager->m_tokenRefresher->newToken();
}
IOManagerDms::IOManagerDms(const DMSOpenOptions& openOptions, IOManager::AccessPattern accessPatttern, Error& error)
: IOManager(openOptions.connectionType)
, m_opened(false)
......@@ -195,9 +204,23 @@ namespace OpenVDS
m_filename = openOptions.datasetPath.substr(it+1);
}
}
try {
m_sdManager.reset(new seismicdrive::SDManager(openOptions.sdAuthorityUrl, openOptions.sdApiKey, openOptions.logLevel));
m_sdManager->setAuthProviderFromString(openOptions.sdToken);
if (openOptions.authTokenUrl.size() && openOptions.clientId.size() && openOptions.clientSecret.size() && openOptions.refreshToken.size())
{
m_curlHandler.reset(new CurlHandler(error));
if (error.code != 0)
return;
m_tokenRefresher.reset(new TokenRefresher(openOptions.authTokenUrl, openOptions.clientId, openOptions.clientSecret, openOptions.refreshToken, *m_curlHandler, std::function<void(std::string&& new_token)>()));
m_sdManager->setAuthProviderCallback(&AuthProviderCallback, this);
}
else
{
m_sdManager->setAuthProviderFromString(openOptions.sdToken);
}
m_dataset.reset(new seismicdrive::SDGenericDataset(m_sdManager.get(), openOptions.datasetPath, openOptions.logLevel != 0));
seismicdrive::SDDatasetDisposition disposition = seismicdrive::SDDatasetDisposition::READ_ONLY;
......
......@@ -24,6 +24,8 @@
namespace OpenVDS
{
class CurlHandler;
class TokenRefresher;
class GetHeadRequestDms : public RequestImpl
{
public:
......@@ -75,11 +77,14 @@ namespace OpenVDS
std::shared_ptr<Request> WriteObject(const std::string& requestName, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector<std::pair<std::string, std::string>>& metadataHeader, std::shared_ptr<std::vector<uint8_t>> data, std::function<void(const Request& request, const Error& error)> completedCallback = nullptr) override;
private:
static std::string AuthProviderCallback(const void* data);
std::unique_ptr<seismicdrive::SDManager> m_sdManager;
std::unique_ptr<seismicdrive::SDGenericDataset> m_dataset;
std::string m_filename;
bool m_opened;
ThreadPool m_threadPool;
std::unique_ptr<CurlHandler> m_curlHandler;
std::unique_ptr<TokenRefresher> m_tokenRefresher;
};
}
......
#include "IORefreshToken.h"
#include <fmt/format.h>
#include <json/json.h>
namespace OpenVDS
{
TokenRefresher::TokenRefresher(const std::string& authTokenUrl, const std::string &clientId, const std::string &clientSecret, const std::string& refreshToken, CurlHandler& curlHandler, const std::function<void(std::string&& new_token)> &newTokenCallback)
: m_authTokenUrl(authTokenUrl)
, m_clientId(clientId)
, m_clientSecret(clientSecret)
, m_refreshToken(refreshToken)
, m_curlHandler(curlHandler)
, m_newTokenCallback(newTokenCallback)
{
}
std::string TokenRefresher::newToken()
{
std::vector<std::shared_ptr<std::vector<uint8_t>>> data;
data.emplace_back(std::make_shared<std::vector<uint8_t>>());
std::string form = fmt::format("grant_type={}&client_id={}&client_secret={}&refresh_token={}&scope={}", "refresh_token", m_clientId, m_clientSecret, m_refreshToken, "openid email");
data.back()->insert(data.back()->end(), form.begin(), form.end());
std::shared_ptr<UploadRequestCurl> request = std::make_shared<UploadRequestCurl>("refresh_token", std::function<void(const Request& request, const Error& error)>());
std::vector<std::string> headers;
headers.emplace_back("Content-Type: application/x-www-form-urlencoded");
m_curlHandler.addUploadRequest(request, m_authTokenUrl, headers, true, std::move(data), form.size());
Error error;
request->WaitForFinish(error);
if (error.code || !request->m_uploadHandler)
return "";
std::string respons_data;
respons_data.insert(respons_data.end(), request->m_uploadHandler->responsData.begin(), request->m_uploadHandler->responsData.end());
Json::Value value;
if (!Json::Reader().parse(respons_data, value))
{
return "";
}
if (value.isMember("refresh_token"))
{
m_refreshToken = value["refresh_token"].asString();
}
return value["access_token"].asString();
}
}
\ No newline at end of file
#ifndef IOREFRESHTOKEN
#define IOREFRESHTOKEN
#include "IOManagerCurl.h"
#include <string>
#include <functional>
namespace OpenVDS
{
class TokenRefresher
{
public:
TokenRefresher(const std::string& authTokenUrl, const std::string& clientId, const std::string& clientSecret, const std::string& refreshToken, CurlHandler& curlHandler, const std::function<void(std::string&& new_token)>& newTokenCallback);
std::string newToken();
std::string m_authTokenUrl;
std::string m_clientId;
std::string m_clientSecret;
std::string m_refreshToken;
CurlHandler& m_curlHandler;
std::function<void(std::string&& new_token)> m_newTokenCallback;
};
}
#endif
\ No newline at end of file
......@@ -124,19 +124,20 @@ static std::unique_ptr<OpenOptions> createS3OpenOptions(const StringWrapper &url
{
openOptions->region = connectionPair.second;
}
else if (connectionPair.first == "endpointoverride")
else if (connectionPair.first == "endpointoverride" || connectionPair.first == "endpoint_override")
{
openOptions->endpointOverride = connectionPair.second;
}
else if (connectionPair.first == "accesskeyid")
else if (connectionPair.first == "accesskeyid" || connectionPair.first == "access_key_id")
{
openOptions->accessKeyId = connectionPair.second;
}
else if (connectionPair.first == "secretkey")
else if (connectionPair.first == "secretkey" || connectionPair.first == "secretaccesskey"
|| connectionPair.first == "secret_key" || connectionPair.first == "secret_access_key")
{
openOptions->secretKey = connectionPair.second;
}
else if (connectionPair.first == "sessiontoken")
else if (connectionPair.first == "sessiontoken" || connectionPair.first == "session_token")
{
openOptions->sessionToken = connectionPair.second;
}
......@@ -144,15 +145,15 @@ static std::unique_ptr<OpenOptions> createS3OpenOptions(const StringWrapper &url
{
openOptions->expiration = connectionPair.second;
}
else if (connectionPair.first == "logfilenameprefix")
else if (connectionPair.first == "logfilenameprefix" || connectionPair.first == "log_filename_prefix")
{
openOptions->logFilenamePrefix = connectionPair.second;
}
else if (connectionPair.first == "loglevel")
else if (connectionPair.first == "loglevel" || connectionPair.first == "log_level")
{
openOptions->loglevel = connectionPair.second;
}
else if (connectionPair.first == "connectiontimeoutms")
else if (connectionPair.first == "connectiontimeoutms" || connectionPair.first == "connection_timeout_ms")
{
openOptions->connectionTimeoutMs = strtol(&connectionPair.second[0], nullptr, 10);
if (openOptions->connectionTimeoutMs == 0)
......@@ -162,7 +163,7 @@ static std::unique_ptr<OpenOptions> createS3OpenOptions(const StringWrapper &url
return nullptr;
}
}
else if (connectionPair.first == "requesttimeoutms")
else if (connectionPair.first == "requesttimeoutms" || connectionPair.first == "request_timeout_ms")
{
openOptions->requestTimeoutMs = strtol(&connectionPair.second[0], nullptr, 10);
if (openOptions->requestTimeoutMs == 0)
......@@ -172,7 +173,7 @@ static std::unique_ptr<OpenOptions> createS3OpenOptions(const StringWrapper &url
return nullptr;
}
}
else if (connectionPair.first == "disableinitapi")
else if (connectionPair.first == "disableinitapi" || connectionPair.first == "disable_init_api")
{
auto value = connectionPair.second;
std::transform(value.begin(), value.end(), value.begin(), asciitolower);
......@@ -370,14 +371,22 @@ static std::unique_ptr<OpenOptions> createDMSOpenOptions(const StringWrapper& ur
for (auto& connectionPair : connectionStringMap)
{
if (connectionPair.first == "sdauthorityurl")
if (connectionPair.first == "sdauthorityurl" || connectionPair.first == "sd_authority_url")
openOptions->sdAuthorityUrl = connectionPair.second;
if (connectionPair.first == "sdapikey")
if (connectionPair.first == "sdapikey" || connectionPair.first == "sd_api_key")
openOptions->sdApiKey = connectionPair.second;
if (connectionPair.first == "sdtoken")
if (connectionPair.first == "sdtoken" || connectionPair.first == "sd_token")
openOptions->sdToken = connectionPair.second;
if (connectionPair.first == "loglevel")
if (connectionPair.first == "loglevel" || connectionPair.first == "log_level")
openOptions->logLevel = atoi(connectionPair.second.c_str());
if (connectionPair.first == "authtokenurl" || connectionPair.first == "auth_token_url")
openOptions->authTokenUrl = connectionPair.second;
if (connectionPair.first == "refreshtoken" || connectionPair.first == "refresh_token")
openOptions->refreshToken = connectionPair.second;
if (connectionPair.first == "clientid" || connectionPair.first == "client_id")
openOptions->clientId = connectionPair.second;
if (connectionPair.first == "clientsecret" || connectionPair.first == "client_secret")
openOptions->clientSecret = connectionPair.second;
}
return openOptions;
......
......@@ -455,14 +455,19 @@ struct GoogleOpenOptions : OpenOptions
struct DMSOpenOptions : OpenOptions
{
DMSOpenOptions() : OpenOptions(DMS) {}
DMSOpenOptions() : OpenOptions(DMS), logLevel(0) {}
DMSOpenOptions(std::string const& sdAuthorityUrl, std::string const& sdApiKey, std::string const &sdToken, std::string const &datasetPath, int logLevel)
DMSOpenOptions(std::string const& sdAuthorityUrl, std::string const& sdApiKey, std::string const &sdToken, std::string const &datasetPath, int logLevel, std::string const &authTokenUrl = std::string(), std::string const &refreshToken = std::string(), std::string const &clientId = std::string(), std::string const &clientSecret = std::string())
: OpenOptions(DMS)
, sdAuthorityUrl(sdAuthorityUrl)
, sdApiKey(sdApiKey)
, sdToken(sdToken)
, datasetPath(datasetPath)
, logLevel(logLevel)
, authTokenUrl(authTokenUrl)
, refreshToken(refreshToken)
, clientId(clientId)
, clientSecret(clientSecret)
{}
std::string sdAuthorityUrl;
......@@ -470,6 +475,10 @@ struct DMSOpenOptions : OpenOptions
std::string sdToken;
std::string datasetPath;
int logLevel;
std::string authTokenUrl;
std::string refreshToken;
std::string clientId;
std::string clientSecret;
};
/// <summary>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment