signer.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // MinIO C++ Library for Amazon S3 Compatible Cloud Storage
  2. // Copyright 2022 MinIO, Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef _MINIO_SIGNER_H
  16. #define _MINIO_SIGNER_H
  17. #include "http.h"
  18. namespace minio {
  19. namespace signer {
  20. std::string GetScope(utils::Time& time, std::string& region,
  21. std::string& service_name);
  22. std::string GetCanonicalRequestHash(std::string& method, std::string& uri,
  23. std::string& query_string,
  24. std::string& headers,
  25. std::string& signed_headers,
  26. std::string& content_sha256);
  27. std::string GetStringToSign(utils::Time& date, std::string& scope,
  28. std::string& canonical_request_hash);
  29. std::string HmacHash(std::string_view key, std::string_view data);
  30. std::string GetSigningKey(std::string& secret_key, utils::Time& date,
  31. std::string_view region,
  32. std::string_view service_name);
  33. std::string GetSignature(std::string_view signing_key,
  34. std::string_view string_to_sign);
  35. std::string GetAuthorization(std::string& access_key, std::string& scope,
  36. std::string& signed_headers,
  37. std::string& signature);
  38. utils::Multimap& SignV4(std::string& service_name, http::Method& method,
  39. std::string& uri, std::string& region,
  40. utils::Multimap& headers, utils::Multimap& query_params,
  41. std::string& access_key, std::string& secret_key,
  42. std::string& content_sha256, utils::Time& date);
  43. utils::Multimap& SignV4S3(http::Method method, std::string& uri,
  44. std::string& region, utils::Multimap& headers,
  45. utils::Multimap query_params, std::string& access_key,
  46. std::string& secret_key, std::string& content_sha256,
  47. utils::Time& date);
  48. utils::Multimap& SignV4STS(http::Method method, std::string& uri,
  49. std::string& region, utils::Multimap& headers,
  50. utils::Multimap query_params,
  51. std::string& access_key, std::string& secret_key,
  52. std::string& content_sha256, utils::Time& date);
  53. utils::Multimap& PresignV4(http::Method method, std::string& host,
  54. std::string& uri, std::string& region,
  55. utils::Multimap& query_params,
  56. std::string& access_key, std::string& secret_key,
  57. utils::Time& date, unsigned int expires);
  58. std::string PostPresignV4(std::string data, std::string& secret_key,
  59. utils::Time& date, std::string& region);
  60. } // namespace signer
  61. } // namespace minio
  62. #endif // #ifndef __MINIO_SIGNER_H