credential: change git_cred to git_credential We avoid abbreviations where possible; rename git_cred to git_credential. In addition, we have standardized on a trailing `_t` for enum types, instead of using "type" in the name. So `git_credtype_t` has become `git_credential_t` and its members have become `GIT_CREDENTIAL` instead of `GIT_CREDTYPE`. Finally, the source and header files have been renamed to `credential` instead of `cred`. Keep previous name and values as deprecated, and include the new header files from the previous ones.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292
diff --git a/examples/common.c b/examples/common.c
index 30f6cdc..b068b84 100644
--- a/examples/common.c
+++ b/examples/common.c
@@ -176,7 +176,7 @@ static int ask(char **out, const char *prompt, char optional)
return 0;
}
-int cred_acquire_cb(git_cred **out,
+int cred_acquire_cb(git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
@@ -195,7 +195,7 @@ int cred_acquire_cb(git_cred **out,
goto out;
}
- if (allowed_types & GIT_CREDTYPE_SSH_KEY) {
+ if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
int n;
if ((error = ask(&privkey, "SSH Key:", 0)) < 0 ||
@@ -207,14 +207,14 @@ int cred_acquire_cb(git_cred **out,
(n = snprintf(pubkey, n + 1, "%s.pub", privkey)) < 0)
goto out;
- error = git_cred_ssh_key_new(out, username, pubkey, privkey, password);
- } else if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
+ error = git_credential_ssh_key_new(out, username, pubkey, privkey, password);
+ } else if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
if ((error = ask(&password, "Password:", 1)) < 0)
goto out;
- error = git_cred_userpass_plaintext_new(out, username, password);
- } else if (allowed_types & GIT_CREDTYPE_USERNAME) {
- error = git_cred_username_new(out, username);
+ error = git_credential_userpass_plaintext_new(out, username, password);
+ } else if (allowed_types & GIT_CREDENTIAL_USERNAME) {
+ error = git_credential_username_new(out, username);
}
out:
diff --git a/examples/common.h b/examples/common.h
index 5a029b4..c01561b 100644
--- a/examples/common.h
+++ b/examples/common.h
@@ -125,7 +125,7 @@ extern int resolve_refish(git_annotated_commit **commit, git_repository *repo, c
/**
* Acquire credentials via command line
*/
-extern int cred_acquire_cb(git_cred **out,
+extern int cred_acquire_cb(git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
diff --git a/include/git2.h b/include/git2.h
index 7f49f8f..f39d7fb 100644
--- a/include/git2.h
+++ b/include/git2.h
@@ -22,7 +22,7 @@
#include "git2/commit.h"
#include "git2/common.h"
#include "git2/config.h"
-#include "git2/cred.h"
+#include "git2/credential.h"
#include "git2/deprecated.h"
#include "git2/describe.h"
#include "git2/diff.h"
diff --git a/include/git2/cred.h b/include/git2/cred.h
deleted file mode 100644
index e89ab23..0000000
--- a/include/git2/cred.h
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_git_cred_h__
-#define INCLUDE_git_cred_h__
-
-#include "common.h"
-
-/**
- * @file git2/cred.h
- * @brief Git authentication & credential management
- * @defgroup git_cred Authentication & credential management
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/**
- * Supported credential types
- *
- * This represents the various types of authentication methods supported by
- * the library.
- */
-typedef enum {
- /**
- * A vanilla user/password request
- * @see git_cred_userpass_plaintext_new
- */
- GIT_CREDTYPE_USERPASS_PLAINTEXT = (1u << 0),
-
- /**
- * An SSH key-based authentication request
- * @see git_cred_ssh_key_new
- */
- GIT_CREDTYPE_SSH_KEY = (1u << 1),
-
- /**
- * An SSH key-based authentication request, with a custom signature
- * @see git_cred_ssh_custom_new
- */
- GIT_CREDTYPE_SSH_CUSTOM = (1u << 2),
-
- /**
- * An NTLM/Negotiate-based authentication request.
- * @see git_cred_default
- */
- GIT_CREDTYPE_DEFAULT = (1u << 3),
-
- /**
- * An SSH interactive authentication request
- * @see git_cred_ssh_interactive_new
- */
- GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4),
-
- /**
- * Username-only authentication request
- *
- * Used as a pre-authentication step if the underlying transport
- * (eg. SSH, with no username in its URL) does not know which username
- * to use.
- *
- * @see git_cred_username_new
- */
- GIT_CREDTYPE_USERNAME = (1u << 5),
-
- /**
- * An SSH key-based authentication request
- *
- * Allows credentials to be read from memory instead of files.
- * Note that because of differences in crypto backend support, it might
- * not be functional.
- *
- * @see git_cred_ssh_key_memory_new
- */
- GIT_CREDTYPE_SSH_MEMORY = (1u << 6),
-} git_credtype_t;
-
-/**
- * The base structure for all credential types
- */
-typedef struct git_cred git_cred;
-
-typedef struct git_cred_userpass_plaintext git_cred_userpass_plaintext;
-
-/** Username-only credential information */
-typedef struct git_cred_username git_cred_username;
-
-/** A key for NTLM/Kerberos "default" credentials */
-typedef struct git_cred git_cred_default;
-
-/**
- * A ssh key from disk
- */
-typedef struct git_cred_ssh_key git_cred_ssh_key;
-
-/**
- * Keyboard-interactive based ssh authentication
- */
-typedef struct git_cred_ssh_interactive git_cred_ssh_interactive;
-
-/**
- * A key with a custom signature function
- */
-typedef struct git_cred_ssh_custom git_cred_ssh_custom;
-
-/**
- * Credential acquisition callback.
- *
- * This callback is usually involved any time another system might need
- * authentication. As such, you are expected to provide a valid git_cred
- * object back, depending on allowed_types (a git_credtype_t bitmask).
- *
- * Note that most authentication details are your responsibility - this
- * callback will be called until the authentication succeeds, or you report
- * an error. As such, it's easy to get in a loop if you fail to stop providing
- * the same incorrect credentials.
- *
- * @param cred The newly created credential object.
- * @param url The resource for which we are demanding a credential.
- * @param username_from_url The username that was embedded in a "user\@host"
- * remote url, or NULL if not included.
- * @param allowed_types A bitmask stating which cred types are OK to return.
- * @param payload The payload provided when specifying this callback.
- * @return 0 for success, < 0 to indicate an error, > 0 to indicate
- * no credential was acquired
- */
-typedef int GIT_CALLBACK(git_cred_acquire_cb)(
- git_cred **cred,
- const char *url,
- const char *username_from_url,
- unsigned int allowed_types,
- void *payload);
-
-/**
- * Free a credential.
- *
- * This is only necessary if you own the object; that is, if you are a
- * transport.
- *
- * @param cred the object to free
- */
-GIT_EXTERN(void) git_cred_free(git_cred *cred);
-
-/**
- * Check whether a credential object contains username information.
- *
- * @param cred object to check
- * @return 1 if the credential object has non-NULL username, 0 otherwise
- */
-GIT_EXTERN(int) git_cred_has_username(git_cred *cred);
-
-/**
- * Return the username associated with a credential object.
- *
- * @param cred object to check
- * @return the credential username, or NULL if not applicable
- */
-GIT_EXTERN(const char *) git_cred_get_username(git_cred *cred);
-
-/**
- * Create a new plain-text username and password credential object.
- * The supplied credential parameter will be internally duplicated.
- *
- * @param out The newly created credential object.
- * @param username The username of the credential.
- * @param password The password of the credential.
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_userpass_plaintext_new(
- git_cred **out,
- const char *username,
- const char *password);
-
-/**
- * Create a "default" credential usable for Negotiate mechanisms like NTLM
- * or Kerberos authentication.
- *
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_default_new(git_cred **out);
-
-/**
- * Create a credential to specify a username.
- *
- * This is used with ssh authentication to query for the username if
- * none is specified in the url.
- */
-GIT_EXTERN(int) git_cred_username_new(git_cred **cred, const char *username);
-
-/**
- * Create a new passphrase-protected ssh key credential object.
- * The supplied credential parameter will be internally duplicated.
- *
- * @param out The newly created credential object.
- * @param username username to use to authenticate
- * @param publickey The path to the public key of the credential.
- * @param privatekey The path to the private key of the credential.
- * @param passphrase The passphrase of the credential.
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_ssh_key_new(
- git_cred **out,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase);
-
-/**
- * Create a new ssh key credential object reading the keys from memory.
- *
- * @param out The newly created credential object.
- * @param username username to use to authenticate.
- * @param publickey The public key of the credential.
- * @param privatekey The private key of the credential.
- * @param passphrase The passphrase of the credential.
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_ssh_key_memory_new(
- git_cred **out,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase);
-
-/*
- * If the user hasn't included libssh2.h before git2.h, we need to
- * define a few types for the callback signatures.
- */
-#ifndef LIBSSH2_VERSION
-typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION;
-typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT;
-typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE;
-#endif
-
-typedef void GIT_CALLBACK(git_cred_ssh_interactive_cb)(
- const char *name,
- int name_len,
- const char *instruction, int instruction_len,
- int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
- LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
- void **abstract);
-
-
-/**
- * Create a new ssh keyboard-interactive based credential object.
- * The supplied credential parameter will be internally duplicated.
- *
- * @param username Username to use to authenticate.
- * @param prompt_callback The callback method used for prompts.
- * @param payload Additional data to pass to the callback.
- * @return 0 for success or an error code for failure.
- */
-GIT_EXTERN(int) git_cred_ssh_interactive_new(
- git_cred **out,
- const char *username,
- git_cred_ssh_interactive_cb prompt_callback,
- void *payload);
-
-/**
- * Create a new ssh key credential object used for querying an ssh-agent.
- * The supplied credential parameter will be internally duplicated.
- *
- * @param out The newly created credential object.
- * @param username username to use to authenticate
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_ssh_key_from_agent(
- git_cred **out,
- const char *username);
-
-typedef int GIT_CALLBACK(git_cred_sign_cb)(
- LIBSSH2_SESSION *session,
- unsigned char **sig, size_t *sig_len,
- const unsigned char *data, size_t data_len,
- void **abstract);
-
-/**
- * Create an ssh key credential with a custom signing function.
- *
- * This lets you use your own function to sign the challenge.
- *
- * This function and its credential type is provided for completeness
- * and wraps `libssh2_userauth_publickey()`, which is undocumented.
- *
- * The supplied credential parameter will be internally duplicated.
- *
- * @param out The newly created credential object.
- * @param username username to use to authenticate
- * @param publickey The bytes of the public key.
- * @param publickey_len The length of the public key in bytes.
- * @param sign_callback The callback method to sign the data during the challenge.
- * @param payload Additional data to pass to the callback.
- * @return 0 for success or an error code for failure
- */
-GIT_EXTERN(int) git_cred_ssh_custom_new(
- git_cred **out,
- const char *username,
- const char *publickey,
- size_t publickey_len,
- git_cred_sign_cb sign_callback,
- void *payload);
-
-/** @} */
-GIT_END_DECL
-#endif
diff --git a/include/git2/cred_helpers.h b/include/git2/cred_helpers.h
index 1416d56..3721b6d 100644
--- a/include/git2/cred_helpers.h
+++ b/include/git2/cred_helpers.h
@@ -7,47 +7,9 @@
#ifndef INCLUDE_git_cred_helpers_h__
#define INCLUDE_git_cred_helpers_h__
-#include "transport.h"
-
-/**
- * @file git2/cred_helpers.h
- * @brief Utility functions for credential management
- * @defgroup git_cred_helpers credential management helpers
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/**
- * Payload for git_cred_stock_userpass_plaintext.
- */
-typedef struct git_cred_userpass_payload {
- const char *username;
- const char *password;
-} git_cred_userpass_payload;
-
-
-/**
- * Stock callback usable as a git_cred_acquire_cb. This calls
- * git_cred_userpass_plaintext_new unless the protocol has not specified
- * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
- *
- * @param cred The newly created credential object.
- * @param url The resource for which we are demanding a credential.
- * @param user_from_url The username that was embedded in a "user\@host"
- * remote url, or NULL if not included.
- * @param allowed_types A bitmask stating which cred types are OK to return.
- * @param payload The payload provided when specifying this callback. (This is
- * interpreted as a `git_cred_userpass_payload*`.)
- */
-GIT_EXTERN(int) git_cred_userpass(
- git_cred **cred,
- const char *url,
- const char *user_from_url,
- unsigned int allowed_types,
- void *payload);
-
+/* These declarations have moved. */
+#ifndef GIT_DEPRECATE_HARD
+# include "git2/credential_helpers.h"
+#endif
-/** @} */
-GIT_END_DECL
#endif
diff --git a/include/git2/credential.h b/include/git2/credential.h
new file mode 100644
index 0000000..9426a6e
--- /dev/null
+++ b/include/git2/credential.h
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_credential_h__
+#define INCLUDE_git_credential_h__
+
+#include "common.h"
+
+/**
+ * @file git2/credential.h
+ * @brief Git authentication & credential management
+ * @defgroup git_credential Authentication & credential management
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Supported credential types
+ *
+ * This represents the various types of authentication methods supported by
+ * the library.
+ */
+typedef enum {
+ /**
+ * A vanilla user/password request
+ * @see git_credential_userpass_plaintext_new
+ */
+ GIT_CREDENTIAL_USERPASS_PLAINTEXT = (1u << 0),
+
+ /**
+ * An SSH key-based authentication request
+ * @see git_credential_ssh_key_new
+ */
+ GIT_CREDENTIAL_SSH_KEY = (1u << 1),
+
+ /**
+ * An SSH key-based authentication request, with a custom signature
+ * @see git_credential_ssh_custom_new
+ */
+ GIT_CREDENTIAL_SSH_CUSTOM = (1u << 2),
+
+ /**
+ * An NTLM/Negotiate-based authentication request.
+ * @see git_credential_default
+ */
+ GIT_CREDENTIAL_DEFAULT = (1u << 3),
+
+ /**
+ * An SSH interactive authentication request
+ * @see git_credential_ssh_interactive_new
+ */
+ GIT_CREDENTIAL_SSH_INTERACTIVE = (1u << 4),
+
+ /**
+ * Username-only authentication request
+ *
+ * Used as a pre-authentication step if the underlying transport
+ * (eg. SSH, with no username in its URL) does not know which username
+ * to use.
+ *
+ * @see git_credential_username_new
+ */
+ GIT_CREDENTIAL_USERNAME = (1u << 5),
+
+ /**
+ * An SSH key-based authentication request
+ *
+ * Allows credentials to be read from memory instead of files.
+ * Note that because of differences in crypto backend support, it might
+ * not be functional.
+ *
+ * @see git_credential_ssh_key_memory_new
+ */
+ GIT_CREDENTIAL_SSH_MEMORY = (1u << 6),
+} git_credential_t;
+
+/**
+ * The base structure for all credential types
+ */
+typedef struct git_credential git_credential;
+
+typedef struct git_credential_userpass_plaintext git_credential_userpass_plaintext;
+
+/** Username-only credential information */
+typedef struct git_credential_username git_credential_username;
+
+/** A key for NTLM/Kerberos "default" credentials */
+typedef struct git_credential git_credential_default;
+
+/**
+ * A ssh key from disk
+ */
+typedef struct git_credential_ssh_key git_credential_ssh_key;
+
+/**
+ * Keyboard-interactive based ssh authentication
+ */
+typedef struct git_credential_ssh_interactive git_credential_ssh_interactive;
+
+/**
+ * A key with a custom signature function
+ */
+typedef struct git_credential_ssh_custom git_credential_ssh_custom;
+
+/**
+ * Credential acquisition callback.
+ *
+ * This callback is usually involved any time another system might need
+ * authentication. As such, you are expected to provide a valid
+ * git_credential object back, depending on allowed_types (a
+ * git_credential_t bitmask).
+ *
+ * Note that most authentication details are your responsibility - this
+ * callback will be called until the authentication succeeds, or you report
+ * an error. As such, it's easy to get in a loop if you fail to stop providing
+ * the same incorrect credentials.
+ *
+ * @param out The newly created credential object.
+ * @param url The resource for which we are demanding a credential.
+ * @param username_from_url The username that was embedded in a "user\@host"
+ * remote url, or NULL if not included.
+ * @param allowed_types A bitmask stating which credential types are OK to return.
+ * @param payload The payload provided when specifying this callback.
+ * @return 0 for success, < 0 to indicate an error, > 0 to indicate
+ * no credential was acquired
+ */
+typedef int GIT_CALLBACK(git_credential_acquire_cb)(
+ git_credential **out,
+ const char *url,
+ const char *username_from_url,
+ unsigned int allowed_types,
+ void *payload);
+
+/**
+ * Free a credential.
+ *
+ * This is only necessary if you own the object; that is, if you are a
+ * transport.
+ *
+ * @param cred the object to free
+ */
+GIT_EXTERN(void) git_credential_free(git_credential *cred);
+
+/**
+ * Check whether a credential object contains username information.
+ *
+ * @param cred object to check
+ * @return 1 if the credential object has non-NULL username, 0 otherwise
+ */
+GIT_EXTERN(int) git_credential_has_username(git_credential *cred);
+
+/**
+ * Return the username associated with a credential object.
+ *
+ * @param cred object to check
+ * @return the credential username, or NULL if not applicable
+ */
+GIT_EXTERN(const char *) git_credential_get_username(git_credential *cred);
+
+/**
+ * Create a new plain-text username and password credential object.
+ * The supplied credential parameter will be internally duplicated.
+ *
+ * @param out The newly created credential object.
+ * @param username The username of the credential.
+ * @param password The password of the credential.
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_userpass_plaintext_new(
+ git_credential **out,
+ const char *username,
+ const char *password);
+
+/**
+ * Create a "default" credential usable for Negotiate mechanisms like NTLM
+ * or Kerberos authentication.
+ *
+ * @param out The newly created credential object.
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_default_new(git_credential **out);
+
+/**
+ * Create a credential to specify a username.
+ *
+ * This is used with ssh authentication to query for the username if
+ * none is specified in the url.
+ *
+ * @param out The newly created credential object.
+ * @param username The username to authenticate with
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_username_new(git_credential **out, const char *username);
+
+/**
+ * Create a new passphrase-protected ssh key credential object.
+ * The supplied credential parameter will be internally duplicated.
+ *
+ * @param out The newly created credential object.
+ * @param username username to use to authenticate
+ * @param publickey The path to the public key of the credential.
+ * @param privatekey The path to the private key of the credential.
+ * @param passphrase The passphrase of the credential.
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_ssh_key_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+
+/**
+ * Create a new ssh key credential object reading the keys from memory.
+ *
+ * @param out The newly created credential object.
+ * @param username username to use to authenticate.
+ * @param publickey The public key of the credential.
+ * @param privatekey The private key of the credential.
+ * @param passphrase The passphrase of the credential.
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_ssh_key_memory_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+
+/*
+ * If the user hasn't included libssh2.h before git2.h, we need to
+ * define a few types for the callback signatures.
+ */
+#ifndef LIBSSH2_VERSION
+typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION;
+typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT;
+typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE;
+#endif
+
+typedef void GIT_CALLBACK(git_credential_ssh_interactive_cb)(
+ const char *name,
+ int name_len,
+ const char *instruction, int instruction_len,
+ int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
+ LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
+ void **abstract);
+
+
+/**
+ * Create a new ssh keyboard-interactive based credential object.
+ * The supplied credential parameter will be internally duplicated.
+ *
+ * @param username Username to use to authenticate.
+ * @param prompt_callback The callback method used for prompts.
+ * @param payload Additional data to pass to the callback.
+ * @return 0 for success or an error code for failure.
+ */
+GIT_EXTERN(int) git_credential_ssh_interactive_new(
+ git_credential **out,
+ const char *username,
+ git_credential_ssh_interactive_cb prompt_callback,
+ void *payload);
+
+/**
+ * Create a new ssh key credential object used for querying an ssh-agent.
+ * The supplied credential parameter will be internally duplicated.
+ *
+ * @param out The newly created credential object.
+ * @param username username to use to authenticate
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_ssh_key_from_agent(
+ git_credential **out,
+ const char *username);
+
+typedef int GIT_CALLBACK(git_credential_sign_cb)(
+ LIBSSH2_SESSION *session,
+ unsigned char **sig, size_t *sig_len,
+ const unsigned char *data, size_t data_len,
+ void **abstract);
+
+/**
+ * Create an ssh key credential with a custom signing function.
+ *
+ * This lets you use your own function to sign the challenge.
+ *
+ * This function and its credential type is provided for completeness
+ * and wraps `libssh2_userauth_publickey()`, which is undocumented.
+ *
+ * The supplied credential parameter will be internally duplicated.
+ *
+ * @param out The newly created credential object.
+ * @param username username to use to authenticate
+ * @param publickey The bytes of the public key.
+ * @param publickey_len The length of the public key in bytes.
+ * @param sign_callback The callback method to sign the data during the challenge.
+ * @param payload Additional data to pass to the callback.
+ * @return 0 for success or an error code for failure
+ */
+GIT_EXTERN(int) git_credential_ssh_custom_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ size_t publickey_len,
+ git_credential_sign_cb sign_callback,
+ void *payload);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/credential_helpers.h b/include/git2/credential_helpers.h
new file mode 100644
index 0000000..9a70ecb
--- /dev/null
+++ b/include/git2/credential_helpers.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_credential_helpers_h__
+#define INCLUDE_git_credential_helpers_h__
+
+#include "transport.h"
+
+/**
+ * @file git2/credential_helpers.h
+ * @brief Utility functions for credential management
+ * @defgroup git_credential_helpers credential management helpers
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Payload for git_credential_userpass_plaintext.
+ */
+typedef struct git_credential_userpass_payload {
+ const char *username;
+ const char *password;
+} git_credential_userpass_payload;
+
+
+/**
+ * Stock callback usable as a git_credential_acquire_cb. This calls
+ * git_cred_userpass_plaintext_new unless the protocol has not specified
+ * `GIT_CREDENTIAL_USERPASS_PLAINTEXT` as an allowed type.
+ *
+ * @param out The newly created credential object.
+ * @param url The resource for which we are demanding a credential.
+ * @param user_from_url The username that was embedded in a "user\@host"
+ * remote url, or NULL if not included.
+ * @param allowed_types A bitmask stating which credential types are OK to return.
+ * @param payload The payload provided when specifying this callback. (This is
+ * interpreted as a `git_credential_userpass_payload*`.)
+ */
+GIT_EXTERN(int) git_credential_userpass(
+ git_credential **out,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index 7eb21dc..61d0115 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -33,6 +33,8 @@
#include "status.h"
#include "submodule.h"
#include "worktree.h"
+#include "credential.h"
+#include "credential_helpers.h"
/*
* Users can avoid deprecated functions by defining `GIT_DEPRECATE_HARD`.
@@ -359,7 +361,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
/**@}*/
-/** @name Deprecated Credential Callback Types
+/** @name Deprecated Credential Types
*
* These types are retained for backward compatibility. The newer
* versions of these values should be preferred in all new code.
@@ -368,8 +370,77 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
* this time.
*/
-typedef git_cred_sign_cb git_cred_sign_callback;
-typedef git_cred_ssh_interactive_cb git_cred_ssh_interactive_callback;
+typedef git_credential git_cred;
+typedef git_credential_userpass_plaintext git_cred_userpass_plaintext;
+typedef git_credential_username git_cred_username;
+typedef git_credential_default git_cred_default;
+typedef git_credential_ssh_key git_cred_ssh_key;
+typedef git_credential_ssh_interactive git_cred_ssh_interactive;
+typedef git_credential_ssh_custom git_cred_ssh_custom;
+
+typedef git_credential_acquire_cb git_cred_acquire_cb;
+typedef git_credential_sign_cb git_cred_sign_callback;
+typedef git_credential_sign_cb git_cred_sign_cb;
+typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_callback;
+typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_cb;
+
+#define git_credtype_t git_credential_t
+
+#define GIT_CREDTYPE_USERPASS_PLAINTEXT GIT_CREDENTIAL_USERPASS_PLAINTEXT
+#define GIT_CREDTYPE_SSH_KEY GIT_CREDENTIAL_SSH_KEY
+#define GIT_CREDTYPE_SSH_CUSTOM GIT_CREDENTIAL_SSH_CUSTOM
+#define GIT_CREDTYPE_DEFAULT GIT_CREDENTIAL_DEFAULT
+#define GIT_CREDTYPE_SSH_INTERACTIVE GIT_CREDENTIAL_SSH_INTERACTIVE
+#define GIT_CREDTYPE_USERNAME GIT_CREDENTIAL_USERNAME
+#define GIT_CREDTYPE_SSH_MEMORY GIT_CREDENTIAL_SSH_MEMORY
+
+GIT_EXTERN(void) git_cred_free(git_credential *cred);
+GIT_EXTERN(int) git_cred_has_username(git_credential *cred);
+GIT_EXTERN(const char *) git_cred_get_username(git_credential *cred);
+GIT_EXTERN(int) git_cred_userpass_plaintext_new(
+ git_credential **out,
+ const char *username,
+ const char *password);
+GIT_EXTERN(int) git_cred_default_new(git_credential **out);
+GIT_EXTERN(int) git_cred_username_new(git_credential **out, const char *username);
+GIT_EXTERN(int) git_cred_ssh_key_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+GIT_EXTERN(int) git_cred_ssh_key_memory_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase);
+GIT_EXTERN(int) git_cred_ssh_interactive_new(
+ git_credential **out,
+ const char *username,
+ git_credential_ssh_interactive_cb prompt_callback,
+ void *payload);
+GIT_EXTERN(int) git_cred_ssh_key_from_agent(
+ git_credential **out,
+ const char *username);
+GIT_EXTERN(int) git_cred_ssh_custom_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ size_t publickey_len,
+ git_credential_sign_cb sign_callback,
+ void *payload);
+
+/* Deprecated Credential Helper Types */
+
+typedef git_credential_userpass_payload git_cred_userpass_payload;
+
+GIT_EXTERN(int) git_cred_userpass(
+ git_credential **out,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload);
/**@}*/
diff --git a/include/git2/proxy.h b/include/git2/proxy.h
index f959ae2..653425d 100644
--- a/include/git2/proxy.h
+++ b/include/git2/proxy.h
@@ -10,7 +10,7 @@
#include "common.h"
#include "cert.h"
-#include "cred.h"
+#include "credential.h"
GIT_BEGIN_DECL
@@ -61,7 +61,7 @@ typedef struct {
* Returning GIT_PASSTHROUGH will make libgit2 behave as
* though this field isn't set.
*/
- git_cred_acquire_cb credentials;
+ git_credential_acquire_cb credentials;
/**
* If cert verification fails, this will be called to let the
diff --git a/include/git2/remote.h b/include/git2/remote.h
index f9454d6..54b6672 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -517,7 +517,7 @@ struct git_remote_callbacks {
* Returning GIT_PASSTHROUGH will make libgit2 behave as
* though this field isn't set.
*/
- git_cred_acquire_cb credentials;
+ git_credential_acquire_cb credentials;
/**
* If cert verification fails, this will be called to let the
diff --git a/include/git2/sys/cred.h b/include/git2/sys/cred.h
index 7636e79..4d2a59a 100644
--- a/include/git2/sys/cred.h
+++ b/include/git2/sys/cred.h
@@ -7,84 +7,9 @@
#ifndef INCLUDE_sys_git_cred_h__
#define INCLUDE_sys_git_cred_h__
-#include "git2/common.h"
-#include "git2/cred.h"
-
-/**
- * @file git2/sys/cred.h
- * @brief Git credentials low-level implementation
- * @defgroup git_cred Git credentials low-level implementation
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/**
- * The base structure for all credential types
- */
-struct git_cred {
- git_credtype_t credtype; /**< A type of credential */
-
- /** The deallocator for this type of credentials */
- void GIT_CALLBACK(free)(git_cred *cred);
-};
-
-/** A plaintext username and password */
-struct git_cred_userpass_plaintext {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *password; /**< The password to use */
-};
-
-/** Username-only credential information */
-struct git_cred_username {
- git_cred parent; /**< The parent cred */
- char username[1]; /**< The username to authenticate as */
-};
-
-/**
- * A ssh key from disk
- */
-struct git_cred_ssh_key {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *publickey; /**< The path to a public key */
- char *privatekey; /**< The path to a private key */
- char *passphrase; /**< Passphrase used to decrypt the private key */
-};
-
-/**
- * Keyboard-interactive based ssh authentication
- */
-struct git_cred_ssh_interactive {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
-
- /**
- * Callback used for authentication.
- */
- git_cred_ssh_interactive_cb prompt_callback;
-
- void *payload; /**< Payload passed to prompt_callback */
-};
-
-/**
- * A key with a custom signature function
- */
-struct git_cred_ssh_custom {
- git_cred parent; /**< The parent cred */
- char *username; /**< The username to authenticate as */
- char *publickey; /**< The public key data */
- size_t publickey_len; /**< Length of the public key */
-
- /**
- * Callback used to sign the data.
- */
- git_cred_sign_cb sign_callback;
-
- void *payload; /**< Payload passed to prompt_callback */
-};
-
-GIT_END_DECL
+/* These declarations have moved. */
+#ifndef GIT_DEPRECATE_HARD
+# include "git2/sys/credential.h"
+#endif
#endif
diff --git a/include/git2/sys/credential.h b/include/git2/sys/credential.h
new file mode 100644
index 0000000..bb4c9f9
--- /dev/null
+++ b/include/git2/sys/credential.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_credential_h__
+#define INCLUDE_sys_git_credential_h__
+
+#include "git2/common.h"
+#include "git2/credential.h"
+
+/**
+ * @file git2/sys/cred.h
+ * @brief Git credentials low-level implementation
+ * @defgroup git_credential Git credentials low-level implementation
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * The base structure for all credential types
+ */
+struct git_credential {
+ git_credential_t credtype; /**< A type of credential */
+
+ /** The deallocator for this type of credentials */
+ void GIT_CALLBACK(free)(git_credential *cred);
+};
+
+/** A plaintext username and password */
+struct git_credential_userpass_plaintext {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *password; /**< The password to use */
+};
+
+/** Username-only credential information */
+struct git_credential_username {
+ git_credential parent; /**< The parent credential */
+ char username[1]; /**< The username to authenticate as */
+};
+
+/**
+ * A ssh key from disk
+ */
+struct git_credential_ssh_key {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The path to a public key */
+ char *privatekey; /**< The path to a private key */
+ char *passphrase; /**< Passphrase to decrypt the private key */
+};
+
+/**
+ * Keyboard-interactive based ssh authentication
+ */
+struct git_credential_ssh_interactive {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+
+ /**
+ * Callback used for authentication.
+ */
+ git_credential_ssh_interactive_cb prompt_callback;
+
+ void *payload; /**< Payload passed to prompt_callback */
+};
+
+/**
+ * A key with a custom signature function
+ */
+struct git_credential_ssh_custom {
+ git_credential parent; /**< The parent credential */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The public key data */
+ size_t publickey_len; /**< Length of the public key */
+
+ /**
+ * Callback used to sign the data.
+ */
+ git_credential_sign_cb sign_callback;
+
+ void *payload; /**< Payload passed to prompt_callback */
+};
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index d7c7313..6cee42f 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -55,7 +55,7 @@ struct git_transport {
int GIT_CALLBACK(connect)(
git_transport *transport,
const char *url,
- git_cred_acquire_cb cred_acquire_cb,
+ git_credential_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
const git_proxy_options *proxy_opts,
int direction,
@@ -266,7 +266,7 @@ GIT_EXTERN(int) git_transport_smart_certificate_check(git_transport *transport,
* refused to provide credentials and callers should behave as if no
* callback was set), or < 0 for an error
*/
-GIT_EXTERN(int) git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods);
+GIT_EXTERN(int) git_transport_smart_credentials(git_credential **out, git_transport *transport, const char *user, int methods);
/**
* Get a copy of the proxy options
diff --git a/include/git2/transport.h b/include/git2/transport.h
index b99bb30..fc99ce8 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -11,7 +11,7 @@
#include "net.h"
#include "types.h"
#include "cert.h"
-#include "cred.h"
+#include "credential.h"
/**
* @file git2/transport.h
diff --git a/src/remote.c b/src/remote.c
index 19aa45d..ae67fa4 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -710,7 +710,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
int flags = GIT_TRANSPORTFLAGS_NONE;
int error;
void *payload = NULL;
- git_cred_acquire_cb credentials = NULL;
+ git_credential_acquire_cb credentials = NULL;
git_transport_cb transport = NULL;
assert(remote);
diff --git a/src/transports/auth.c b/src/transports/auth.c
index b5f9b40..4aa3df0 100644
--- a/src/transports/auth.c
+++ b/src/transports/auth.c
@@ -9,25 +9,25 @@
#include "git2.h"
#include "buffer.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
static int basic_next_token(
git_buf *out,
git_http_auth_context *ctx,
- git_cred *c)
+ git_credential *c)
{
- git_cred_userpass_plaintext *cred;
+ git_credential_userpass_plaintext *cred;
git_buf raw = GIT_BUF_INIT;
int error = -1;
GIT_UNUSED(ctx);
- if (c->credtype != GIT_CREDTYPE_USERPASS_PLAINTEXT) {
+ if (c->credtype != GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
git_error_set(GIT_ERROR_INVALID, "invalid credential type for basic auth");
goto on_error;
}
- cred = (git_cred_userpass_plaintext *)c;
+ cred = (git_credential_userpass_plaintext *)c;
git_buf_printf(&raw, "%s:%s", cred->username, cred->password);
@@ -48,7 +48,7 @@ on_error:
static git_http_auth_context basic_context = {
GIT_HTTP_AUTH_BASIC,
- GIT_CREDTYPE_USERPASS_PLAINTEXT,
+ GIT_CREDENTIAL_USERPASS_PLAINTEXT,
0,
NULL,
basic_next_token,
diff --git a/src/transports/auth.h b/src/transports/auth.h
index 7624676..9caac46 100644
--- a/src/transports/auth.h
+++ b/src/transports/auth.h
@@ -26,7 +26,7 @@ struct git_http_auth_context {
git_http_auth_t type;
/** Supported credentials */
- git_credtype_t credtypes;
+ git_credential_t credtypes;
/** Connection affinity or request affinity */
unsigned connection_affinity : 1;
@@ -35,7 +35,7 @@ struct git_http_auth_context {
int (*set_challenge)(git_http_auth_context *ctx, const char *challenge);
/** Gets the next authentication token from the context */
- int (*next_token)(git_buf *out, git_http_auth_context *ctx, git_cred *cred);
+ int (*next_token)(git_buf *out, git_http_auth_context *ctx, git_credential *cred);
/** Examines if all tokens have been presented. */
int (*is_complete)(git_http_auth_context *ctx);
@@ -52,7 +52,7 @@ typedef struct {
const char *name;
/** Credential types this scheme supports */
- git_credtype_t credtypes;
+ git_credential_t credtypes;
/** Function to initialize an authentication context */
int (*init_context)(
diff --git a/src/transports/auth_negotiate.c b/src/transports/auth_negotiate.c
index 8fa44cd..8a614b8 100644
--- a/src/transports/auth_negotiate.c
+++ b/src/transports/auth_negotiate.c
@@ -12,7 +12,7 @@
#include "git2.h"
#include "buffer.h"
#include "auth.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
#ifdef GIT_GSSFRAMEWORK
#import <GSS/GSS.h>
@@ -94,7 +94,7 @@ static void negotiate_context_dispose(http_auth_negotiate_context *ctx)
static int negotiate_next_token(
git_buf *buf,
git_http_auth_context *c,
- git_cred *cred)
+ git_credential *cred)
{
http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c;
OM_uint32 status_major, status_minor;
@@ -108,7 +108,7 @@ static int negotiate_next_token(
size_t challenge_len;
int error = 0;
- assert(buf && ctx && ctx->configured && cred && cred->credtype == GIT_CREDTYPE_DEFAULT);
+ assert(buf && ctx && ctx->configured && cred && cred->credtype == GIT_CREDENTIAL_DEFAULT);
if (ctx->complete)
return 0;
@@ -292,7 +292,7 @@ int git_http_auth_negotiate(
}
ctx->parent.type = GIT_HTTP_AUTH_NEGOTIATE;
- ctx->parent.credtypes = GIT_CREDTYPE_DEFAULT;
+ ctx->parent.credtypes = GIT_CREDENTIAL_DEFAULT;
ctx->parent.connection_affinity = 1;
ctx->parent.set_challenge = negotiate_set_challenge;
ctx->parent.next_token = negotiate_next_token;
diff --git a/src/transports/auth_ntlm.c b/src/transports/auth_ntlm.c
index 7d9c597..02a861f 100644
--- a/src/transports/auth_ntlm.c
+++ b/src/transports/auth_ntlm.c
@@ -10,7 +10,7 @@
#include "buffer.h"
#include "auth.h"
#include "auth_ntlm.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
#ifdef GIT_NTLM
@@ -39,15 +39,15 @@ static int ntlm_set_challenge(
return 0;
}
-static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_cred *_cred)
+static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_credential *_cred)
{
- git_cred_userpass_plaintext *cred;
+ git_credential_userpass_plaintext *cred;
const char *sep, *username;
char *domain = NULL, *domainuser = NULL;
int error = 0;
- assert(_cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT);
- cred = (git_cred_userpass_plaintext *)_cred;
+ assert(_cred->credtype == GIT_CREDENTIAL_USERPASS_PLAINTEXT);
+ cred = (git_credential_userpass_plaintext *)_cred;
if ((sep = strchr(cred->username, '\\')) != NULL) {
domain = strndup(cred->username, (sep - cred->username));
@@ -78,7 +78,7 @@ done:
static int ntlm_next_token(
git_buf *buf,
git_http_auth_context *c,
- git_cred *cred)
+ git_credential *cred)
{
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
git_buf input_buf = GIT_BUF_INIT;
@@ -208,7 +208,7 @@ int git_http_auth_ntlm(
}
ctx->parent.type = GIT_HTTP_AUTH_NTLM;
- ctx->parent.credtypes = GIT_CREDTYPE_USERPASS_PLAINTEXT;
+ ctx->parent.credtypes = GIT_CREDENTIAL_USERPASS_PLAINTEXT;
ctx->parent.connection_affinity = 1;
ctx->parent.set_challenge = ntlm_set_challenge;
ctx->parent.next_token = ntlm_next_token;
diff --git a/src/transports/cred.c b/src/transports/cred.c
deleted file mode 100644
index 80c4d36..0000000
--- a/src/transports/cred.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "common.h"
-
-#include "git2/cred.h"
-#include "git2/sys/cred.h"
-#include "git2/cred_helpers.h"
-
-static int git_cred_ssh_key_type_new(
- git_cred **cred,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase,
- git_credtype_t credtype);
-
-int git_cred_has_username(git_cred *cred)
-{
- if (cred->credtype == GIT_CREDTYPE_DEFAULT)
- return 0;
-
- return 1;
-}
-
-const char *git_cred_get_username(git_cred *cred)
-{
- switch (cred->credtype) {
- case GIT_CREDTYPE_USERNAME:
- {
- git_cred_username *c = (git_cred_username *) cred;
- return c->username;
- }
- case GIT_CREDTYPE_USERPASS_PLAINTEXT:
- {
- git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *) cred;
- return c->username;
- }
- case GIT_CREDTYPE_SSH_KEY:
- case GIT_CREDTYPE_SSH_MEMORY:
- {
- git_cred_ssh_key *c = (git_cred_ssh_key *) cred;
- return c->username;
- }
- case GIT_CREDTYPE_SSH_CUSTOM:
- {
- git_cred_ssh_custom *c = (git_cred_ssh_custom *) cred;
- return c->username;
- }
- case GIT_CREDTYPE_SSH_INTERACTIVE:
- {
- git_cred_ssh_interactive *c = (git_cred_ssh_interactive *) cred;
- return c->username;
- }
-
- default:
- return NULL;
- }
-}
-
-static void plaintext_free(struct git_cred *cred)
-{
- git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
-
- git__free(c->username);
-
- /* Zero the memory which previously held the password */
- if (c->password) {
- size_t pass_len = strlen(c->password);
- git__memzero(c->password, pass_len);
- git__free(c->password);
- }
-
- git__free(c);
-}
-
-int git_cred_userpass_plaintext_new(
- git_cred **cred,
- const char *username,
- const char *password)
-{
- git_cred_userpass_plaintext *c;
-
- assert(cred && username && password);
-
- c = git__malloc(sizeof(git_cred_userpass_plaintext));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = GIT_CREDTYPE_USERPASS_PLAINTEXT;
- c->parent.free = plaintext_free;
- c->username = git__strdup(username);
-
- if (!c->username) {
- git__free(c);
- return -1;
- }
-
- c->password = git__strdup(password);
-
- if (!c->password) {
- git__free(c->username);
- git__free(c);
- return -1;
- }
-
- *cred = &c->parent;
- return 0;
-}
-
-static void ssh_key_free(struct git_cred *cred)
-{
- git_cred_ssh_key *c =
- (git_cred_ssh_key *)cred;
-
- git__free(c->username);
-
- if (c->privatekey) {
- /* Zero the memory which previously held the private key */
- size_t key_len = strlen(c->privatekey);
- git__memzero(c->privatekey, key_len);
- git__free(c->privatekey);
- }
-
- if (c->passphrase) {
- /* Zero the memory which previously held the passphrase */
- size_t pass_len = strlen(c->passphrase);
- git__memzero(c->passphrase, pass_len);
- git__free(c->passphrase);
- }
-
- if (c->publickey) {
- /* Zero the memory which previously held the public key */
- size_t key_len = strlen(c->publickey);
- git__memzero(c->publickey, key_len);
- git__free(c->publickey);
- }
-
- git__free(c);
-}
-
-static void ssh_interactive_free(struct git_cred *cred)
-{
- git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred;
-
- git__free(c->username);
-
- git__free(c);
-}
-
-static void ssh_custom_free(struct git_cred *cred)
-{
- git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred;
-
- git__free(c->username);
-
- if (c->publickey) {
- /* Zero the memory which previously held the publickey */
- size_t key_len = strlen(c->publickey);
- git__memzero(c->publickey, key_len);
- git__free(c->publickey);
- }
-
- git__free(c);
-}
-
-static void default_free(struct git_cred *cred)
-{
- git_cred_default *c = (git_cred_default *)cred;
-
- git__free(c);
-}
-
-static void username_free(struct git_cred *cred)
-{
- git__free(cred);
-}
-
-int git_cred_ssh_key_new(
- git_cred **cred,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase)
-{
- return git_cred_ssh_key_type_new(
- cred,
- username,
- publickey,
- privatekey,
- passphrase,
- GIT_CREDTYPE_SSH_KEY);
-}
-
-int git_cred_ssh_key_memory_new(
- git_cred **cred,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase)
-{
-#ifdef GIT_SSH_MEMORY_CREDENTIALS
- return git_cred_ssh_key_type_new(
- cred,
- username,
- publickey,
- privatekey,
- passphrase,
- GIT_CREDTYPE_SSH_MEMORY);
-#else
- GIT_UNUSED(cred);
- GIT_UNUSED(username);
- GIT_UNUSED(publickey);
- GIT_UNUSED(privatekey);
- GIT_UNUSED(passphrase);
-
- git_error_set(GIT_ERROR_INVALID,
- "this version of libgit2 was not built with ssh memory credentials.");
- return -1;
-#endif
-}
-
-static int git_cred_ssh_key_type_new(
- git_cred **cred,
- const char *username,
- const char *publickey,
- const char *privatekey,
- const char *passphrase,
- git_credtype_t credtype)
-{
- git_cred_ssh_key *c;
-
- assert(username && cred && privatekey);
-
- c = git__calloc(1, sizeof(git_cred_ssh_key));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = credtype;
- c->parent.free = ssh_key_free;
-
- c->username = git__strdup(username);
- GIT_ERROR_CHECK_ALLOC(c->username);
-
- c->privatekey = git__strdup(privatekey);
- GIT_ERROR_CHECK_ALLOC(c->privatekey);
-
- if (publickey) {
- c->publickey = git__strdup(publickey);
- GIT_ERROR_CHECK_ALLOC(c->publickey);
- }
-
- if (passphrase) {
- c->passphrase = git__strdup(passphrase);
- GIT_ERROR_CHECK_ALLOC(c->passphrase);
- }
-
- *cred = &c->parent;
- return 0;
-}
-
-int git_cred_ssh_interactive_new(
- git_cred **out,
- const char *username,
- git_cred_ssh_interactive_cb prompt_callback,
- void *payload)
-{
- git_cred_ssh_interactive *c;
-
- assert(out && username && prompt_callback);
-
- c = git__calloc(1, sizeof(git_cred_ssh_interactive));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = GIT_CREDTYPE_SSH_INTERACTIVE;
- c->parent.free = ssh_interactive_free;
-
- c->username = git__strdup(username);
- GIT_ERROR_CHECK_ALLOC(c->username);
-
- c->prompt_callback = prompt_callback;
- c->payload = payload;
-
- *out = &c->parent;
- return 0;
-}
-
-int git_cred_ssh_key_from_agent(git_cred **cred, const char *username) {
- git_cred_ssh_key *c;
-
- assert(username && cred);
-
- c = git__calloc(1, sizeof(git_cred_ssh_key));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = GIT_CREDTYPE_SSH_KEY;
- c->parent.free = ssh_key_free;
-
- c->username = git__strdup(username);
- GIT_ERROR_CHECK_ALLOC(c->username);
-
- c->privatekey = NULL;
-
- *cred = &c->parent;
- return 0;
-}
-
-int git_cred_ssh_custom_new(
- git_cred **cred,
- const char *username,
- const char *publickey,
- size_t publickey_len,
- git_cred_sign_cb sign_callback,
- void *payload)
-{
- git_cred_ssh_custom *c;
-
- assert(username && cred);
-
- c = git__calloc(1, sizeof(git_cred_ssh_custom));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = GIT_CREDTYPE_SSH_CUSTOM;
- c->parent.free = ssh_custom_free;
-
- c->username = git__strdup(username);
- GIT_ERROR_CHECK_ALLOC(c->username);
-
- if (publickey_len > 0) {
- c->publickey = git__malloc(publickey_len);
- GIT_ERROR_CHECK_ALLOC(c->publickey);
-
- memcpy(c->publickey, publickey, publickey_len);
- }
-
- c->publickey_len = publickey_len;
- c->sign_callback = sign_callback;
- c->payload = payload;
-
- *cred = &c->parent;
- return 0;
-}
-
-int git_cred_default_new(git_cred **cred)
-{
- git_cred_default *c;
-
- assert(cred);
-
- c = git__calloc(1, sizeof(git_cred_default));
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->credtype = GIT_CREDTYPE_DEFAULT;
- c->free = default_free;
-
- *cred = c;
- return 0;
-}
-
-int git_cred_username_new(git_cred **cred, const char *username)
-{
- git_cred_username *c;
- size_t len, allocsize;
-
- assert(cred);
-
- len = strlen(username);
-
- GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, sizeof(git_cred_username), len);
- GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, allocsize, 1);
- c = git__malloc(allocsize);
- GIT_ERROR_CHECK_ALLOC(c);
-
- c->parent.credtype = GIT_CREDTYPE_USERNAME;
- c->parent.free = username_free;
- memcpy(c->username, username, len + 1);
-
- *cred = (git_cred *) c;
- return 0;
-}
-
-void git_cred_free(git_cred *cred)
-{
- if (!cred)
- return;
-
- cred->free(cred);
-}
diff --git a/src/transports/cred_helpers.c b/src/transports/cred_helpers.c
deleted file mode 100644
index fdc56b1..0000000
--- a/src/transports/cred_helpers.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "common.h"
-
-#include "git2/cred_helpers.h"
-
-int git_cred_userpass(
- git_cred **cred,
- const char *url,
- const char *user_from_url,
- unsigned int allowed_types,
- void *payload)
-{
- git_cred_userpass_payload *userpass = (git_cred_userpass_payload*)payload;
- const char *effective_username = NULL;
-
- GIT_UNUSED(url);
-
- if (!userpass || !userpass->password) return -1;
-
- /* Username resolution: a username can be passed with the URL, the
- * credentials payload, or both. Here's what we do. Note that if we get
- * this far, we know that any password the url may contain has already
- * failed at least once, so we ignore it.
- *
- * | Payload | URL | Used |
- * +-------------+----------+-----------+
- * | yes | no | payload |
- * | yes | yes | payload |
- * | no | yes | url |
- * | no | no | FAIL |
- */
- if (userpass->username)
- effective_username = userpass->username;
- else if (user_from_url)
- effective_username = user_from_url;
- else
- return -1;
-
- if (GIT_CREDTYPE_USERNAME & allowed_types)
- return git_cred_username_new(cred, effective_username);
-
- if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 ||
- git_cred_userpass_plaintext_new(cred, effective_username, userpass->password) < 0)
- return -1;
-
- return 0;
-}
diff --git a/src/transports/credential.c b/src/transports/credential.c
new file mode 100644
index 0000000..0cf50a0
--- /dev/null
+++ b/src/transports/credential.c
@@ -0,0 +1,476 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "common.h"
+
+#include "git2/credential.h"
+#include "git2/sys/credential.h"
+#include "git2/credential_helpers.h"
+
+static int git_credential_ssh_key_type_new(
+ git_credential **cred,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase,
+ git_credential_t credtype);
+
+int git_credential_has_username(git_credential *cred)
+{
+ if (cred->credtype == GIT_CREDENTIAL_DEFAULT)
+ return 0;
+
+ return 1;
+}
+
+const char *git_credential_get_username(git_credential *cred)
+{
+ switch (cred->credtype) {
+ case GIT_CREDENTIAL_USERNAME:
+ {
+ git_credential_username *c = (git_credential_username *) cred;
+ return c->username;
+ }
+ case GIT_CREDENTIAL_USERPASS_PLAINTEXT:
+ {
+ git_credential_userpass_plaintext *c = (git_credential_userpass_plaintext *) cred;
+ return c->username;
+ }
+ case GIT_CREDENTIAL_SSH_KEY:
+ case GIT_CREDENTIAL_SSH_MEMORY:
+ {
+ git_credential_ssh_key *c = (git_credential_ssh_key *) cred;
+ return c->username;
+ }
+ case GIT_CREDENTIAL_SSH_CUSTOM:
+ {
+ git_credential_ssh_custom *c = (git_credential_ssh_custom *) cred;
+ return c->username;
+ }
+ case GIT_CREDENTIAL_SSH_INTERACTIVE:
+ {
+ git_credential_ssh_interactive *c = (git_credential_ssh_interactive *) cred;
+ return c->username;
+ }
+
+ default:
+ return NULL;
+ }
+}
+
+static void plaintext_free(struct git_credential *cred)
+{
+ git_credential_userpass_plaintext *c = (git_credential_userpass_plaintext *)cred;
+
+ git__free(c->username);
+
+ /* Zero the memory which previously held the password */
+ if (c->password) {
+ size_t pass_len = strlen(c->password);
+ git__memzero(c->password, pass_len);
+ git__free(c->password);
+ }
+
+ git__free(c);
+}
+
+int git_credential_userpass_plaintext_new(
+ git_credential **cred,
+ const char *username,
+ const char *password)
+{
+ git_credential_userpass_plaintext *c;
+
+ assert(cred && username && password);
+
+ c = git__malloc(sizeof(git_credential_userpass_plaintext));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = GIT_CREDENTIAL_USERPASS_PLAINTEXT;
+ c->parent.free = plaintext_free;
+ c->username = git__strdup(username);
+
+ if (!c->username) {
+ git__free(c);
+ return -1;
+ }
+
+ c->password = git__strdup(password);
+
+ if (!c->password) {
+ git__free(c->username);
+ git__free(c);
+ return -1;
+ }
+
+ *cred = &c->parent;
+ return 0;
+}
+
+static void ssh_key_free(struct git_credential *cred)
+{
+ git_credential_ssh_key *c =
+ (git_credential_ssh_key *)cred;
+
+ git__free(c->username);
+
+ if (c->privatekey) {
+ /* Zero the memory which previously held the private key */
+ size_t key_len = strlen(c->privatekey);
+ git__memzero(c->privatekey, key_len);
+ git__free(c->privatekey);
+ }
+
+ if (c->passphrase) {
+ /* Zero the memory which previously held the passphrase */
+ size_t pass_len = strlen(c->passphrase);
+ git__memzero(c->passphrase, pass_len);
+ git__free(c->passphrase);
+ }
+
+ if (c->publickey) {
+ /* Zero the memory which previously held the public key */
+ size_t key_len = strlen(c->publickey);
+ git__memzero(c->publickey, key_len);
+ git__free(c->publickey);
+ }
+
+ git__free(c);
+}
+
+static void ssh_interactive_free(struct git_credential *cred)
+{
+ git_credential_ssh_interactive *c = (git_credential_ssh_interactive *)cred;
+
+ git__free(c->username);
+
+ git__free(c);
+}
+
+static void ssh_custom_free(struct git_credential *cred)
+{
+ git_credential_ssh_custom *c = (git_credential_ssh_custom *)cred;
+
+ git__free(c->username);
+
+ if (c->publickey) {
+ /* Zero the memory which previously held the publickey */
+ size_t key_len = strlen(c->publickey);
+ git__memzero(c->publickey, key_len);
+ git__free(c->publickey);
+ }
+
+ git__free(c);
+}
+
+static void default_free(struct git_credential *cred)
+{
+ git_credential_default *c = (git_credential_default *)cred;
+
+ git__free(c);
+}
+
+static void username_free(struct git_credential *cred)
+{
+ git__free(cred);
+}
+
+int git_credential_ssh_key_new(
+ git_credential **cred,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase)
+{
+ return git_credential_ssh_key_type_new(
+ cred,
+ username,
+ publickey,
+ privatekey,
+ passphrase,
+ GIT_CREDENTIAL_SSH_KEY);
+}
+
+int git_credential_ssh_key_memory_new(
+ git_credential **cred,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase)
+{
+#ifdef GIT_SSH_MEMORY_CREDENTIALS
+ return git_credential_ssh_key_type_new(
+ cred,
+ username,
+ publickey,
+ privatekey,
+ passphrase,
+ GIT_CREDENTIAL_SSH_MEMORY);
+#else
+ GIT_UNUSED(cred);
+ GIT_UNUSED(username);
+ GIT_UNUSED(publickey);
+ GIT_UNUSED(privatekey);
+ GIT_UNUSED(passphrase);
+
+ git_error_set(GIT_ERROR_INVALID,
+ "this version of libgit2 was not built with ssh memory credentials.");
+ return -1;
+#endif
+}
+
+static int git_credential_ssh_key_type_new(
+ git_credential **cred,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase,
+ git_credential_t credtype)
+{
+ git_credential_ssh_key *c;
+
+ assert(username && cred && privatekey);
+
+ c = git__calloc(1, sizeof(git_credential_ssh_key));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = credtype;
+ c->parent.free = ssh_key_free;
+
+ c->username = git__strdup(username);
+ GIT_ERROR_CHECK_ALLOC(c->username);
+
+ c->privatekey = git__strdup(privatekey);
+ GIT_ERROR_CHECK_ALLOC(c->privatekey);
+
+ if (publickey) {
+ c->publickey = git__strdup(publickey);
+ GIT_ERROR_CHECK_ALLOC(c->publickey);
+ }
+
+ if (passphrase) {
+ c->passphrase = git__strdup(passphrase);
+ GIT_ERROR_CHECK_ALLOC(c->passphrase);
+ }
+
+ *cred = &c->parent;
+ return 0;
+}
+
+int git_credential_ssh_interactive_new(
+ git_credential **out,
+ const char *username,
+ git_credential_ssh_interactive_cb prompt_callback,
+ void *payload)
+{
+ git_credential_ssh_interactive *c;
+
+ assert(out && username && prompt_callback);
+
+ c = git__calloc(1, sizeof(git_credential_ssh_interactive));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = GIT_CREDENTIAL_SSH_INTERACTIVE;
+ c->parent.free = ssh_interactive_free;
+
+ c->username = git__strdup(username);
+ GIT_ERROR_CHECK_ALLOC(c->username);
+
+ c->prompt_callback = prompt_callback;
+ c->payload = payload;
+
+ *out = &c->parent;
+ return 0;
+}
+
+int git_credential_ssh_key_from_agent(git_credential **cred, const char *username) {
+ git_credential_ssh_key *c;
+
+ assert(username && cred);
+
+ c = git__calloc(1, sizeof(git_credential_ssh_key));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = GIT_CREDENTIAL_SSH_KEY;
+ c->parent.free = ssh_key_free;
+
+ c->username = git__strdup(username);
+ GIT_ERROR_CHECK_ALLOC(c->username);
+
+ c->privatekey = NULL;
+
+ *cred = &c->parent;
+ return 0;
+}
+
+int git_credential_ssh_custom_new(
+ git_credential **cred,
+ const char *username,
+ const char *publickey,
+ size_t publickey_len,
+ git_credential_sign_cb sign_callback,
+ void *payload)
+{
+ git_credential_ssh_custom *c;
+
+ assert(username && cred);
+
+ c = git__calloc(1, sizeof(git_credential_ssh_custom));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = GIT_CREDENTIAL_SSH_CUSTOM;
+ c->parent.free = ssh_custom_free;
+
+ c->username = git__strdup(username);
+ GIT_ERROR_CHECK_ALLOC(c->username);
+
+ if (publickey_len > 0) {
+ c->publickey = git__malloc(publickey_len);
+ GIT_ERROR_CHECK_ALLOC(c->publickey);
+
+ memcpy(c->publickey, publickey, publickey_len);
+ }
+
+ c->publickey_len = publickey_len;
+ c->sign_callback = sign_callback;
+ c->payload = payload;
+
+ *cred = &c->parent;
+ return 0;
+}
+
+int git_credential_default_new(git_credential **cred)
+{
+ git_credential_default *c;
+
+ assert(cred);
+
+ c = git__calloc(1, sizeof(git_credential_default));
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->credtype = GIT_CREDENTIAL_DEFAULT;
+ c->free = default_free;
+
+ *cred = c;
+ return 0;
+}
+
+int git_credential_username_new(git_credential **cred, const char *username)
+{
+ git_credential_username *c;
+ size_t len, allocsize;
+
+ assert(cred);
+
+ len = strlen(username);
+
+ GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, sizeof(git_credential_username), len);
+ GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, allocsize, 1);
+ c = git__malloc(allocsize);
+ GIT_ERROR_CHECK_ALLOC(c);
+
+ c->parent.credtype = GIT_CREDENTIAL_USERNAME;
+ c->parent.free = username_free;
+ memcpy(c->username, username, len + 1);
+
+ *cred = (git_credential *) c;
+ return 0;
+}
+
+void git_credential_free(git_credential *cred)
+{
+ if (!cred)
+ return;
+
+ cred->free(cred);
+}
+
+/* Deprecated credential functions */
+
+int git_cred_has_username(git_credential *cred)
+{
+ return git_credential_has_username(cred);
+}
+
+const char *git_cred_get_username(git_credential *cred)
+{
+ return git_credential_get_username(cred);
+}
+
+int git_cred_userpass_plaintext_new(
+ git_credential **out,
+ const char *username,
+ const char *password)
+{
+ return git_credential_userpass_plaintext_new(out,username, password);
+}
+
+int git_cred_default_new(git_credential **out)
+{
+ return git_credential_default_new(out);
+}
+
+int git_cred_username_new(git_credential **out, const char *username)
+{
+ return git_credential_username_new(out, username);
+}
+
+int git_cred_ssh_key_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase)
+{
+ return git_credential_ssh_key_new(out, username,
+ publickey, privatekey, passphrase);
+}
+
+int git_cred_ssh_key_memory_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ const char *privatekey,
+ const char *passphrase)
+{
+ return git_credential_ssh_key_memory_new(out, username,
+ publickey, privatekey, passphrase);
+}
+
+int git_cred_ssh_interactive_new(
+ git_credential **out,
+ const char *username,
+ git_credential_ssh_interactive_cb prompt_callback,
+ void *payload)
+{
+ return git_credential_ssh_interactive_new(out, username,
+ prompt_callback, payload);
+}
+
+int git_cred_ssh_key_from_agent(
+ git_credential **out,
+ const char *username)
+{
+ return git_credential_ssh_key_from_agent(out, username);
+}
+
+int git_cred_ssh_custom_new(
+ git_credential **out,
+ const char *username,
+ const char *publickey,
+ size_t publickey_len,
+ git_credential_sign_cb sign_callback,
+ void *payload)
+{
+ return git_credential_ssh_custom_new(out, username,
+ publickey, publickey_len, sign_callback, payload);
+}
+
+void git_cred_free(git_credential *cred)
+{
+ git_credential_free(cred);
+}
diff --git a/src/transports/credential_helpers.c b/src/transports/credential_helpers.c
new file mode 100644
index 0000000..6b975e1
--- /dev/null
+++ b/src/transports/credential_helpers.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "common.h"
+
+#include "git2/credential_helpers.h"
+
+int git_credential_userpass(
+ git_credential **cred,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload)
+{
+ git_credential_userpass_payload *userpass = (git_credential_userpass_payload*)payload;
+ const char *effective_username = NULL;
+
+ GIT_UNUSED(url);
+
+ if (!userpass || !userpass->password) return -1;
+
+ /* Username resolution: a username can be passed with the URL, the
+ * credentials payload, or both. Here's what we do. Note that if we get
+ * this far, we know that any password the url may contain has already
+ * failed at least once, so we ignore it.
+ *
+ * | Payload | URL | Used |
+ * +-------------+----------+-----------+
+ * | yes | no | payload |
+ * | yes | yes | payload |
+ * | no | yes | url |
+ * | no | no | FAIL |
+ */
+ if (userpass->username)
+ effective_username = userpass->username;
+ else if (user_from_url)
+ effective_username = user_from_url;
+ else
+ return -1;
+
+ if (GIT_CREDENTIAL_USERNAME & allowed_types)
+ return git_credential_username_new(cred, effective_username);
+
+ if ((GIT_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) == 0 ||
+ git_credential_userpass_plaintext_new(cred, effective_username, userpass->password) < 0)
+ return -1;
+
+ return 0;
+}
+
+/* Deprecated credential functions */
+
+int git_cred_userpass(
+ git_credential **out,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload)
+{
+ return git_credential_userpass(out, url, user_from_url,
+ allowed_types, payload);
+}
diff --git a/src/transports/http.c b/src/transports/http.c
index 36f038e..294bab5 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -16,7 +16,7 @@
#include "netops.h"
#include "global.h"
#include "remote.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
#include "smart.h"
#include "auth.h"
#include "http.h"
@@ -54,7 +54,7 @@ typedef struct {
typedef struct {
git_net_url url;
- git_cred *cred;
+ git_credential *cred;
unsigned auth_schemetypes;
unsigned url_cred_presented : 1;
} http_server;
@@ -100,24 +100,24 @@ static const http_service receive_pack_service = {
#define OWNING_SUBTRANSPORT(s) ((http_subtransport *)(s)->parent.subtransport)
static int apply_url_credentials(
- git_cred **cred,
+ git_credential **cred,
unsigned int allowed_types,
const char *username,
const char *password)
{
- if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)
- return git_cred_userpass_plaintext_new(cred, username, password);
+ if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT)
+ return git_credential_userpass_plaintext_new(cred, username, password);
- if ((allowed_types & GIT_CREDTYPE_DEFAULT) && *username == '\0' && *password == '\0')
- return git_cred_default_new(cred);
+ if ((allowed_types & GIT_CREDENTIAL_DEFAULT) && *username == '\0' && *password == '\0')
+ return git_credential_default_new(cred);
return GIT_PASSTHROUGH;
}
-GIT_INLINE(void) free_cred(git_cred **cred)
+GIT_INLINE(void) free_cred(git_credential **cred)
{
if (*cred) {
- git_cred_free(*cred);
+ git_credential_free(*cred);
(*cred) = NULL;
}
}
@@ -128,7 +128,7 @@ static int handle_auth(
const char *url,
unsigned int allowed_schemetypes,
unsigned int allowed_credtypes,
- git_cred_acquire_cb callback,
+ git_credential_acquire_cb callback,
void *callback_payload)
{
int error = 1;
@@ -137,7 +137,7 @@ static int handle_auth(
free_cred(&server->cred);
/* Start with URL-specified credentials, if there were any. */
- if ((allowed_credtypes & GIT_CREDTYPE_USERPASS_PLAINTEXT) &&
+ if ((allowed_credtypes & GIT_CREDENTIAL_USERPASS_PLAINTEXT) &&
!server->url_cred_presented &&
server->url.username &&
server->url.password) {
diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c
index 7f44a26..f5c2ce5 100644
--- a/src/transports/httpclient.c
+++ b/src/transports/httpclient.c
@@ -16,7 +16,7 @@
#include "auth.h"
#include "auth_negotiate.h"
#include "auth_ntlm.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
#include "net.h"
#include "stream.h"
#include "streams/socket.h"
@@ -24,9 +24,9 @@
#include "auth.h"
static git_http_auth_scheme auth_schemes[] = {
- { GIT_HTTP_AUTH_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate },
- { GIT_HTTP_AUTH_NTLM, "NTLM", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_ntlm },
- { GIT_HTTP_AUTH_BASIC, "Basic", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_basic },
+ { GIT_HTTP_AUTH_NEGOTIATE, "Negotiate", GIT_CREDENTIAL_DEFAULT, git_http_auth_negotiate },
+ { GIT_HTTP_AUTH_NTLM, "NTLM", GIT_CREDENTIAL_USERPASS_PLAINTEXT, git_http_auth_ntlm },
+ { GIT_HTTP_AUTH_BASIC, "Basic", GIT_CREDENTIAL_USERPASS_PLAINTEXT, git_http_auth_basic },
};
#define GIT_READ_BUFFER_SIZE 8192
@@ -456,7 +456,7 @@ static bool best_scheme_and_challenge(
git_http_auth_scheme **scheme_out,
const char **challenge_out,
git_vector *challenges,
- git_cred *credentials)
+ git_credential *credentials)
{
const char *challenge;
size_t i, j;
@@ -504,7 +504,7 @@ static const char *challenge_for_context(
static const char *init_auth_context(
git_http_server *server,
git_vector *challenges,
- git_cred *credentials)
+ git_credential *credentials)
{
git_http_auth_scheme *scheme;
const char *challenge;
@@ -540,7 +540,7 @@ static int apply_credentials(
git_buf *buf,
git_http_server *server,
const char *header_name,
- git_cred *credentials)
+ git_credential *credentials)
{
git_http_auth_context *auth = server->auth_context;
git_vector *challenges = &server->auth_challenges;
diff --git a/src/transports/httpclient.h b/src/transports/httpclient.h
index da764fd..2a83bee 100644
--- a/src/transports/httpclient.h
+++ b/src/transports/httpclient.h
@@ -32,21 +32,21 @@ typedef enum {
/** An HTTP request */
typedef struct {
- git_http_method method; /**< Method for the request */
- git_net_url *url; /**< Full request URL */
- git_net_url *proxy; /**< Proxy to use */
+ git_http_method method; /**< Method for the request */
+ git_net_url *url; /**< Full request URL */
+ git_net_url *proxy; /**< Proxy to use */
/* Headers */
- const char *accept; /**< Contents of the Accept header */
- const char *content_type; /**< Content-Type header (for POST) */
- git_cred *credentials; /**< Credentials to authenticate with */
- git_cred *proxy_credentials; /**< Credentials for proxy */
- git_strarray *custom_headers; /**< Additional headers to deliver */
+ const char *accept; /**< Contents of the Accept header */
+ const char *content_type; /**< Content-Type header (for POST) */
+ git_credential *credentials; /**< Credentials to authenticate with */
+ git_credential *proxy_credentials; /**< Credentials for proxy */
+ git_strarray *custom_headers; /**< Additional headers to deliver */
/* To POST a payload, either set content_length OR set chunked. */
- size_t content_length; /**< Length of the POST body */
- unsigned chunked : 1, /**< Post with chunking */
- expect_continue : 1; /**< Use expect/continue negotiation */
+ size_t content_length; /**< Length of the POST body */
+ unsigned chunked : 1, /**< Post with chunking */
+ expect_continue : 1; /**< Use expect/continue negotiation */
} git_http_request;
typedef struct {
diff --git a/src/transports/local.c b/src/transports/local.c
index cfc6c2a..24af7f0 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -201,7 +201,7 @@ on_error:
static int local_connect(
git_transport *transport,
const char *url,
- git_cred_acquire_cb cred_acquire_cb,
+ git_credential_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
const git_proxy_options *proxy,
int direction, int flags)
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 8e8af00..bb4d2a2 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -206,7 +206,7 @@ static void free_symrefs(git_vector *symrefs)
static int git_smart__connect(
git_transport *transport,
const char *url,
- git_cred_acquire_cb cred_acquire_cb,
+ git_credential_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
const git_proxy_options *proxy,
int direction,
@@ -489,7 +489,7 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
return t->certificate_check_cb(cert, valid, hostname, t->message_cb_payload);
}
-int git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods)
+int git_transport_smart_credentials(git_credential **out, git_transport *transport, const char *user, int methods)
{
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 53e9773..18e0b7e 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -137,7 +137,7 @@ typedef struct {
git_transport parent;
git_remote *owner;
char *url;
- git_cred_acquire_cb cred_acquire_cb;
+ git_credential_acquire_cb cred_acquire_cb;
void *cred_acquire_payload;
git_proxy_options proxy;
int direction;
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 18d90a9..68b3cbe 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -19,8 +19,8 @@
#include "smart.h"
#include "streams/socket.h"
-#include "git2/cred.h"
-#include "git2/sys/cred.h"
+#include "git2/credential.h"
+#include "git2/sys/credential.h"
#ifdef GIT_SSH
@@ -45,7 +45,7 @@ typedef struct {
git_smart_subtransport parent;
transport_smart *owner;
ssh_stream *current_stream;
- git_cred *cred;
+ git_credential *cred;
char *cmd_uploadpack;
char *cmd_receivepack;
} ssh_subtransport;
@@ -291,7 +291,7 @@ static int git_ssh_extract_url_parts(
return 0;
}
-static int ssh_agent_auth(LIBSSH2_SESSION *session, git_cred_ssh_key *c) {
+static int ssh_agent_auth(LIBSSH2_SESSION *session, git_credential_ssh_key *c) {
int rc = LIBSSH2_ERROR_NONE;
struct libssh2_agent_publickey *curr, *prev = NULL;
@@ -346,21 +346,21 @@ shutdown:
}
static int _git_ssh_authenticate_session(
- LIBSSH2_SESSION* session,
- git_cred* cred)
+ LIBSSH2_SESSION *session,
+ git_credential *cred)
{
int rc;
do {
git_error_clear();
switch (cred->credtype) {
- case GIT_CREDTYPE_USERPASS_PLAINTEXT: {
- git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
+ case GIT_CREDENTIAL_USERPASS_PLAINTEXT: {
+ git_credential_userpass_plaintext *c = (git_credential_userpass_plaintext *)cred;
rc = libssh2_userauth_password(session, c->username, c->password);
break;
}
- case GIT_CREDTYPE_SSH_KEY: {
- git_cred_ssh_key *c = (git_cred_ssh_key *)cred;
+ case GIT_CREDENTIAL_SSH_KEY: {
+ git_credential_ssh_key *c = (git_credential_ssh_key *)cred;
if (c->privatekey)
rc = libssh2_userauth_publickey_fromfile(
@@ -371,17 +371,17 @@ static int _git_ssh_authenticate_session(
break;
}
- case GIT_CREDTYPE_SSH_CUSTOM: {
- git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred;
+ case GIT_CREDENTIAL_SSH_CUSTOM: {
+ git_credential_ssh_custom *c = (git_credential_ssh_custom *)cred;
rc = libssh2_userauth_publickey(
session, c->username, (const unsigned char *)c->publickey,
c->publickey_len, c->sign_callback, &c->payload);
break;
}
- case GIT_CREDTYPE_SSH_INTERACTIVE: {
+ case GIT_CREDENTIAL_SSH_INTERACTIVE: {
void **abstract = libssh2_session_abstract(session);
- git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred;
+ git_credential_ssh_interactive *c = (git_credential_ssh_interactive *)cred;
/* ideally, we should be able to set this by calling
* libssh2_session_init_ex() instead of libssh2_session_init().
@@ -401,8 +401,8 @@ static int _git_ssh_authenticate_session(
break;
}
#ifdef GIT_SSH_MEMORY_CREDENTIALS
- case GIT_CREDTYPE_SSH_MEMORY: {
- git_cred_ssh_key *c = (git_cred_ssh_key *)cred;
+ case GIT_CREDENTIAL_SSH_MEMORY: {
+ git_credential_ssh_key *c = (git_credential_ssh_key *)cred;
assert(c->username);
assert(c->privatekey);
@@ -438,10 +438,10 @@ static int _git_ssh_authenticate_session(
return 0;
}
-static int request_creds(git_cred **out, ssh_subtransport *t, const char *user, int auth_methods)
+static int request_creds(git_credential **out, ssh_subtransport *t, const char *user, int auth_methods)
{
int error, no_callback = 0;
- git_cred *cred = NULL;
+ git_credential *cred = NULL;
if (!t->owner->cred_acquire_cb) {
no_callback = 1;
@@ -520,7 +520,7 @@ static int _git_ssh_setup_conn(
int auth_methods, error = 0;
size_t i;
ssh_stream *s;
- git_cred *cred = NULL;
+ git_credential *cred = NULL;
LIBSSH2_SESSION* session=NULL;
LIBSSH2_CHANNEL* channel=NULL;
@@ -609,16 +609,16 @@ post_extract:
/* we need the username to ask for auth methods */
if (!urldata.username) {
- if ((error = request_creds(&cred, t, NULL, GIT_CREDTYPE_USERNAME)) < 0)
+ if ((error = request_creds(&cred, t, NULL, GIT_CREDENTIAL_USERNAME)) < 0)
goto done;
- urldata.username = git__strdup(((git_cred_username *) cred)->username);
+ urldata.username = git__strdup(((git_credential_username *) cred)->username);
cred->free(cred);
cred = NULL;
if (!urldata.username)
goto done;
} else if (urldata.username && urldata.password) {
- if ((error = git_cred_userpass_plaintext_new(&cred, urldata.username, urldata.password)) < 0)
+ if ((error = git_credential_userpass_plaintext_new(&cred, urldata.username, urldata.password)) < 0)
goto done;
}
@@ -639,7 +639,7 @@ post_extract:
if ((error = request_creds(&cred, t, urldata.username, auth_methods)) < 0)
goto done;
- if (strcmp(urldata.username, git_cred_get_username(cred))) {
+ if (strcmp(urldata.username, git_credential_get_username(cred))) {
git_error_set(GIT_ERROR_SSH, "username does not match previous request");
error = -1;
goto done;
@@ -814,23 +814,23 @@ static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *use
ptr++;
if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) {
- *out |= GIT_CREDTYPE_SSH_KEY;
- *out |= GIT_CREDTYPE_SSH_CUSTOM;
+ *out |= GIT_CREDENTIAL_SSH_KEY;
+ *out |= GIT_CREDENTIAL_SSH_CUSTOM;
#ifdef GIT_SSH_MEMORY_CREDENTIALS
- *out |= GIT_CREDTYPE_SSH_MEMORY;
+ *out |= GIT_CREDENTIAL_SSH_MEMORY;
#endif
ptr += strlen(SSH_AUTH_PUBLICKEY);
continue;
}
if (!git__prefixcmp(ptr, SSH_AUTH_PASSWORD)) {
- *out |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
+ *out |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
ptr += strlen(SSH_AUTH_PASSWORD);
continue;
}
if (!git__prefixcmp(ptr, SSH_AUTH_KEYBOARD_INTERACTIVE)) {
- *out |= GIT_CREDTYPE_SSH_INTERACTIVE;
+ *out |= GIT_CREDENTIAL_SSH_INTERACTIVE;
ptr += strlen(SSH_AUTH_KEYBOARD_INTERACTIVE);
continue;
}
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index e9e53ae..ee8cb15 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -19,7 +19,7 @@
#include "repository.h"
#include "global.h"
#include "http.h"
-#include "git2/sys/cred.h"
+#include "git2/sys/credential.h"
#include <wincrypt.h>
#include <winhttp.h>
@@ -113,7 +113,7 @@ typedef struct {
typedef struct {
git_net_url url;
- git_cred *cred;
+ git_credential *cred;
int auth_mechanisms;
bool url_cred_presented;
} winhttp_server;
@@ -129,9 +129,9 @@ typedef struct {
HINTERNET connection;
} winhttp_subtransport;
-static int apply_userpass_credentials(HINTERNET request, DWORD target, int mechanisms, git_cred *cred)
+static int apply_userpass_credentials(HINTERNET request, DWORD target, int mechanisms, git_credential *cred)
{
- git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
+ git_credential_userpass_plaintext *c = (git_credential_userpass_plaintext *)cred;
wchar_t *user = NULL, *pass = NULL;
int user_len = 0, pass_len = 0, error = 0;
DWORD native_scheme;
@@ -206,22 +206,22 @@ static int apply_default_credentials(HINTERNET request, DWORD target, int mechan
}
static int acquire_url_cred(
- git_cred **cred,
+ git_credential **cred,
unsigned int allowed_types,
const char *username,
const char *password)
{
- if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)
- return git_cred_userpass_plaintext_new(cred, username, password);
+ if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT)
+ return git_credential_userpass_plaintext_new(cred, username, password);
- if ((allowed_types & GIT_CREDTYPE_DEFAULT) && *username == '\0' && *password == '\0')
- return git_cred_default_new(cred);
+ if ((allowed_types & GIT_CREDENTIAL_DEFAULT) && *username == '\0' && *password == '\0')
+ return git_credential_default_new(cred);
return 1;
}
static int acquire_fallback_cred(
- git_cred **cred,
+ git_credential **cred,
const char *url,
unsigned int allowed_types)
{
@@ -229,7 +229,7 @@ static int acquire_fallback_cred(
/* If the target URI supports integrated Windows authentication
* as an authentication mechanism */
- if (GIT_CREDTYPE_DEFAULT & allowed_types) {
+ if (GIT_CREDENTIAL_DEFAULT & allowed_types) {
wchar_t *wide_url;
HRESULT hCoInitResult;
@@ -253,13 +253,13 @@ static int acquire_fallback_cred(
(URLZONE_LOCAL_MACHINE == dwZone ||
URLZONE_INTRANET == dwZone ||
URLZONE_TRUSTED == dwZone)) {
- git_cred *existing = *cred;
+ git_credential *existing = *cred;
if (existing)
existing->free(existing);
/* Then use default Windows credentials to authenticate this request */
- error = git_cred_default_new(cred);
+ error = git_credential_default_new(cred);
}
pISM->lpVtbl->Release(pISM);
@@ -345,7 +345,7 @@ static int apply_credentials(
HINTERNET request,
git_net_url *url,
int target,
- git_cred *creds,
+ git_credential *creds,
int mechanisms)
{
int error = 0;
@@ -353,9 +353,9 @@ static int apply_credentials(
GIT_UNUSED(url);
/* If we have creds, just apply them */
- if (creds && creds->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT)
+ if (creds && creds->credtype == GIT_CREDENTIAL_USERPASS_PLAINTEXT)
error = apply_userpass_credentials(request, target, mechanisms, creds);
- else if (creds && creds->credtype == GIT_CREDTYPE_DEFAULT)
+ else if (creds && creds->credtype == GIT_CREDENTIAL_DEFAULT)
error = apply_default_credentials(request, target, mechanisms);
return error;
@@ -606,23 +606,23 @@ static int parse_unauthorized_response(
}
if (WINHTTP_AUTH_SCHEME_NTLM & supported) {
- *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
- *allowed_types |= GIT_CREDTYPE_DEFAULT;
+ *allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
+ *allowed_types |= GIT_CREDENTIAL_DEFAULT;
*allowed_mechanisms |= GIT_WINHTTP_AUTH_NTLM;
}
if (WINHTTP_AUTH_SCHEME_NEGOTIATE & supported) {
- *allowed_types |= GIT_CREDTYPE_DEFAULT;
+ *allowed_types |= GIT_CREDENTIAL_DEFAULT;
*allowed_mechanisms |= GIT_WINHTTP_AUTH_NEGOTIATE;
}
if (WINHTTP_AUTH_SCHEME_BASIC & supported) {
- *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
+ *allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
*allowed_mechanisms |= GIT_WINHTTP_AUTH_BASIC;
}
if (WINHTTP_AUTH_SCHEME_DIGEST & supported) {
- *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT;
+ *allowed_types |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
*allowed_mechanisms |= GIT_WINHTTP_AUTH_DIGEST;
}
@@ -907,7 +907,7 @@ static int acquire_credentials(
HINTERNET request,
winhttp_server *server,
const char *url_str,
- git_cred_acquire_cb cred_cb,
+ git_credential_acquire_cb cred_cb,
void *cred_cb_payload)
{
int allowed_types;
@@ -917,7 +917,7 @@ static int acquire_credentials(
return -1;
if (allowed_types) {
- git_cred_free(server->cred);
+ git_credential_free(server->cred);
server->cred = NULL;
/* Start with URL-specified credentials, if there were any. */
@@ -933,7 +933,7 @@ static int acquire_credentials(
if (error > 0 && cred_cb) {
error = cred_cb(&server->cred, url_str, server->url.username, allowed_types, cred_cb_payload);
- /* Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set */
+ /* Treat GIT_PASSTHROUGH as though git_credential_acquire_cb isn't set */
if (error == GIT_PASSTHROUGH)
error = 1;
else if (error < 0)
diff --git a/tests/network/cred.c b/tests/network/cred.c
index d35e2b2..5e4db75 100644
--- a/tests/network/cred.c
+++ b/tests/network/cred.c
@@ -4,43 +4,43 @@
void test_network_cred__stock_userpass_validates_args(void)
{
- git_cred_userpass_payload payload = {0};
+ git_credential_userpass_payload payload = {0};
- cl_git_fail(git_cred_userpass(NULL, NULL, NULL, 0, NULL));
+ cl_git_fail(git_credential_userpass(NULL, NULL, NULL, 0, NULL));
payload.username = "user";
- cl_git_fail(git_cred_userpass(NULL, NULL, NULL, 0, &payload));
+ cl_git_fail(git_credential_userpass(NULL, NULL, NULL, 0, &payload));
payload.username = NULL;
payload.username = "pass";
- cl_git_fail(git_cred_userpass(NULL, NULL, NULL, 0, &payload));
+ cl_git_fail(git_credential_userpass(NULL, NULL, NULL, 0, &payload));
}
void test_network_cred__stock_userpass_validates_that_method_is_allowed(void)
{
- git_cred *cred;
- git_cred_userpass_payload payload = {"user", "pass"};
+ git_credential *cred;
+ git_credential_userpass_payload payload = {"user", "pass"};
- cl_git_fail(git_cred_userpass(&cred, NULL, NULL, 0, &payload));
- cl_git_pass(git_cred_userpass(&cred, NULL, NULL, GIT_CREDTYPE_USERPASS_PLAINTEXT, &payload));
- git_cred_free(cred);
+ cl_git_fail(git_credential_userpass(&cred, NULL, NULL, 0, &payload));
+ cl_git_pass(git_credential_userpass(&cred, NULL, NULL, GIT_CREDENTIAL_USERPASS_PLAINTEXT, &payload));
+ git_credential_free(cred);
}
void test_network_cred__stock_userpass_properly_handles_username_in_url(void)
{
- git_cred *cred;
- git_cred_userpass_payload payload = {"alice", "password"};
+ git_credential *cred;
+ git_credential_userpass_payload payload = {"alice", "password"};
- cl_git_pass(git_cred_userpass(&cred, NULL, NULL, GIT_CREDTYPE_USERPASS_PLAINTEXT, &payload));
- cl_assert_equal_s("alice", git_cred_get_username(cred));
- git_cred_free(cred);
+ cl_git_pass(git_credential_userpass(&cred, NULL, NULL, GIT_CREDENTIAL_USERPASS_PLAINTEXT, &payload));
+ cl_assert_equal_s("alice", git_credential_get_username(cred));
+ git_credential_free(cred);
- cl_git_pass(git_cred_userpass(&cred, NULL, "bob", GIT_CREDTYPE_USERPASS_PLAINTEXT, &payload));
- cl_assert_equal_s("alice", git_cred_get_username(cred));
- git_cred_free(cred);
+ cl_git_pass(git_credential_userpass(&cred, NULL, "bob", GIT_CREDENTIAL_USERPASS_PLAINTEXT, &payload));
+ cl_assert_equal_s("alice", git_credential_get_username(cred));
+ git_credential_free(cred);
payload.username = NULL;
- cl_git_pass(git_cred_userpass(&cred, NULL, "bob", GIT_CREDTYPE_USERPASS_PLAINTEXT, &payload));
- cl_assert_equal_s("bob", git_cred_get_username(cred));
- git_cred_free(cred);
+ cl_git_pass(git_credential_userpass(&cred, NULL, "bob", GIT_CREDENTIAL_USERPASS_PLAINTEXT, &payload));
+ cl_assert_equal_s("bob", git_credential_get_username(cred));
+ git_credential_free(cred);
}
diff --git a/tests/online/clone.c b/tests/online/clone.c
index aed0ab9..f780f13 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -291,7 +291,7 @@ void test_online_clone__custom_headers(void)
}
static int cred_failure_cb(
- git_cred **cred,
+ git_credential **cred,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
@@ -315,22 +315,22 @@ void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
cl_git_fail_with(-172, git_clone(&g_repo, _remote_url, "./foo", &g_options));
}
-static int cred_count_calls_cb(git_cred **cred, const char *url, const char *user,
+static int cred_count_calls_cb(git_credential **cred, const char *url, const char *user,
unsigned int allowed_types, void *data)
{
size_t *counter = (size_t *) data;
GIT_UNUSED(url); GIT_UNUSED(user); GIT_UNUSED(allowed_types);
- if (allowed_types == GIT_CREDTYPE_USERNAME)
- return git_cred_username_new(cred, "foo");
+ if (allowed_types == GIT_CREDENTIAL_USERNAME)
+ return git_credential_username_new(cred, "foo");
(*counter)++;
if (*counter == 3)
return GIT_EUSER;
- return git_cred_userpass_plaintext_new(cred, "foo", "bar");
+ return git_credential_userpass_plaintext_new(cred, "foo", "bar");
}
void test_online_clone__cred_callback_called_again_on_auth_failure(void)
@@ -351,7 +351,7 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void)
}
int cred_default(
- git_cred **cred,
+ git_credential **cred,
const char *url,
const char *user_from_url,
unsigned int allowed_types,
@@ -361,10 +361,10 @@ int cred_default(
GIT_UNUSED(user_from_url);
GIT_UNUSED(payload);
- if (!(allowed_types & GIT_CREDTYPE_DEFAULT))
+ if (!(allowed_types & GIT_CREDENTIAL_DEFAULT))
return 0;
- return git_cred_default_new(cred);
+ return git_credential_default_new(cred);
}
void test_online_clone__credentials(void)
@@ -372,7 +372,7 @@ void test_online_clone__credentials(void)
/* Remote URL environment variable must be set.
* User and password are optional.
*/
- git_cred_userpass_payload user_pass = {
+ git_credential_userpass_payload user_pass = {
_remote_user,
_remote_pass
};
@@ -383,7 +383,7 @@ void test_online_clone__credentials(void)
if (cl_is_env_set("GITTEST_REMOTE_DEFAULT")) {
g_options.fetch_opts.callbacks.credentials = cred_default;
} else {
- g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
+ g_options.fetch_opts.callbacks.credentials = git_credential_userpass;
g_options.fetch_opts.callbacks.payload = &user_pass;
}
@@ -394,11 +394,11 @@ void test_online_clone__credentials(void)
void test_online_clone__bitbucket_style(void)
{
- git_cred_userpass_payload user_pass = {
+ git_credential_userpass_payload user_pass = {
"libgit3", "libgit3"
};
- g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
+ g_options.fetch_opts.callbacks.credentials = git_credential_userpass;
g_options.fetch_opts.callbacks.payload = &user_pass;
cl_git_pass(git_clone(&g_repo, BB_REPO_URL, "./foo", &g_options));
@@ -408,16 +408,16 @@ void test_online_clone__bitbucket_style(void)
void test_online_clone__bitbucket_uses_creds_in_url(void)
{
- git_cred_userpass_payload user_pass = {
+ git_credential_userpass_payload user_pass = {
"libgit2", "wrong"
};
- g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
+ g_options.fetch_opts.callbacks.credentials = git_credential_userpass;
g_options.fetch_opts.callbacks.payload = &user_pass;
/*
* Correct user and pass are in the URL; the (incorrect) creds in
- * the `git_cred_userpass_payload` should be ignored.
+ * the `git_credential_userpass_payload` should be ignored.
*/
cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_PASS, "./foo", &g_options));
git_repository_free(g_repo); g_repo = NULL;
@@ -426,11 +426,11 @@ void test_online_clone__bitbucket_uses_creds_in_url(void)
void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
{
- git_cred_userpass_payload user_pass = {
+ git_credential_userpass_payload user_pass = {
"libgit2", "libgit2"
};
- g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
+ g_options.fetch_opts.callbacks.credentials = git_credential_userpass;
g_options.fetch_opts.callbacks.payload = &user_pass;
/*
@@ -441,7 +441,7 @@ void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
/*
* Incorrect user and pass are in the URL; the (correct) creds in
- * the `git_cred_userpass_payload` should be used as a fallback.
+ * the `git_credential_userpass_payload` should be used as a fallback.
*/
cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_WRONG_PASS, "./foo", &g_options));
git_repository_free(g_repo); g_repo = NULL;
@@ -465,16 +465,16 @@ void test_online_clone__can_cancel(void)
git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
}
-static int cred_cb(git_cred **cred, const char *url, const char *user_from_url,
+static int cred_cb(git_credential **cred, const char *url, const char *user_from_url,
unsigned int allowed_types, void *payload)
{
GIT_UNUSED(url); GIT_UNUSED(user_from_url); GIT_UNUSED(payload);
- if (allowed_types & GIT_CREDTYPE_USERNAME)
- return git_cred_username_new(cred, _remote_user);
+ if (allowed_types & GIT_CREDENTIAL_USERNAME)
+ return git_credential_username_new(cred, _remote_user);
- if (allowed_types & GIT_CREDTYPE_SSH_KEY)
- return git_cred_ssh_key_new(cred,
+ if (allowed_types & GIT_CREDENTIAL_SSH_KEY)
+ return git_credential_ssh_key_new(cred,
_remote_user, _remote_ssh_pubkey,
_remote_ssh_privkey, _remote_ssh_passphrase);
@@ -482,16 +482,16 @@ static int cred_cb(git_cred **cred, const char *url, const char *user_from_url,
return -1;
}
-static int check_ssh_auth_methods(git_cred **cred, const char *url, const char *username_from_url,
+static int check_ssh_auth_methods(git_credential **cred, const char *url, const char *username_from_url,
unsigned int allowed_types, void *data)
{
int *with_user = (int *) data;
GIT_UNUSED(cred); GIT_UNUSED(url); GIT_UNUSED(username_from_url); GIT_UNUSED(data);
if (!*with_user)
- cl_assert_equal_i(GIT_CREDTYPE_USERNAME, allowed_types);
+ cl_assert_equal_i(GIT_CREDENTIAL_USERNAME, allowed_types);
else
- cl_assert(!(allowed_types & GIT_CREDTYPE_USERNAME));
+ cl_assert(!(allowed_types & GIT_CREDENTIAL_USERNAME));
return GIT_EUSER;
}
@@ -566,13 +566,13 @@ void test_online_clone__ssh_with_paths(void)
cl_git_pass(git_clone(&g_repo, _remote_url, "./foo", &g_options));
}
-static int cred_foo_bar(git_cred **cred, const char *url, const char *username_from_url,
+static int cred_foo_bar(git_credential **cred, const char *url, const char *username_from_url,
unsigned int allowed_types, void *data)
{
GIT_UNUSED(url); GIT_UNUSED(username_from_url); GIT_UNUSED(allowed_types); GIT_UNUSED(data);
- return git_cred_userpass_plaintext_new(cred, "foo", "bar");
+ return git_credential_userpass_plaintext_new(cred, "foo", "bar");
}
void test_online_clone__ssh_cannot_change_username(void)
@@ -649,20 +649,20 @@ static char *read_key_file(const char *path)
return buf;
}
-static int ssh_memory_cred_cb(git_cred **cred, const char *url, const char *user_from_url,
+static int ssh_memory_cred_cb(git_credential **cred, const char *url, const char *user_from_url,
unsigned int allowed_types, void *payload)
{
GIT_UNUSED(url); GIT_UNUSED(user_from_url); GIT_UNUSED(payload);
- if (allowed_types & GIT_CREDTYPE_USERNAME)
- return git_cred_username_new(cred, _remote_user);
+ if (allowed_types & GIT_CREDENTIAL_USERNAME)
+ return git_credential_username_new(cred, _remote_user);
- if (allowed_types & GIT_CREDTYPE_SSH_KEY)
+ if (allowed_types & GIT_CREDENTIAL_SSH_KEY)
{
char *pubkey = read_key_file(_remote_ssh_pubkey);
char *privkey = read_key_file(_remote_ssh_privkey);
- int ret = git_cred_ssh_key_memory_new(cred, _remote_user, pubkey, privkey, _remote_ssh_passphrase);
+ int ret = git_credential_ssh_key_memory_new(cred, _remote_user, pubkey, privkey, _remote_ssh_passphrase);
if (privkey)
free(privkey);
@@ -737,7 +737,7 @@ void test_online_clone__start_with_http(void)
}
static int called_proxy_creds;
-static int proxy_cred_cb(git_cred **out, const char *url, const char *username, unsigned int allowed, void *payload)
+static int proxy_cred_cb(git_credential **out, const char *url, const char *username, unsigned int allowed, void *payload)
{
GIT_UNUSED(url);
GIT_UNUSED(username);
@@ -745,7 +745,7 @@ static int proxy_cred_cb(git_cred **out, const char *url, const char *username,
GIT_UNUSED(payload);
called_proxy_creds = 1;
- return git_cred_userpass_plaintext_new(out, _remote_proxy_user, _remote_proxy_pass);
+ return git_credential_userpass_plaintext_new(out, _remote_proxy_user, _remote_proxy_pass);
}
static int proxy_cert_cb(git_cert *cert, int valid, const char *host, void *payload)
diff --git a/tests/online/push.c b/tests/online/push.c
index 8c3150c..c82b606 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -21,7 +21,7 @@ static char *_remote_ssh_passphrase = NULL;
static char *_remote_default = NULL;
static char *_remote_expectcontinue = NULL;
-static int cred_acquire_cb(git_cred **, const char *, const char *, unsigned int, void *);
+static int cred_acquire_cb(git_credential **, const char *, const char *, unsigned int, void *);
static git_remote *_remote;
static record_callbacks_data _record_cbs_data = {{ 0 }};
@@ -41,7 +41,7 @@ static git_oid _tag_lightweight;
static git_oid _tag_tag;
static int cred_acquire_cb(
- git_cred **cred,
+ git_credential **cred,
const char *url,
const char *user_from_url,
unsigned int allowed_types,
@@ -51,40 +51,40 @@ static int cred_acquire_cb(
GIT_UNUSED(user_from_url);
GIT_UNUSED(payload);
- if (GIT_CREDTYPE_USERNAME & allowed_types) {
+ if (GIT_CREDENTIAL_USERNAME & allowed_types) {
if (!_remote_user) {
printf("GITTEST_REMOTE_USER must be set\n");
return -1;
}
- return git_cred_username_new(cred, _remote_user);
+ return git_credential_username_new(cred, _remote_user);
}
- if (GIT_CREDTYPE_DEFAULT & allowed_types) {
+ if (GIT_CREDENTIAL_DEFAULT & allowed_types) {
if (!_remote_default) {
printf("GITTEST_REMOTE_DEFAULT must be set to use NTLM/Negotiate credentials\n");
return -1;
}
- return git_cred_default_new(cred);
+ return git_credential_default_new(cred);
}
- if (GIT_CREDTYPE_SSH_KEY & allowed_types) {
+ if (GIT_CREDENTIAL_SSH_KEY & allowed_types) {
if (!_remote_user || !_remote_ssh_pubkey || !_remote_ssh_key || !_remote_ssh_passphrase) {
printf("GITTEST_REMOTE_USER, GITTEST_REMOTE_SSH_PUBKEY, GITTEST_REMOTE_SSH_KEY and GITTEST_REMOTE_SSH_PASSPHRASE must be set\n");
return -1;
}
- return git_cred_ssh_key_new(cred, _remote_user, _remote_ssh_pubkey, _remote_ssh_key, _remote_ssh_passphrase);
+ return git_credential_ssh_key_new(cred, _remote_user, _remote_ssh_pubkey, _remote_ssh_key, _remote_ssh_passphrase);
}
- if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) {
+ if (GIT_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
if (!_remote_user || !_remote_pass) {
printf("GITTEST_REMOTE_USER and GITTEST_REMOTE_PASS must be set\n");
return -1;
}
- return git_cred_userpass_plaintext_new(cred, _remote_user, _remote_pass);
+ return git_credential_userpass_plaintext_new(cred, _remote_user, _remote_pass);
}
return -1;