gix-credentials-0.24.2/.cargo_vcs_info.json0000644000000001550000000000100142040ustar { "git": { "sha1": "b050327e76f234b19be921b78b7b28e034319fdb" }, "path_in_vcs": "gix-credentials" }gix-credentials-0.24.2/Cargo.lock0000644000000363370000000000100121720ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "serde", ] [[package]] name = "bstr" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", "regex-automata", "serde", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "document-features" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" dependencies = [ "litrs", ] [[package]] name = "errno" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "faster-hex" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "gix-command" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90009020dc4b3de47beed28e1334706e0a330ddd17f5cfeb097df3b15a54b77" dependencies = [ "bstr", "gix-path", "gix-trace", "shell-words", ] [[package]] name = "gix-config-value" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" dependencies = [ "bitflags 2.4.1", "bstr", "gix-path", "libc", "thiserror", ] [[package]] name = "gix-credentials" version = "0.24.2" dependencies = [ "bstr", "document-features", "gix-command", "gix-config-value", "gix-path", "gix-prompt", "gix-sec", "gix-trace", "gix-url", "serde", "thiserror", ] [[package]] name = "gix-features" version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db4254037d20a247a0367aa79333750146a369719f0c6617fec4f5752cc62b37" dependencies = [ "gix-hash", "gix-trace", "libc", ] [[package]] name = "gix-hash" version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" dependencies = [ "faster-hex", "thiserror", ] [[package]] name = "gix-path" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23623cf0f475691a6d943f898c4d0b89f5c1a2a64d0f92bce0e0322ee6528783" dependencies = [ "bstr", "gix-trace", "home", "once_cell", "thiserror", ] [[package]] name = "gix-prompt" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5325eb17ce7b5e5d25dec5c2315d642a09d55b9888b3bf46b7d72e1621a55d8" dependencies = [ "gix-command", "gix-config-value", "parking_lot", "rustix", "thiserror", ] [[package]] name = "gix-sec" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" dependencies = [ "bitflags 2.4.1", "gix-path", "libc", "serde", "windows-sys 0.52.0", ] [[package]] name = "gix-trace" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b838b2db8f62c9447d483a4c28d251b67fee32741a82cb4d35e9eb4e9fdc5ab" [[package]] name = "gix-url" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0b24f3ecc79a5a53539de9c2e99425d0ef23feacdcf3faac983aa9a2f26849" dependencies = [ "bstr", "gix-features", "gix-path", "home", "thiserror", "url", ] [[package]] name = "home" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ "windows-sys 0.48.0", ] [[package]] name = "idna" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linux-raw-sys" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "litrs" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", ] [[package]] name = "memchr" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets 0.48.5", ] [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "proc-macro2" version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex-automata" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" [[package]] name = "rustix" version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "smallvec" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" version = "2.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "thiserror" version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tinyvec" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "unicode-bidi" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "url" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.5", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.0", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ "windows_aarch64_gnullvm 0.52.0", "windows_aarch64_msvc 0.52.0", "windows_i686_gnu 0.52.0", "windows_i686_msvc 0.52.0", "windows_x86_64_gnu 0.52.0", "windows_x86_64_gnullvm 0.52.0", "windows_x86_64_msvc 0.52.0", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" gix-credentials-0.24.2/Cargo.toml0000644000000031770000000000100122110ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.65" name = "gix-credentials" version = "0.24.2" authors = ["Sebastian Thiel "] include = [ "src/**/*", "LICENSE-*", ] description = "A crate of the gitoxide project to interact with git credentials helpers" license = "MIT OR Apache-2.0" repository = "https://github.com/Byron/gitoxide" [package.metadata.docs.rs] all-features = true features = ["document-features"] [lib] doctest = false [dependencies.bstr] version = "1.3.0" features = ["std"] default-features = false [dependencies.document-features] version = "0.2.1" optional = true [dependencies.gix-command] version = "^0.3.6" [dependencies.gix-config-value] version = "^0.14.6" [dependencies.gix-path] version = "^0.10.7" [dependencies.gix-prompt] version = "^0.8.4" [dependencies.gix-sec] version = "^0.10.6" [dependencies.gix-trace] version = "^0.1.8" [dependencies.gix-url] version = "^0.27.2" [dependencies.serde] version = "1.0.114" features = ["derive"] optional = true default-features = false [dependencies.thiserror] version = "1.0.32" [dev-dependencies] [features] serde = [ "dep:serde", "bstr/serde", "gix-sec/serde", ] gix-credentials-0.24.2/Cargo.toml.orig000064400000000000000000000025551046102023000156710ustar 00000000000000[package] name = "gix-credentials" version = "0.24.2" repository = "https://github.com/Byron/gitoxide" license = "MIT OR Apache-2.0" description = "A crate of the gitoxide project to interact with git credentials helpers" authors = ["Sebastian Thiel "] edition = "2021" rust-version = "1.65" include = ["src/**/*", "LICENSE-*"] [lib] doctest = false [features] ## Data structures implement `serde::Serialize` and `serde::Deserialize`. serde = ["dep:serde", "bstr/serde", "gix-sec/serde"] [dependencies] gix-sec = { version = "^0.10.6", path = "../gix-sec" } gix-url = { version = "^0.27.2", path = "../gix-url" } gix-path = { version = "^0.10.7", path = "../gix-path" } gix-command = { version = "^0.3.6", path = "../gix-command" } gix-config-value = { version = "^0.14.6", path = "../gix-config-value" } gix-prompt = { version = "^0.8.4", path = "../gix-prompt" } gix-trace = { version = "^0.1.8", path = "../gix-trace" } thiserror = "1.0.32" serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] } bstr = { version = "1.3.0", default-features = false, features = ["std"]} document-features = { version = "0.2.1", optional = true } [dev-dependencies] gix-testtools = { path = "../tests/tools" } gix-sec = { path = "../gix-sec" } [package.metadata.docs.rs] all-features = true features = ["document-features"] gix-credentials-0.24.2/LICENSE-APACHE000064400000000000000000000247461046102023000147340ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Licensed 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. gix-credentials-0.24.2/LICENSE-MIT000064400000000000000000000017771046102023000144430ustar 00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gix-credentials-0.24.2/src/helper/cascade.rs000064400000000000000000000150341046102023000167750ustar 00000000000000use crate::{helper, helper::Cascade, protocol, protocol::Context, Program}; impl Default for Cascade { fn default() -> Self { Cascade { programs: Vec::new(), stderr: true, use_http_path: false, query_user_only: false, } } } /// Initialization impl Cascade { /// Return the programs to run for the current platform. /// /// These are typically used as basis for all credential cascade invocations, with configured programs following afterwards. /// /// # Note /// /// These defaults emulate what typical git installations may use these days, as in fact it's a configurable which comes /// from installation-specific configuration files which we cannot know (or guess at best). /// This seems like an acceptable trade-off as helpers are ignored if they fail or are not existing. pub fn platform_builtin() -> Vec { if cfg!(target_os = "macos") { Some("osxkeychain") } else if cfg!(target_os = "linux") { Some("libsecret") } else if cfg!(target_os = "windows") { Some("manager-core") } else { None } .map(|name| vec![Program::from_custom_definition(name)]) .unwrap_or_default() } } /// Builder impl Cascade { /// Extend the list of programs to run `programs`. pub fn extend(mut self, programs: impl IntoIterator) -> Self { self.programs.extend(programs); self } /// If `toggle` is true, http(s) urls will use the path portions of the url to obtain a credential for. /// /// Otherwise, they will only take the user name into account. pub fn use_http_path(mut self, toggle: bool) -> Self { self.use_http_path = toggle; self } /// If `toggle` is true, a bogus password will be provided to prevent any helper program from prompting for it, nor will /// we prompt for the password. The resulting identity will have a bogus password and it's expected to not be used by the /// consuming transport. pub fn query_user_only(mut self, toggle: bool) -> Self { self.query_user_only = toggle; self } } /// Finalize impl Cascade { /// Invoke the cascade by `invoking` each program with `action`, and configuring potential prompts with `prompt` options. /// The latter can also be used to disable the prompt entirely when setting the `mode` to [`Disable`][gix_prompt::Mode::Disable];=. /// /// When _getting_ credentials, all programs are asked until the credentials are complete, stopping the cascade. /// When _storing_ or _erasing_ all programs are instructed in order. #[allow(clippy::result_large_err)] pub fn invoke(&mut self, mut action: helper::Action, mut prompt: gix_prompt::Options<'_>) -> protocol::Result { let mut url = action .context_mut() .map(|ctx| { ctx.destructure_url_in_place(self.use_http_path).map(|ctx| { if self.query_user_only && ctx.password.is_none() { ctx.password = Some("".into()); } ctx }) }) .transpose()? .and_then(|ctx| ctx.url.take()); for program in &mut self.programs { program.stderr = self.stderr; match helper::invoke::raw(program, &action) { Ok(None) => {} Ok(Some(stdout)) => { let ctx = Context::from_bytes(&stdout)?; if let Some(dst_ctx) = action.context_mut() { if let Some(src) = ctx.path { dst_ctx.path = Some(src); } for (src, dst) in [ (ctx.protocol, &mut dst_ctx.protocol), (ctx.host, &mut dst_ctx.host), (ctx.username, &mut dst_ctx.username), (ctx.password, &mut dst_ctx.password), ] { if let Some(src) = src { *dst = Some(src); } } if let Some(src) = ctx.url { dst_ctx.url = Some(src); url = dst_ctx.destructure_url_in_place(self.use_http_path)?.url.take(); } if dst_ctx.username.is_some() && dst_ctx.password.is_some() { break; } if ctx.quit.unwrap_or_default() { dst_ctx.quit = ctx.quit; break; } } } Err(helper::Error::CredentialsHelperFailed { .. }) => continue, // ignore helpers that we can't call Err(err) if action.context().is_some() => return Err(err.into()), // communication errors are fatal when getting credentials Err(_) => {} // for other actions, ignore everything, try the operation } } if prompt.mode != gix_prompt::Mode::Disable { if let Some(ctx) = action.context_mut() { ctx.url = url; if ctx.username.is_none() { let message = ctx.to_prompt("Username"); prompt.mode = gix_prompt::Mode::Visible; ctx.username = gix_prompt::ask(&message, &prompt) .map_err(|err| protocol::Error::Prompt { prompt: message, source: err, })? .into(); } if ctx.password.is_none() { let message = ctx.to_prompt("Password"); prompt.mode = gix_prompt::Mode::Hidden; ctx.password = gix_prompt::ask(&message, &prompt) .map_err(|err| protocol::Error::Prompt { prompt: message, source: err, })? .into(); } } } protocol::helper_outcome_to_result( action.context().map(|ctx| helper::Outcome { username: ctx.username.clone(), password: ctx.password.clone(), quit: ctx.quit.unwrap_or(false), next: ctx.to_owned().into(), }), action, ) } } gix-credentials-0.24.2/src/helper/invoke.rs000064400000000000000000000050131046102023000167010ustar 00000000000000use std::io::Read; use crate::helper::{Action, Context, Error, NextAction, Outcome, Result}; impl Action { /// Send ourselves to the given `write` which is expected to be credentials-helper compatible pub fn send(&self, write: &mut dyn std::io::Write) -> std::io::Result<()> { match self { Action::Get(ctx) => ctx.write_to(write), Action::Store(last) | Action::Erase(last) => { write.write_all(last).ok(); write.write_all(&[b'\n']).ok(); Ok(()) } } } } /// Invoke the given `helper` with `action` in `context`. /// /// Usually the first call is performed with [`Action::Get`] to obtain `Some` identity, which subsequently can be used if it is complete. /// Note that it may also only contain the username _or_ password, and should start out with everything the helper needs. /// On successful usage, use [`NextAction::store()`], otherwise [`NextAction::erase()`], which is when this function /// returns `Ok(None)` as no outcome is expected. pub fn invoke(helper: &mut crate::Program, action: &Action) -> Result { match raw(helper, action)? { None => Ok(None), Some(stdout) => { let ctx = Context::from_bytes(stdout.as_slice())?; Ok(Some(Outcome { username: ctx.username, password: ctx.password, quit: ctx.quit.unwrap_or(false), next: NextAction { previous_output: stdout.into(), }, })) } } } pub(crate) fn raw(helper: &mut crate::Program, action: &Action) -> std::result::Result>, Error> { let (mut stdin, stdout) = helper.start(action)?; if let (Action::Get(_), None) = (&action, &stdout) { panic!("BUG: `Helper` impls must return an output handle to read output from if Action::Get is provided") } action.send(&mut stdin)?; drop(stdin); let stdout = stdout .map(|mut stdout| { let mut buf = Vec::new(); stdout.read_to_end(&mut buf).map(|_| buf) }) .transpose() .map_err(|err| Error::CredentialsHelperFailed { source: err })?; helper.finish().map_err(|err| { if err.kind() == std::io::ErrorKind::Other { Error::CredentialsHelperFailed { source: err } } else { err.into() } })?; match matches!(action, Action::Get(_)).then(|| stdout).flatten() { None => Ok(None), Some(stdout) => Ok(Some(stdout)), } } gix-credentials-0.24.2/src/helper/mod.rs000064400000000000000000000140541046102023000161720ustar 00000000000000use bstr::{BStr, BString}; use crate::{protocol, protocol::Context, Program}; /// A list of helper programs to run in order to obtain credentials. #[allow(dead_code)] #[derive(Debug)] pub struct Cascade { /// The programs to run in order to obtain credentials pub programs: Vec, /// If true, stderr is enabled when `programs` are run, which is the default. pub stderr: bool, /// If true, http(s) urls will take their path portion into account when obtaining credentials. Default is false. /// Other protocols like ssh will always use the path portion. pub use_http_path: bool, /// If true, default false, when getting credentials, we will set a bogus password to only obtain the user name. /// Storage and cancellation work the same, but without a password set. pub query_user_only: bool, } /// The outcome of the credentials helper [invocation][crate::helper::invoke()]. #[derive(Debug, Clone, Eq, PartialEq)] pub struct Outcome { /// The username to use in the identity, if set. pub username: Option, /// The password to use in the identity, if set. pub password: Option, /// If set, the helper asked to stop the entire process, whether the identity is complete or not. pub quit: bool, /// A handle to the action to perform next in another call to [`helper::invoke()`][crate::helper::invoke()]. pub next: NextAction, } impl Outcome { /// Try to fetch username _and_ password to form an identity. This will fail if one of them is not set. /// /// This does nothing if only one of the fields is set, or consume both. pub fn consume_identity(&mut self) -> Option { if self.username.is_none() || self.password.is_none() { return None; } self.username .take() .zip(self.password.take()) .map(|(username, password)| gix_sec::identity::Account { username, password }) } } /// The Result type used in [`invoke()`][crate::helper::invoke()]. pub type Result = std::result::Result, Error>; /// The error used in the [credentials helper invocation][crate::helper::invoke()]. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum Error { #[error(transparent)] ContextDecode(#[from] protocol::context::decode::Error), #[error("An IO error occurred while communicating to the credentials helper")] Io(#[from] std::io::Error), #[error(transparent)] CredentialsHelperFailed { source: std::io::Error }, } /// The action to perform by the credentials [helper][`crate::helper::invoke()`]. #[derive(Clone, Debug)] pub enum Action { /// Provide credentials using the given repository context, which must include the repository url. Get(Context), /// Approve the credentials as identified by the previous input provided as `BString`, containing information from [`Context`]. Store(BString), /// Reject the credentials as identified by the previous input provided as `BString`. containing information from [`Context`]. Erase(BString), } /// Initialization impl Action { /// Create a `Get` action with context containing the given URL. /// Note that this creates an `Action` suitable for the credential helper cascade only. pub fn get_for_url(url: impl Into) -> Action { Action::Get(Context { url: Some(url.into()), ..Default::default() }) } } /// Access impl Action { /// Return the payload of store or erase actions. pub fn payload(&self) -> Option<&BStr> { use bstr::ByteSlice; match self { Action::Get(_) => None, Action::Store(p) | Action::Erase(p) => Some(p.as_bstr()), } } /// Return the context of a get operation, or `None`. /// /// The opposite of [`payload`][Action::payload()]. pub fn context(&self) -> Option<&Context> { match self { Action::Get(ctx) => Some(ctx), Action::Erase(_) | Action::Store(_) => None, } } /// Return the mutable context of a get operation, or `None`. pub fn context_mut(&mut self) -> Option<&mut Context> { match self { Action::Get(ctx) => Some(ctx), Action::Erase(_) | Action::Store(_) => None, } } /// Returns true if this action expects output from the helper. pub fn expects_output(&self) -> bool { matches!(self, Action::Get(_)) } /// The name of the argument to describe this action. If `is_external` is true, the target program is /// a custom credentials helper, not a built-in one. pub fn as_arg(&self, is_external: bool) -> &str { match self { Action::Get(_) if is_external => "get", Action::Get(_) => "fill", Action::Store(_) if is_external => "store", Action::Store(_) => "approve", Action::Erase(_) if is_external => "erase", Action::Erase(_) => "reject", } } } /// A handle to [store][NextAction::store()] or [erase][NextAction::erase()] the outcome of the initial action. #[derive(Clone, Debug, Eq, PartialEq)] pub struct NextAction { previous_output: BString, } impl TryFrom<&NextAction> for Context { type Error = protocol::context::decode::Error; fn try_from(value: &NextAction) -> std::result::Result { Context::from_bytes(value.previous_output.as_ref()) } } impl From for NextAction { fn from(ctx: Context) -> Self { let mut buf = Vec::::new(); ctx.write_to(&mut buf).expect("cannot fail"); NextAction { previous_output: buf.into(), } } } impl NextAction { /// Approve the result of the previous [Action] and store for lookup. pub fn store(self) -> Action { Action::Store(self.previous_output) } /// Reject the result of the previous [Action] and erase it as to not be returned when being looked up. pub fn erase(self) -> Action { Action::Erase(self.previous_output) } } mod cascade; pub(crate) mod invoke; pub use invoke::invoke; gix-credentials-0.24.2/src/lib.rs000064400000000000000000000030151046102023000146750ustar 00000000000000//! Interact with git credentials in various ways and launch helper programs. //! //! ## Feature Flags #![cfg_attr( all(doc, feature = "document-features"), doc = ::document_features::document_features!() )] #![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))] #![deny(missing_docs, rust_2018_idioms)] #![forbid(unsafe_code)] /// A program/executable implementing the credential helper protocol. #[derive(Debug)] pub struct Program { /// The kind of program, ready for launch. pub kind: program::Kind, /// If true, stderr is enabled, which is the default. pub stderr: bool, /// `Some(…)` if the process is running. child: Option, } /// #[allow(clippy::empty_docs)] pub mod helper; /// #[allow(clippy::empty_docs)] pub mod program; /// #[allow(clippy::empty_docs)] pub mod protocol; /// Call the `git credential` helper program performing the given `action`, which reads all context from the git configuration /// and does everything `git` typically does. The `action` should have been created with [`helper::Action::get_for_url()`] to /// contain only the URL to kick off the process, or should be created by [`helper::NextAction`]. /// /// If more control is required, use the [`Cascade`][helper::Cascade] type. #[allow(clippy::result_large_err)] pub fn builtin(action: helper::Action) -> protocol::Result { protocol::helper_outcome_to_result( helper::invoke(&mut Program::from_kind(program::Kind::Builtin), &action)?, action, ) } gix-credentials-0.24.2/src/program/main.rs000064400000000000000000000100421046102023000165200ustar 00000000000000use std::ffi::OsString; use bstr::BString; /// The action passed to the credential helper implementation in [`main()`][crate::program::main()]. #[derive(Debug, Copy, Clone)] pub enum Action { /// Get credentials for a url. Get, /// Store credentials provided in the given context. Store, /// Erase credentials identified by the given context. Erase, } impl TryFrom for Action { type Error = Error; fn try_from(value: OsString) -> Result { Ok(match value.to_str() { Some("fill" | "get") => Action::Get, Some("approve" | "store") => Action::Store, Some("reject" | "erase") => Action::Erase, _ => return Err(Error::ActionInvalid { name: value }), }) } } impl Action { /// Return ourselves as string representation, similar to what would be passed as argument to a credential helper. pub fn as_str(&self) -> &'static str { match self { Action::Get => "get", Action::Store => "store", Action::Erase => "erase", } } } /// The error of [`main()`][crate::program::main()]. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum Error { #[error("Action named {name:?} is invalid, need 'get', 'store', 'erase' or 'fill', 'approve', 'reject'")] ActionInvalid { name: OsString }, #[error("The first argument must be the action to perform")] ActionMissing, #[error(transparent)] Helper { source: Box, }, #[error(transparent)] Io(#[from] std::io::Error), #[error(transparent)] Context(#[from] crate::protocol::context::decode::Error), #[error("Credentials for {url:?} could not be obtained")] CredentialsMissing { url: BString }, #[error("The url wasn't provided in input - the git credentials protocol mandates this")] UrlMissing, } pub(crate) mod function { use std::ffi::OsString; use crate::{ program::main::{Action, Error}, protocol::Context, }; /// Invoke a custom credentials helper which receives program `args`, with the first argument being the /// action to perform (as opposed to the program name). /// Then read context information from `stdin` and if the action is `Action::Get`, then write the result to `stdout`. /// `credentials` is the API version of such call, where`Ok(Some(context))` returns credentials, and `Ok(None)` indicates /// no credentials could be found for `url`, which is always set when called. /// /// Call this function from a programs `main`, passing `std::env::args_os()`, `stdin()` and `stdout` accordingly, along with /// your own helper implementation. pub fn main( args: impl IntoIterator, mut stdin: impl std::io::Read, stdout: impl std::io::Write, credentials: CredentialsFn, ) -> Result<(), Error> where CredentialsFn: FnOnce(Action, Context) -> Result, E>, E: std::error::Error + Send + Sync + 'static, { let action: Action = args.into_iter().next().ok_or(Error::ActionMissing)?.try_into()?; let mut buf = Vec::::with_capacity(512); stdin.read_to_end(&mut buf)?; let ctx = Context::from_bytes(&buf)?; if ctx.url.is_none() { return Err(Error::UrlMissing); } let res = credentials(action, ctx).map_err(|err| Error::Helper { source: Box::new(err) })?; match (action, res) { (Action::Get, None) => { return Err(Error::CredentialsMissing { url: Context::from_bytes(&buf)?.url.expect("present and checked above"), }) } (Action::Get, Some(ctx)) => ctx.write_to(stdout)?, (Action::Erase | Action::Store, None) => {} (Action::Erase | Action::Store, Some(_)) => { panic!("BUG: credentials helper must not return context for erase or store actions") } } Ok(()) } } gix-credentials-0.24.2/src/program/mod.rs000064400000000000000000000126551046102023000163670ustar 00000000000000use std::process::{Command, Stdio}; use bstr::{BString, ByteSlice, ByteVec}; use crate::{helper, Program}; /// The kind of helper program to use. #[derive(Debug, Clone, Eq, PartialEq)] pub enum Kind { /// The built-in `git credential` helper program, part of any `git` distribution. Builtin, /// A custom credentials helper, as identified just by the name with optional arguments ExternalName { /// The name like `foo` along with optional args, like `foo --arg --bar="a b"`, with arguments using `sh` shell quoting rules. /// The program executed will be `git-credential-foo [args]` if `name_and_args` starts with `foo [args]`. /// Note that a shell is only used if it's needed. name_and_args: BString, }, /// A custom credentials helper, as identified just by the absolute path to the program and optional arguments. The program is executed through a shell. ExternalPath { /// The absolute path to the executable, like `/path/to/exe` along with optional args, like `/path/to/exe --arg --bar="a b"`, with arguments using `sh` /// shell quoting rules. path_and_args: BString, }, /// A script to execute with `sh`. ExternalShellScript(BString), } /// Initialization impl Program { /// Create a new program of the given `kind`. pub fn from_kind(kind: Kind) -> Self { Program { kind, child: None, stderr: true, } } /// Parse the given input as per the custom helper definition, supporting `!