@@ -108,12 +108,14 @@ AzureObjectStorage::AzureObjectStorage(
108
108
ClientPtr && client_,
109
109
SettingsPtr && settings_,
110
110
const String & object_namespace_,
111
- const String & description_)
111
+ const String & description_,
112
+ AzureBlobStorage::AuthMethod auth_method_)
112
113
: name(name_)
113
114
, client(std::move(client_))
114
115
, settings(std::move(settings_))
115
116
, object_namespace(object_namespace_)
116
117
, description(description_)
118
+ , auth_method(auth_method_)
117
119
, log(getLogger(" AzureObjectStorage" ))
118
120
{
119
121
}
@@ -154,6 +156,40 @@ ObjectStorageIteratorPtr AzureObjectStorage::iterate(const std::string & path_pr
154
156
return std::make_shared<AzureIteratorAsync>(path_prefix, client_ptr, max_keys ? max_keys : settings_ptr->list_object_keys_size );
155
157
}
156
158
159
+ std::optional<std::string> AzureObjectStorage::getIdentityFingerprint () const
160
+ {
161
+ std::optional<std::string> fingerprint;
162
+
163
+ std::visit ([&fingerprint](const auto & auth) {
164
+ using T = std::decay_t <decltype (auth)>;
165
+
166
+ if constexpr (std::is_same_v<T, AzureBlobStorage::ConnectionString>)
167
+ {
168
+ auto connection_string_parts = Azure::Storage::_internal::ParseConnectionString (auth);
169
+ fingerprint = std::to_string (std::hash<std::string>()(connection_string_parts.AccountName ));
170
+ }
171
+ else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Storage::StorageSharedKeyCredential>>)
172
+ {
173
+ if (auth)
174
+ {
175
+ fingerprint = std::to_string (std::hash<std::string>()(auth->AccountName ));
176
+ }
177
+ }
178
+ // / I am not sure what to do with the other auth methods, needs further investigation
179
+ // else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Identity::WorkloadIdentityCredential>>) {
180
+ // }
181
+ // else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Identity::ManagedIdentityCredential>>) {
182
+ // }
183
+ }, auth_method);
184
+
185
+ if (!fingerprint)
186
+ {
187
+ return std::nullopt ;
188
+ }
189
+
190
+ return getName () + fingerprint.value ();
191
+ }
192
+
157
193
void AzureObjectStorage::listObjects (const std::string & path, RelativePathsWithMetadata & children, size_t max_keys) const
158
194
{
159
195
auto client_ptr = client.get ();
@@ -380,7 +416,7 @@ std::unique_ptr<IObjectStorage> AzureObjectStorage::cloneObjectStorage(
380
416
};
381
417
382
418
auto new_client = AzureBlobStorage::getContainerClient (params, /* readonly=*/ true );
383
- return std::make_unique<AzureObjectStorage>(name, std::move (new_client), std::move (new_settings), new_namespace, params.endpoint .getServiceEndpoint ());
419
+ return std::make_unique<AzureObjectStorage>(name, std::move (new_client), std::move (new_settings), new_namespace, params.endpoint .getServiceEndpoint (), params. auth_method );
384
420
}
385
421
386
422
}
0 commit comments