Skip to content

Commit e7fc51a

Browse files
JustinKyleJameskorydraughn
authored andcommitted
[#77] Ran clang format
1 parent 67754ee commit e7fc51a

26 files changed

Lines changed: 2978 additions & 2892 deletions

core/include/irods/private/s3_api/authentication.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111
namespace irods::s3::authentication
1212
{
13-
/// Resolves the hashed signature to an iRODS username.
14-
///
15-
/// \param conn The connection to the iRODS server.
16-
/// \param request The request.
17-
/// \param url The url
18-
///
19-
/// \returns An iRODS username if the signature is correct, else an empty std::optional.
20-
std::optional<std::string> authenticates(
21-
const boost::beast::http::request_parser<boost::beast::http::empty_body>& parser,
22-
const boost::urls::url_view& url);
13+
/// Resolves the hashed signature to an iRODS username.
14+
///
15+
/// \param conn The connection to the iRODS server.
16+
/// \param request The request.
17+
/// \param url The url
18+
///
19+
/// \returns An iRODS username if the signature is correct, else an empty std::optional.
20+
std::optional<std::string> authenticates(
21+
const boost::beast::http::request_parser<boost::beast::http::empty_body>& parser,
22+
const boost::urls::url_view& url);
2323

24-
std::optional<std::string> get_iRODS_user(const std::string_view access_key);
25-
std::optional<std::string> get_user_secret_key(const std::string_view access_key);
24+
std::optional<std::string> get_iRODS_user(const std::string_view access_key);
25+
std::optional<std::string> get_user_secret_key(const std::string_view access_key);
2626

2727
} //namespace irods::s3::authentication
2828
#endif // IRODS_S3_API_AUTHENTICATION_HPP

core/include/irods/private/s3_api/bucket.hpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66

77
namespace irods::s3
88
{
9-
/// Get the base path of the given bucket in the request.
10-
///
11-
/// \param connection The connection to the irods server.
12-
/// \param view The view of the url's segments.
13-
std::optional<irods::experimental::filesystem::path> resolve_bucket(
14-
const boost::urls::segments_view& view);
9+
/// Get the base path of the given bucket in the request.
10+
///
11+
/// \param connection The connection to the irods server.
12+
/// \param view The view of the url's segments.
13+
std::optional<irods::experimental::filesystem::path> resolve_bucket(const boost::urls::segments_view& view);
1514

16-
/// Get the final path of the given bucket in the request.
17-
///
18-
/// \param base The base irods path for the bucket
19-
/// \param view The view of the url's segments.
20-
irods::experimental::filesystem::path finish_path(
21-
const irods::experimental::filesystem::path& base,
22-
const boost::urls::segments_view&);
23-
std::string strip_bucket(const std::string&);
15+
/// Get the final path of the given bucket in the request.
16+
///
17+
/// \param base The base irods path for the bucket
18+
/// \param view The view of the url's segments.
19+
irods::experimental::filesystem::path finish_path(
20+
const irods::experimental::filesystem::path& base,
21+
const boost::urls::segments_view&);
22+
std::string strip_bucket(const std::string&);
2423
} //namespace irods::s3
2524
#endif // IRODS_S3_API_BUCKET_HPP

core/include/irods/private/s3_api/common_routines.hpp

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma clang diagnostic push
88
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
99
#include <fmt/chrono.h>
10-
#pragma clang diagnostic pop
10+
#pragma clang diagnostic pop
1111

1212
#include <boost/uuid/uuid.hpp>
1313
#include <boost/uuid/uuid_generators.hpp>
@@ -20,51 +20,53 @@
2020
#include "irods/private/s3_api/session.hpp"
2121
#include "irods/private/s3_api/common.hpp"
2222

23-
namespace irods::s3::api::common_routines {
23+
namespace irods::s3::api::common_routines
24+
{
2425

25-
inline std::string convert_time_t_to_str(const time_t& t, const std::string_view format) {
26-
return fmt::format(fmt::runtime(format), fmt::localtime(t));
27-
}
26+
inline std::string convert_time_t_to_str(const time_t& t, const std::string_view format)
27+
{
28+
return fmt::format(fmt::runtime(format), fmt::localtime(t));
29+
}
2830

29-
inline void send_error_response(
30-
irods::http::session_pointer_type session_ptr,
31-
const boost::beast::http::status status_code,
32-
const std::string& s3_error_code,
33-
const std::string& message,
34-
const std::string& s3_path,
35-
const std::string& func)
36-
{
37-
boost::beast::http::response<boost::beast::http::string_body> response;
31+
inline void send_error_response(
32+
irods::http::session_pointer_type session_ptr,
33+
const boost::beast::http::status status_code,
34+
const std::string& s3_error_code,
35+
const std::string& message,
36+
const std::string& s3_path,
37+
const std::string& func)
38+
{
39+
boost::beast::http::response<boost::beast::http::string_body> response;
3840

39-
std::string request_id = boost::lexical_cast<std::string>(boost::uuids::random_generator()());
40-
irods::http::logging::error("{}: {} - {}", func, request_id, message);
41-
response.result(status_code);
42-
response.set(boost::beast::http::field::content_type, "text/xml");
41+
std::string request_id = boost::lexical_cast<std::string>(boost::uuids::random_generator()());
42+
irods::http::logging::error("{}: {} - {}", func, request_id, message);
43+
response.result(status_code);
44+
response.set(boost::beast::http::field::content_type, "text/xml");
4345

44-
// build xml response
45-
boost::property_tree::ptree document;
46-
document.add("Error", "");
47-
document.add("Error.Code", s3_error_code.c_str());
48-
document.add("Error.Message", message.c_str());
49-
document.add("Error.Resource", s3_path.c_str());
50-
document.add("Error.RequestId", request_id.c_str());
46+
// build xml response
47+
boost::property_tree::ptree document;
48+
document.add("Error", "");
49+
document.add("Error.Code", s3_error_code.c_str());
50+
document.add("Error.Message", message.c_str());
51+
document.add("Error.Resource", s3_path.c_str());
52+
document.add("Error.RequestId", request_id.c_str());
5153

52-
// add the xml to the response object
53-
std::stringstream s;
54-
boost::property_tree::xml_parser::xml_writer_settings<std::string> settings;
55-
settings.indent_char = ' ';
56-
settings.indent_count = 4;
57-
boost::property_tree::write_xml(s, document, settings);
58-
response.body() = s.str();
54+
// add the xml to the response object
55+
std::stringstream s;
56+
boost::property_tree::xml_parser::xml_writer_settings<std::string> settings;
57+
settings.indent_char = ' ';
58+
settings.indent_count = 4;
59+
boost::property_tree::write_xml(s, document, settings);
60+
response.body() = s.str();
5961

60-
response.prepare_payload();
62+
response.prepare_payload();
6163

62-
// log and send the response
63-
irods::http::logging::debug("{}: {} - returned {}", func, request_id, response.reason());
64-
irods::http::logging::debug("{}: {} - response xml\n{}", func, request_id, response.body());
65-
session_ptr->send(std::move(response));
66-
return;
67-
}
68-
}
64+
// log and send the response
65+
irods::http::logging::debug("{}: {} - returned {}", func, request_id, response.reason());
66+
irods::http::logging::debug("{}: {} - response xml\n{}", func, request_id, response.body());
67+
session_ptr->send(std::move(response));
68+
return;
69+
}
70+
} //namespace irods::s3::api::common_routines
6971

7072
#endif // IRODS_S3_API_COMMON_ROUTINES_HPP

core/include/irods/private/s3_api/configuration.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace irods::s3
77
{
8-
void set_resource(const std::string_view&);
9-
std::string get_resource();
8+
void set_resource(const std::string_view&);
9+
std::string get_resource();
1010

11-
uint64_t get_put_object_buffer_size_in_bytes();
12-
uint64_t get_get_object_buffer_size_in_bytes();
11+
uint64_t get_put_object_buffer_size_in_bytes();
12+
uint64_t get_get_object_buffer_size_in_bytes();
1313

14-
std::string get_s3_region();
14+
std::string get_s3_region();
1515

1616
} //namespace irods::s3
1717

core/include/irods/private/s3_api/connection.hpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@
1212

1313
namespace irods::s3
1414
{
15-
namespace __detail
16-
{
17-
struct rcComm_Deleter
18-
{
19-
rcComm_Deleter() = default;
20-
constexpr void operator()(rcComm_t* conn) const noexcept
21-
{
22-
if (conn == nullptr) {
23-
return;
24-
}
25-
rcDisconnect(conn);
26-
}
27-
};
28-
} //namespace __detail
15+
namespace __detail
16+
{
17+
struct rcComm_Deleter
18+
{
19+
rcComm_Deleter() = default;
20+
constexpr void operator()(rcComm_t* conn) const noexcept
21+
{
22+
if (conn == nullptr) {
23+
return;
24+
}
25+
rcDisconnect(conn);
26+
}
27+
};
28+
} //namespace __detail
2929

30-
using connection_handle = std::unique_ptr<rcComm_t, __detail::rcComm_Deleter>;
30+
using connection_handle = std::unique_ptr<rcComm_t, __detail::rcComm_Deleter>;
3131

32-
std::unique_ptr<rcComm_t, __detail::rcComm_Deleter> get_connection(const std::optional<std::string>& _client_username = std::nullopt);
32+
std::unique_ptr<rcComm_t, __detail::rcComm_Deleter> get_connection(
33+
const std::optional<std::string>& _client_username = std::nullopt);
3334
} //namespace irods::s3
3435
#endif // IRODS_S3_API_CONNECTION_HPP

core/include/irods/private/s3_api/hmac.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
namespace irods::s3::authentication
88
{
9-
/// Produce a hmac_sha_256 signature
10-
/// @param key The key
11-
/// @param data The data
12-
/// @returns the signature
13-
std::string hmac_sha_256(const std::string_view& key, const std::string_view& data);
9+
/// Produce a hmac_sha_256 signature
10+
/// @param key The key
11+
/// @param data The data
12+
/// @returns the signature
13+
std::string hmac_sha_256(const std::string_view& key, const std::string_view& data);
1414

15-
/// Produce a sha256 hash
16-
/// @param data The range of bytes to hash.
17-
/// @returns The hash
18-
std::string hash_sha_256(const std::string_view& data);
15+
/// Produce a sha256 hash
16+
/// @param data The range of bytes to hash.
17+
/// @returns The hash
18+
std::string hash_sha_256(const std::string_view& data);
1919

20-
/// Encode a string view in hexadecimal.
21-
/// @param data the data to convert to string
22-
std::string hex_encode(const std::string_view& data);
20+
/// Encode a string view in hexadecimal.
21+
/// @param data the data to convert to string
22+
std::string hex_encode(const std::string_view& data);
2323
} //namespace irods::s3::authentication
2424
#endif // IRODS_S3_API_HMAC_HPP

core/include/irods/private/s3_api/session.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ namespace irods::http
5656
stream_, *sp, boost::beast::bind_front_handler(&session::on_write, shared_from_this(), sp->need_eof()));
5757
} // send
5858

59-
boost::beast::flat_buffer& get_buffer()
60-
{
61-
return buffer_;
62-
}
59+
boost::beast::flat_buffer& get_buffer()
60+
{
61+
return buffer_;
62+
}
6363

6464
private:
6565
boost::beast::tcp_stream stream_;

core/src/auth_plugin.cpp

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,46 @@
1010

1111
namespace
1212
{
13-
struct user
14-
{
15-
std::string irods_username;
16-
std::string secret_key;
17-
};
18-
std::optional<std::unordered_map<std::string_view, user>> users;
13+
struct user
14+
{
15+
std::string irods_username;
16+
std::string secret_key;
17+
};
18+
std::optional<std::unordered_map<std::string_view, user>> users;
1919
} //namespace
2020

2121
std::optional<std::string> irods::s3::authentication::get_iRODS_user(const std::string_view access_key)
2222
{
23-
if (!users.has_value()) {
24-
const nlohmann::json& config = irods::http::globals::configuration();
25-
users.emplace();
26-
for (const auto& [s3_access_key, user_info] : config["s3_server"]["plugins"]["static_authentication_resolver"]["users"].items()) {
27-
(*users)[s3_access_key] = user{user_info["username"], user_info["secret_key"]};
28-
}
29-
}
23+
if (!users.has_value()) {
24+
const nlohmann::json& config = irods::http::globals::configuration();
25+
users.emplace();
26+
for (const auto& [s3_access_key, user_info] :
27+
config["s3_server"]["plugins"]["static_authentication_resolver"]["users"].items())
28+
{
29+
(*users)[s3_access_key] = user{user_info["username"], user_info["secret_key"]};
30+
}
31+
}
3032

31-
if (users->contains(access_key)) {
32-
return (*users)[access_key].irods_username;
33-
}
34-
return std::nullopt;
33+
if (users->contains(access_key)) {
34+
return (*users)[access_key].irods_username;
35+
}
36+
return std::nullopt;
3537
}
3638

3739
std::optional<std::string> irods::s3::authentication::get_user_secret_key(const std::string_view access_key)
3840
{
39-
if (!users.has_value()) {
40-
const nlohmann::json& config = irods::http::globals::configuration();
41-
users.emplace();
42-
for (const auto& [s3_access_key, user_info] : config["s3_server"]["plugins"]["static_authentication_resolver"]["users"].items()) {
43-
(*users)[s3_access_key] = user{user_info["username"], user_info["secret_key"]};
44-
}
45-
}
41+
if (!users.has_value()) {
42+
const nlohmann::json& config = irods::http::globals::configuration();
43+
users.emplace();
44+
for (const auto& [s3_access_key, user_info] :
45+
config["s3_server"]["plugins"]["static_authentication_resolver"]["users"].items())
46+
{
47+
(*users)[s3_access_key] = user{user_info["username"], user_info["secret_key"]};
48+
}
49+
}
4650

47-
if (users->contains(access_key)) {
48-
return (*users)[access_key].secret_key;
49-
}
50-
return std::nullopt;
51+
if (users->contains(access_key)) {
52+
return (*users)[access_key].secret_key;
53+
}
54+
return std::nullopt;
5155
}

0 commit comments

Comments
 (0)