snowflake-connector-python 4.4.0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. snowflake/connector/__init__.py +118 -0
  2. snowflake/connector/_query_context_cache.py +276 -0
  3. snowflake/connector/_sql_util.py +48 -0
  4. snowflake/connector/_utils.py +353 -0
  5. snowflake/connector/aio/README.md +88 -0
  6. snowflake/connector/aio/__init__.py +163 -0
  7. snowflake/connector/aio/_azure_storage_client.py +227 -0
  8. snowflake/connector/aio/_bind_upload_agent.py +69 -0
  9. snowflake/connector/aio/_connection.py +1216 -0
  10. snowflake/connector/aio/_cursor.py +1402 -0
  11. snowflake/connector/aio/_description.py +5 -0
  12. snowflake/connector/aio/_direct_file_operation_utils.py +88 -0
  13. snowflake/connector/aio/_file_transfer_agent.py +316 -0
  14. snowflake/connector/aio/_gcs_storage_client.py +360 -0
  15. snowflake/connector/aio/_network.py +860 -0
  16. snowflake/connector/aio/_ocsp_asn1crypto.py +51 -0
  17. snowflake/connector/aio/_ocsp_snowflake.py +608 -0
  18. snowflake/connector/aio/_pandas_tools.py +561 -0
  19. snowflake/connector/aio/_result_batch.py +442 -0
  20. snowflake/connector/aio/_result_set.py +309 -0
  21. snowflake/connector/aio/_s3_storage_client.py +460 -0
  22. snowflake/connector/aio/_session_manager.py +588 -0
  23. snowflake/connector/aio/_storage_client.py +331 -0
  24. snowflake/connector/aio/_telemetry.py +97 -0
  25. snowflake/connector/aio/_time_util.py +57 -0
  26. snowflake/connector/aio/_wif_util.py +324 -0
  27. snowflake/connector/aio/auth/__init__.py +52 -0
  28. snowflake/connector/aio/auth/_auth.py +406 -0
  29. snowflake/connector/aio/auth/_by_plugin.py +131 -0
  30. snowflake/connector/aio/auth/_default.py +28 -0
  31. snowflake/connector/aio/auth/_idtoken.py +54 -0
  32. snowflake/connector/aio/auth/_keypair.py +60 -0
  33. snowflake/connector/aio/auth/_no_auth.py +31 -0
  34. snowflake/connector/aio/auth/_oauth.py +27 -0
  35. snowflake/connector/aio/auth/_oauth_code.py +117 -0
  36. snowflake/connector/aio/auth/_oauth_credentials.py +100 -0
  37. snowflake/connector/aio/auth/_okta.py +247 -0
  38. snowflake/connector/aio/auth/_pat.py +27 -0
  39. snowflake/connector/aio/auth/_usrpwdmfa.py +30 -0
  40. snowflake/connector/aio/auth/_webbrowser.py +405 -0
  41. snowflake/connector/aio/auth/_workload_identity.py +60 -0
  42. snowflake/connector/arrow_context.py +211 -0
  43. snowflake/connector/auth/__init__.py +53 -0
  44. snowflake/connector/auth/_auth.py +669 -0
  45. snowflake/connector/auth/_http_server.py +257 -0
  46. snowflake/connector/auth/_oauth_base.py +472 -0
  47. snowflake/connector/auth/by_plugin.py +219 -0
  48. snowflake/connector/auth/default.py +36 -0
  49. snowflake/connector/auth/idtoken.py +72 -0
  50. snowflake/connector/auth/keypair.py +225 -0
  51. snowflake/connector/auth/no_auth.py +39 -0
  52. snowflake/connector/auth/oauth.py +49 -0
  53. snowflake/connector/auth/oauth_code.py +490 -0
  54. snowflake/connector/auth/oauth_credentials.py +71 -0
  55. snowflake/connector/auth/okta.py +339 -0
  56. snowflake/connector/auth/pat.py +40 -0
  57. snowflake/connector/auth/usrpwdmfa.py +69 -0
  58. snowflake/connector/auth/webbrowser.py +514 -0
  59. snowflake/connector/auth/workload_identity.py +110 -0
  60. snowflake/connector/azure_storage_client.py +278 -0
  61. snowflake/connector/backoff_policies.py +141 -0
  62. snowflake/connector/bind_upload_agent.py +89 -0
  63. snowflake/connector/cache.py +696 -0
  64. snowflake/connector/compat.py +127 -0
  65. snowflake/connector/config_manager.py +553 -0
  66. snowflake/connector/connection.py +2671 -0
  67. snowflake/connector/connection_diagnostic.py +793 -0
  68. snowflake/connector/constants.py +460 -0
  69. snowflake/connector/converter.py +809 -0
  70. snowflake/connector/converter_issue23517.py +87 -0
  71. snowflake/connector/converter_null.py +14 -0
  72. snowflake/connector/converter_snowsql.py +205 -0
  73. snowflake/connector/crl.py +919 -0
  74. snowflake/connector/crl_cache.py +734 -0
  75. snowflake/connector/cursor.py +2099 -0
  76. snowflake/connector/dbapi.py +53 -0
  77. snowflake/connector/description.py +21 -0
  78. snowflake/connector/direct_file_operation_utils.py +88 -0
  79. snowflake/connector/encryption_util.py +220 -0
  80. snowflake/connector/errorcode.py +94 -0
  81. snowflake/connector/errors.py +666 -0
  82. snowflake/connector/externals_utils/__init__.py +0 -0
  83. snowflake/connector/externals_utils/externals_setup.py +30 -0
  84. snowflake/connector/feature.py +4 -0
  85. snowflake/connector/file_compression_type.py +118 -0
  86. snowflake/connector/file_lock.py +72 -0
  87. snowflake/connector/file_transfer_agent.py +1244 -0
  88. snowflake/connector/file_util.py +153 -0
  89. snowflake/connector/gcs_storage_client.py +476 -0
  90. snowflake/connector/gzip_decoder.py +85 -0
  91. snowflake/connector/interval_util.py +26 -0
  92. snowflake/connector/local_storage_client.py +90 -0
  93. snowflake/connector/log_configuration.py +62 -0
  94. snowflake/connector/logging_utils/__init__.py +0 -0
  95. snowflake/connector/logging_utils/filters.py +72 -0
  96. snowflake/connector/minicore/__init__.py +0 -0
  97. snowflake/connector/minicore/aix_ppc64/libsf_mini_core.a +0 -0
  98. snowflake/connector/minicore/aix_ppc64/libsf_mini_core_static.a +0 -0
  99. snowflake/connector/minicore/linux_aarch64_glibc/libsf_mini_core.so +0 -0
  100. snowflake/connector/minicore/linux_aarch64_musl/libsf_mini_core.so +0 -0
  101. snowflake/connector/minicore/linux_x86_64_glibc/libsf_mini_core.so +0 -0
  102. snowflake/connector/minicore/linux_x86_64_musl/libsf_mini_core.so +0 -0
  103. snowflake/connector/minicore/macos_aarch64/libsf_mini_core.dylib +0 -0
  104. snowflake/connector/minicore/macos_x86_64/libsf_mini_core.dylib +0 -0
  105. snowflake/connector/minicore/windows_x86_64/sf_mini_core.dll +0 -0
  106. snowflake/connector/minicore/windows_x86_64/sf_mini_core_static.lib +0 -0
  107. snowflake/connector/nanoarrow_arrow_iterator.cp314-win_amd64.pyd +0 -0
  108. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
  109. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  110. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
  111. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  112. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  113. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  114. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +570 -0
  115. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
  116. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
  117. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
  118. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1140 -0
  119. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +138 -0
  120. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
  121. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  122. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
  123. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  124. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
  125. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
  126. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
  127. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  128. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
  129. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  130. snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  131. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  132. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
  133. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +75 -0
  134. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +57 -0
  135. snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  136. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
  137. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  138. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
  139. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  140. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  141. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
  142. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
  143. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
  144. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
  145. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  146. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
  147. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  148. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
  149. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  150. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
  151. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
  152. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  153. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +67 -0
  154. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  155. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
  156. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
  157. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  158. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
  159. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
  160. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
  161. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  162. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
  163. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
  164. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  165. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  166. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  167. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
  168. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
  169. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
  170. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  171. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
  172. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
  173. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
  174. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  175. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  176. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
  177. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
  178. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  179. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  180. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  181. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  182. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  183. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
  184. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
  185. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
  186. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  187. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  188. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
  189. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
  190. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
  191. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
  192. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +262 -0
  193. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
  194. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
  195. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
  196. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
  197. snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
  198. snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
  199. snowflake/connector/network.py +1227 -0
  200. snowflake/connector/ocsp_asn1crypto.py +447 -0
  201. snowflake/connector/ocsp_snowflake.py +1939 -0
  202. snowflake/connector/options.py +179 -0
  203. snowflake/connector/os_details.py +88 -0
  204. snowflake/connector/pandas_tools.py +734 -0
  205. snowflake/connector/platform_detection.py +555 -0
  206. snowflake/connector/proxy.py +28 -0
  207. snowflake/connector/py.typed +0 -0
  208. snowflake/connector/result_batch.py +917 -0
  209. snowflake/connector/result_set.py +340 -0
  210. snowflake/connector/s3_storage_client.py +614 -0
  211. snowflake/connector/secret_detector.py +181 -0
  212. snowflake/connector/session_manager.py +650 -0
  213. snowflake/connector/sf_dirs.py +64 -0
  214. snowflake/connector/sfbinaryformat.py +35 -0
  215. snowflake/connector/sfdatetime.py +345 -0
  216. snowflake/connector/snow_logging.py +144 -0
  217. snowflake/connector/sqlstate.py +9 -0
  218. snowflake/connector/ssd_internal_keys.py +30 -0
  219. snowflake/connector/ssl_wrap_socket.py +281 -0
  220. snowflake/connector/storage_client.py +486 -0
  221. snowflake/connector/telemetry.py +254 -0
  222. snowflake/connector/telemetry_oob.py +544 -0
  223. snowflake/connector/test_util.py +30 -0
  224. snowflake/connector/time_util.py +159 -0
  225. snowflake/connector/token_cache.py +457 -0
  226. snowflake/connector/tool/__init__.py +0 -0
  227. snowflake/connector/tool/dump_certs.py +57 -0
  228. snowflake/connector/tool/dump_ocsp_response.py +139 -0
  229. snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
  230. snowflake/connector/tool/probe_connection.py +69 -0
  231. snowflake/connector/url_util.py +55 -0
  232. snowflake/connector/util_text.py +320 -0
  233. snowflake/connector/vendored/__init__.py +3 -0
  234. snowflake/connector/vendored/requests/LICENSE +175 -0
  235. snowflake/connector/vendored/requests/__init__.py +184 -0
  236. snowflake/connector/vendored/requests/__version__.py +14 -0
  237. snowflake/connector/vendored/requests/_internal_utils.py +50 -0
  238. snowflake/connector/vendored/requests/adapters.py +696 -0
  239. snowflake/connector/vendored/requests/api.py +157 -0
  240. snowflake/connector/vendored/requests/auth.py +314 -0
  241. snowflake/connector/vendored/requests/certs.py +17 -0
  242. snowflake/connector/vendored/requests/compat.py +106 -0
  243. snowflake/connector/vendored/requests/cookies.py +561 -0
  244. snowflake/connector/vendored/requests/exceptions.py +151 -0
  245. snowflake/connector/vendored/requests/help.py +134 -0
  246. snowflake/connector/vendored/requests/hooks.py +33 -0
  247. snowflake/connector/vendored/requests/models.py +1039 -0
  248. snowflake/connector/vendored/requests/packages.py +23 -0
  249. snowflake/connector/vendored/requests/sessions.py +831 -0
  250. snowflake/connector/vendored/requests/status_codes.py +128 -0
  251. snowflake/connector/vendored/requests/structures.py +99 -0
  252. snowflake/connector/vendored/requests/utils.py +1086 -0
  253. snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
  254. snowflake/connector/vendored/urllib3/__init__.py +211 -0
  255. snowflake/connector/vendored/urllib3/_base_connection.py +165 -0
  256. snowflake/connector/vendored/urllib3/_collections.py +487 -0
  257. snowflake/connector/vendored/urllib3/_request_methods.py +278 -0
  258. snowflake/connector/vendored/urllib3/_version.py +34 -0
  259. snowflake/connector/vendored/urllib3/connection.py +1108 -0
  260. snowflake/connector/vendored/urllib3/connectionpool.py +1178 -0
  261. snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
  262. snowflake/connector/vendored/urllib3/contrib/emscripten/__init__.py +17 -0
  263. snowflake/connector/vendored/urllib3/contrib/emscripten/connection.py +260 -0
  264. snowflake/connector/vendored/urllib3/contrib/emscripten/emscripten_fetch_worker.js +110 -0
  265. snowflake/connector/vendored/urllib3/contrib/emscripten/fetch.py +726 -0
  266. snowflake/connector/vendored/urllib3/contrib/emscripten/request.py +22 -0
  267. snowflake/connector/vendored/urllib3/contrib/emscripten/response.py +277 -0
  268. snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +564 -0
  269. snowflake/connector/vendored/urllib3/contrib/socks.py +228 -0
  270. snowflake/connector/vendored/urllib3/exceptions.py +335 -0
  271. snowflake/connector/vendored/urllib3/fields.py +341 -0
  272. snowflake/connector/vendored/urllib3/filepost.py +89 -0
  273. snowflake/connector/vendored/urllib3/http2/__init__.py +53 -0
  274. snowflake/connector/vendored/urllib3/http2/connection.py +356 -0
  275. snowflake/connector/vendored/urllib3/http2/probe.py +87 -0
  276. snowflake/connector/vendored/urllib3/poolmanager.py +651 -0
  277. snowflake/connector/vendored/urllib3/py.typed +2 -0
  278. snowflake/connector/vendored/urllib3/response.py +1480 -0
  279. snowflake/connector/vendored/urllib3/util/__init__.py +42 -0
  280. snowflake/connector/vendored/urllib3/util/connection.py +137 -0
  281. snowflake/connector/vendored/urllib3/util/proxy.py +43 -0
  282. snowflake/connector/vendored/urllib3/util/request.py +263 -0
  283. snowflake/connector/vendored/urllib3/util/response.py +101 -0
  284. snowflake/connector/vendored/urllib3/util/retry.py +549 -0
  285. snowflake/connector/vendored/urllib3/util/ssl_.py +527 -0
  286. snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
  287. snowflake/connector/vendored/urllib3/util/ssltransport.py +271 -0
  288. snowflake/connector/vendored/urllib3/util/timeout.py +275 -0
  289. snowflake/connector/vendored/urllib3/util/url.py +469 -0
  290. snowflake/connector/vendored/urllib3/util/util.py +42 -0
  291. snowflake/connector/vendored/urllib3/util/wait.py +124 -0
  292. snowflake/connector/version.py +3 -0
  293. snowflake/connector/wif_util.py +434 -0
  294. snowflake_connector_python-4.4.0.dist-info/DELVEWHEEL +2 -0
  295. snowflake_connector_python-4.4.0.dist-info/METADATA +1591 -0
  296. snowflake_connector_python-4.4.0.dist-info/RECORD +302 -0
  297. snowflake_connector_python-4.4.0.dist-info/WHEEL +5 -0
  298. snowflake_connector_python-4.4.0.dist-info/entry_points.txt +4 -0
  299. snowflake_connector_python-4.4.0.dist-info/licenses/LICENSE.txt +202 -0
  300. snowflake_connector_python-4.4.0.dist-info/licenses/NOTICE +8 -0
  301. snowflake_connector_python-4.4.0.dist-info/top_level.txt +1 -0
  302. snowflake_connector_python.libs/msvcp140-0f885b509a685d2bbfa652fed26b5fb3.dll +0 -0
@@ -0,0 +1,434 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import logging
5
+ import os
6
+ from base64 import b64encode
7
+ from dataclasses import dataclass
8
+ from enum import Enum, unique
9
+
10
+ import jwt
11
+
12
+ from .options import boto3, botocore, installed_boto
13
+
14
+ if installed_boto:
15
+ SigV4Auth = botocore.auth.SigV4Auth
16
+ AWSRequest = botocore.awsrequest.AWSRequest
17
+ InstanceMetadataRegionFetcher = botocore.utils.InstanceMetadataRegionFetcher
18
+
19
+ from .errorcode import ER_INVALID_WIF_SETTINGS, ER_WIF_CREDENTIALS_NOT_FOUND
20
+ from .errors import MissingDependencyError, ProgrammingError
21
+ from .session_manager import SessionManager, SessionManagerFactory
22
+
23
+ logger = logging.getLogger(__name__)
24
+ SNOWFLAKE_AUDIENCE = "snowflakecomputing.com"
25
+ DEFAULT_ENTRA_SNOWFLAKE_RESOURCE = "api://fd3f753b-eed3-462c-b6a7-a4b5bb650aad"
26
+ GCP_METADATA_SERVICE_ACCOUNT_BASE_URL = (
27
+ "http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default"
28
+ )
29
+
30
+
31
+ @unique
32
+ class AttestationProvider(Enum):
33
+ """A WIF provider implementation that can produce an attestation."""
34
+
35
+ AWS = "AWS"
36
+ """Provider that builds an encoded pre-signed GetCallerIdentity request using the current workload's IAM role."""
37
+ AZURE = "AZURE"
38
+ """Provider that requests an OAuth access token for the workload's managed identity."""
39
+ GCP = "GCP"
40
+ """Provider that requests an ID token for the workload's attached service account."""
41
+ OIDC = "OIDC"
42
+ """Provider that looks for an OIDC ID token."""
43
+
44
+ @staticmethod
45
+ def from_string(provider: str) -> AttestationProvider:
46
+ """Converts a string to a strongly-typed enum value of AttestationProvider."""
47
+ try:
48
+ return AttestationProvider[provider.upper()]
49
+ except KeyError:
50
+ raise ProgrammingError(
51
+ msg=f"Unknown workload_identity_provider: '{provider}'. Expected one of: {', '.join(AttestationProvider.all_string_values())}",
52
+ errno=ER_INVALID_WIF_SETTINGS,
53
+ )
54
+
55
+ @staticmethod
56
+ def all_string_values() -> list[str]:
57
+ """Returns a list of all string values of the AttestationProvider enum."""
58
+ return [provider.value for provider in AttestationProvider]
59
+
60
+
61
+ @dataclass
62
+ class WorkloadIdentityAttestation:
63
+ provider: AttestationProvider
64
+ credential: str
65
+ user_identifier_components: dict
66
+
67
+
68
+ def extract_iss_and_sub_without_signature_verification(jwt_str: str) -> tuple[str, str]:
69
+ """Extracts the 'iss' and 'sub' claims from the given JWT, without verifying the signature.
70
+
71
+ Note: the real token verification (including signature verification) happens on the Snowflake side. The driver doesn't have
72
+ the keys to verify these JWTs, and in any case that's not where the security boundary is drawn.
73
+
74
+ We only decode the JWT here to get some basic claims, which will be used for a) a quick smoke test to ensure the token is well-formed,
75
+ and b) to find the unique user being asserted and populate assertion_content. The latter may be used for logging
76
+ and possibly caching.
77
+
78
+ Any errors during token parsing will be bubbled up. Missing 'iss' or 'sub' claims will also raise an error.
79
+ """
80
+ try:
81
+ claims = jwt.decode(jwt_str, options={"verify_signature": False})
82
+ except jwt.InvalidTokenError as e:
83
+ raise ProgrammingError(
84
+ msg=f"Invalid JWT token: {e}",
85
+ errno=ER_INVALID_WIF_SETTINGS,
86
+ )
87
+
88
+ if not ("iss" in claims and "sub" in claims):
89
+ raise ProgrammingError(
90
+ msg="Token is missing 'iss' or 'sub' claims.",
91
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
92
+ )
93
+
94
+ return claims["iss"], claims["sub"]
95
+
96
+
97
+ def get_aws_region() -> str:
98
+ """Get the current AWS workload's region, or raises an error if it's missing."""
99
+
100
+ region = os.environ.get("AWS_REGION") or os.environ.get("AWS_DEFAULT_REGION")
101
+
102
+ if not region:
103
+ # Fallback for EC2 environments
104
+ # TODO: SNOW-2223669 Investigate if our adapters - containing settings of http traffic - should be passed here as boto urllib3session. Those requests go to local servers, so they do not need Proxy setup or Headers customization in theory. But we may want to have all the traffic going through one class (e.g. Adapter or mixin).
105
+ region = InstanceMetadataRegionFetcher().retrieve_region()
106
+
107
+ if not region:
108
+ raise ProgrammingError(
109
+ msg="No AWS region was found. Ensure the application is running on AWS.",
110
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
111
+ )
112
+
113
+ return region
114
+
115
+
116
+ def get_aws_sts_hostname(region: str, partition: str) -> str:
117
+ """Constructs the AWS STS hostname for a given region and partition.
118
+
119
+ Args:
120
+ region (str): The AWS region (e.g., 'us-east-1', 'cn-north-1').
121
+ partition (str): The AWS partition (e.g., 'aws', 'aws-cn', 'aws-us-gov').
122
+
123
+ Returns:
124
+ str: The AWS STS hostname (e.g., 'sts.us-east-1.amazonaws.com')
125
+ if a valid hostname can be constructed, otherwise raises a ProgrammingError.
126
+
127
+ References:
128
+ - https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html
129
+ - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_region-endpoints.html
130
+ - https://docs.aws.amazon.com/general/latest/gr/sts.html
131
+ """
132
+ if partition == "aws":
133
+ # For the 'aws' partition, STS endpoints are generally regional
134
+ # except for the global endpoint (sts.amazonaws.com) which is
135
+ # generally resolved to us-east-1 under the hood by the SDKs
136
+ # when a region is not explicitly specified.
137
+ # However, for explicit regional endpoints, the format is sts.<region>.amazonaws.com
138
+ return f"sts.{region}.amazonaws.com"
139
+ elif partition == "aws-cn":
140
+ # China regions have a different domain suffix
141
+ return f"sts.{region}.amazonaws.com.cn"
142
+ elif partition == "aws-us-gov":
143
+ return (
144
+ f"sts.{region}.amazonaws.com" # GovCloud uses .com, but dedicated regions
145
+ )
146
+ else:
147
+ raise ProgrammingError(
148
+ msg=f"Invalid AWS partition: '{partition}'.",
149
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
150
+ )
151
+
152
+
153
+ def get_aws_session(impersonation_path: list[str] | None = None):
154
+ """Creates a boto3 session with the appropriate credentials.
155
+
156
+ If impersonation_path is provided, this uses the role at the end of the path. Otherwise, this uses the role attached to the current workload.
157
+ """
158
+ session = boto3.session.Session()
159
+
160
+ impersonation_path = impersonation_path or []
161
+ for arn in impersonation_path:
162
+ response = session.client("sts").assume_role(
163
+ RoleArn=arn, RoleSessionName="identity-federation-session"
164
+ )
165
+ creds = response["Credentials"]
166
+ session = boto3.session.Session(
167
+ aws_access_key_id=creds["AccessKeyId"],
168
+ aws_secret_access_key=creds["SecretAccessKey"],
169
+ aws_session_token=creds["SessionToken"],
170
+ )
171
+ return session
172
+
173
+
174
+ def create_aws_attestation(
175
+ impersonation_path: list[str] | None = None,
176
+ ) -> WorkloadIdentityAttestation:
177
+ """Tries to create a workload identity attestation for AWS.
178
+
179
+ If the application isn't running on AWS or no credentials were found, raises an error.
180
+ """
181
+ if not installed_boto:
182
+ raise MissingDependencyError(
183
+ msg="AWS Workload Identity Federation can't be used because boto3 or botocore optional dependency is not installed. Try installing missing dependencies.",
184
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
185
+ )
186
+
187
+ # TODO: SNOW-2223669 Investigate if our adapters - containing settings of http traffic - should be passed here as boto urllib3session. Those requests go to local servers, so they do not need Proxy setup or Headers customization in theory. But we may want to have all the traffic going through one class (e.g. Adapter or mixin).
188
+ session = get_aws_session(impersonation_path)
189
+
190
+ aws_creds = session.get_credentials()
191
+ if not aws_creds:
192
+ raise ProgrammingError(
193
+ msg="No AWS credentials were found. Ensure the application is running on AWS with an IAM role attached.",
194
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
195
+ )
196
+ region = get_aws_region()
197
+ partition = session.get_partition_for_region(region)
198
+ sts_hostname = get_aws_sts_hostname(region, partition)
199
+ request = AWSRequest(
200
+ method="POST",
201
+ url=f"https://{sts_hostname}/?Action=GetCallerIdentity&Version=2011-06-15",
202
+ headers={
203
+ "Host": sts_hostname,
204
+ "X-Snowflake-Audience": SNOWFLAKE_AUDIENCE,
205
+ },
206
+ )
207
+
208
+ SigV4Auth(aws_creds, "sts", region).add_auth(request)
209
+
210
+ assertion_dict = {
211
+ "url": request.url,
212
+ "method": request.method,
213
+ "headers": dict(request.headers.items()),
214
+ }
215
+ credential = b64encode(json.dumps(assertion_dict).encode("utf-8")).decode("utf-8")
216
+ # Unlike other providers, for AWS, we only include general identifiers (region and partition)
217
+ # rather than specific user identifiers, since we don't actually execute a GetCallerIdentity call.
218
+ return WorkloadIdentityAttestation(
219
+ AttestationProvider.AWS, credential, {"region": region, "partition": partition}
220
+ )
221
+
222
+
223
+ def get_gcp_access_token(session_manager: SessionManager) -> str:
224
+ """Gets a GCP access token from the metadata server.
225
+
226
+ If the application isn't running on GCP or no credentials were found, raises an error.
227
+ """
228
+ try:
229
+ res = session_manager.request(
230
+ method="GET",
231
+ url=f"{GCP_METADATA_SERVICE_ACCOUNT_BASE_URL}/token",
232
+ headers={
233
+ "Metadata-Flavor": "Google",
234
+ },
235
+ )
236
+ res.raise_for_status()
237
+ return res.json()["access_token"]
238
+ except Exception as e:
239
+ raise ProgrammingError(
240
+ msg=f"Error fetching GCP access token: {e}. Ensure the application is running on GCP.",
241
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
242
+ )
243
+
244
+
245
+ def get_gcp_identity_token_via_impersonation(
246
+ impersonation_path: list[str], session_manager: SessionManager
247
+ ) -> str:
248
+ """Gets a GCP identity token from the metadata server.
249
+
250
+ If the application isn't running on GCP or no credentials were found, raises an error.
251
+ """
252
+ if not impersonation_path:
253
+ raise ProgrammingError(
254
+ msg="Error: impersonation_path cannot be empty.",
255
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
256
+ )
257
+
258
+ current_sa_token = get_gcp_access_token(session_manager)
259
+ impersonation_path = [
260
+ f"projects/-/serviceAccounts/{client_id}" for client_id in impersonation_path
261
+ ]
262
+ try:
263
+ res = session_manager.post(
264
+ url=f"https://iamcredentials.googleapis.com/v1/{impersonation_path[-1]}:generateIdToken",
265
+ headers={
266
+ "Authorization": f"Bearer {current_sa_token}",
267
+ "Content-Type": "application/json",
268
+ },
269
+ json={
270
+ "delegates": impersonation_path[:-1],
271
+ "audience": SNOWFLAKE_AUDIENCE,
272
+ },
273
+ )
274
+ res.raise_for_status()
275
+ return res.json()["token"]
276
+ except Exception as e:
277
+ raise ProgrammingError(
278
+ msg=f"Error fetching GCP identity token for impersonated GCP service account '{impersonation_path[-1]}': {e}. Ensure the application is running on GCP.",
279
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
280
+ )
281
+
282
+
283
+ def get_gcp_identity_token(session_manager: SessionManager) -> str:
284
+ """Gets a GCP identity token from the metadata server.
285
+
286
+ If the application isn't running on GCP or no credentials were found, raises an error.
287
+ """
288
+ try:
289
+ res = session_manager.request(
290
+ method="GET",
291
+ url=f"{GCP_METADATA_SERVICE_ACCOUNT_BASE_URL}/identity?audience={SNOWFLAKE_AUDIENCE}",
292
+ headers={
293
+ "Metadata-Flavor": "Google",
294
+ },
295
+ )
296
+ res.raise_for_status()
297
+ return res.content.decode("utf-8")
298
+ except Exception as e:
299
+ raise ProgrammingError(
300
+ msg=f"Error fetching GCP identity token: {e}. Ensure the application is running on GCP.",
301
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
302
+ )
303
+
304
+
305
+ def create_gcp_attestation(
306
+ session_manager: SessionManager,
307
+ impersonation_path: list[str] | None = None,
308
+ ) -> WorkloadIdentityAttestation:
309
+ """Tries to create a workload identity attestation for GCP.
310
+
311
+ If the application isn't running on GCP or no credentials were found, raises an error.
312
+ """
313
+ if impersonation_path:
314
+ jwt_str = get_gcp_identity_token_via_impersonation(
315
+ impersonation_path, session_manager
316
+ )
317
+ else:
318
+ jwt_str = get_gcp_identity_token(session_manager)
319
+
320
+ _, subject = extract_iss_and_sub_without_signature_verification(jwt_str)
321
+ return WorkloadIdentityAttestation(
322
+ AttestationProvider.GCP, jwt_str, {"sub": subject}
323
+ )
324
+
325
+
326
+ def create_azure_attestation(
327
+ snowflake_entra_resource: str,
328
+ session_manager: SessionManager | None = None,
329
+ ) -> WorkloadIdentityAttestation:
330
+ """Tries to create a workload identity attestation for Azure.
331
+
332
+ If the application isn't running on Azure or no credentials were found, raises an error.
333
+ """
334
+ headers = {"Metadata": "true"}
335
+ url_without_query_string = "http://169.254.169.254/metadata/identity/oauth2/token"
336
+ query_params = f"api-version=2018-02-01&resource={snowflake_entra_resource}"
337
+
338
+ # Check if running in Azure Functions environment
339
+ identity_endpoint = os.environ.get("IDENTITY_ENDPOINT")
340
+ identity_header = os.environ.get("IDENTITY_HEADER")
341
+ is_azure_functions = identity_endpoint is not None
342
+
343
+ if is_azure_functions:
344
+ if not identity_header:
345
+ raise ProgrammingError(
346
+ msg="Managed identity is not enabled on this Azure function.",
347
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
348
+ )
349
+
350
+ # Azure Functions uses a different endpoint, headers and API version.
351
+ url_without_query_string = identity_endpoint
352
+ headers = {"X-IDENTITY-HEADER": identity_header}
353
+ query_params = f"api-version=2019-08-01&resource={snowflake_entra_resource}"
354
+
355
+ # Allow configuring an explicit client ID, which may be used in Azure Functions,
356
+ # if there are user-assigned identities, or multiple managed identities available.
357
+ managed_identity_client_id = os.environ.get("MANAGED_IDENTITY_CLIENT_ID")
358
+ if managed_identity_client_id:
359
+ query_params += f"&client_id={managed_identity_client_id}"
360
+
361
+ try:
362
+ res = session_manager.request(
363
+ method="GET",
364
+ url=f"{url_without_query_string}?{query_params}",
365
+ headers=headers,
366
+ )
367
+ res.raise_for_status()
368
+ except Exception as e:
369
+ raise ProgrammingError(
370
+ msg=f"Error fetching Azure metadata: {e}. Ensure the application is running on Azure.",
371
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
372
+ )
373
+
374
+ jwt_str = res.json().get("access_token")
375
+ if not jwt_str:
376
+ raise ProgrammingError(
377
+ msg="No access token found in Azure metadata service response.",
378
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
379
+ )
380
+
381
+ issuer, subject = extract_iss_and_sub_without_signature_verification(jwt_str)
382
+ return WorkloadIdentityAttestation(
383
+ AttestationProvider.AZURE, jwt_str, {"iss": issuer, "sub": subject}
384
+ )
385
+
386
+
387
+ def create_oidc_attestation(token: str | None) -> WorkloadIdentityAttestation:
388
+ """Tries to create an attestation using the given token.
389
+
390
+ If this is not populated, raises an error.
391
+ """
392
+ if not token:
393
+ raise ProgrammingError(
394
+ msg="token must be provided if workload_identity_provider=OIDC",
395
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
396
+ )
397
+
398
+ issuer, subject = extract_iss_and_sub_without_signature_verification(token)
399
+ return WorkloadIdentityAttestation(
400
+ AttestationProvider.OIDC, token, {"iss": issuer, "sub": subject}
401
+ )
402
+
403
+
404
+ def create_attestation(
405
+ provider: AttestationProvider,
406
+ entra_resource: str | None = None,
407
+ token: str | None = None,
408
+ impersonation_path: list[str] | None = None,
409
+ session_manager: SessionManager | None = None,
410
+ ) -> WorkloadIdentityAttestation:
411
+ """Entry point to create an attestation using the given provider.
412
+
413
+ If an explicit entra_resource was provided to the connector, this will be used. Otherwise, the default Snowflake Entra resource will be used.
414
+ """
415
+ entra_resource = entra_resource or DEFAULT_ENTRA_SNOWFLAKE_RESOURCE
416
+ session_manager = (
417
+ session_manager.clone()
418
+ if session_manager
419
+ else SessionManagerFactory.get_manager(use_pooling=True, max_retries=0)
420
+ )
421
+
422
+ if provider == AttestationProvider.AWS:
423
+ return create_aws_attestation(impersonation_path)
424
+ elif provider == AttestationProvider.AZURE:
425
+ return create_azure_attestation(entra_resource, session_manager)
426
+ elif provider == AttestationProvider.GCP:
427
+ return create_gcp_attestation(session_manager, impersonation_path)
428
+ elif provider == AttestationProvider.OIDC:
429
+ return create_oidc_attestation(token)
430
+ else:
431
+ raise ProgrammingError(
432
+ msg=f"Unknown workload_identity_provider: '{provider.value}'.",
433
+ errno=ER_WIF_CREDENTIALS_NOT_FOUND,
434
+ )
@@ -0,0 +1,2 @@
1
+ Version: 1.12.0
2
+ Arguments: ['C:\\Program Files\\Python314\\Lib\\site-packages\\delvewheel\\__main__.py', 'repair', '-vv', '-w', 'dist', '--namespace-pkg', 'snowflake', 'dist\\rawwheel\\*']