SteNicholas commented on code in PR #274: URL: https://github.com/apache/paimon-cpp/pull/274#discussion_r4036417352
########## src/paimon/rest/rest_token_file_system.cpp: ########## @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "paimon/rest/rest_token_file_system.h" + +#include <utility> + +#include "paimon/core/core_options.h" + +namespace paimon { + +std::shared_ptr<RestTokenFileSystemCache> RestTokenFileSystem::CreateFileSystemCache() { + RestTokenFileSystemCache::Options cache_options; + cache_options.max_weight = kMaxCachedFileSystems; + cache_options.expire_after_access_ms = kFileSystemCacheExpireAfterAccessMillis; + return std::make_shared<RestTokenFileSystemCache>(std::move(cache_options)); +} + +RestTokenFileSystem::RestTokenFileSystem(const std::shared_ptr<RestApi>& api, + const std::map<std::string, std::string>& catalog_options, + const Identifier& identifier, + std::shared_ptr<RestTokenFileSystemCache> fs_cache, + Clock clock) + : catalog_options_(catalog_options), + identifier_(identifier), + fs_cache_(fs_cache != nullptr ? std::move(fs_cache) : CreateFileSystemCache()), + provider_(std::make_shared<RestCredentialProvider>(api, catalog_options, identifier, + std::move(clock))) {} + +Result<std::shared_ptr<FileSystem>> RestTokenFileSystem::BuildFileSystem( + const RestToken& token) const { + std::map<std::string, std::string> fs_options = catalog_options_; + for (const auto& [key, value] : token.token) { + fs_options[key] = value; + } Review Comment: **Prevent bucket credentials from overriding the issued token**. This merge only replaces identically named keys. For an OSS catalog configured with `fs.oss.bucket.b.accessKeyId`/`accessKeySecret`, a token containing `fs.oss.accessKeyId`/`accessKeySecret`/`securityToken` leaves the bucket keys intact. `OssFileSystemFactory::FindOption()` prefers those bucket keys, so access to `oss://b/...` is signed with the old catalog key pair and the new STS token, which is an invalid credential combination; if a bucket-scoped security token is configured too, the issued credentials are ignored entirely. Please ensure the issued credentials take precedence after bucket-option resolution, and add coverage with bucket-scoped catalog credentials. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
