CURLOPT_HTTPAUTH.3 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_HTTPAUTH 3 "2 Aug 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_HTTPAUTH \- HTTP server authentication methods to try
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPAUTH, long bitmask);
  32. .SH DESCRIPTION
  33. Pass a long as parameter, which is set to a bitmask, to tell libcurl which
  34. authentication method(s) you want it to use speaking to the remote server.
  35. The available bits are listed below. If more than one bit is set, libcurl will
  36. first query the site to see which authentication methods it supports and then
  37. pick the best one you allow it to use. For some methods, this will induce an
  38. extra network round-trip. Set the actual name and password with the
  39. \fICURLOPT_USERPWD(3)\fP option or with the \fICURLOPT_USERNAME(3)\fP and the
  40. \fICURLOPT_PASSWORD(3)\fP options.
  41. For authentication with a proxy, see \fICURLOPT_PROXYAUTH(3)\fP.
  42. .IP CURLAUTH_BASIC
  43. HTTP Basic authentication. This is the default choice, and the only method
  44. that is in wide-spread use and supported virtually everywhere. This sends
  45. the user name and password over the network in plain text, easily captured by
  46. others.
  47. .IP CURLAUTH_DIGEST
  48. HTTP Digest authentication. Digest authentication is defined in RFC 2617 and
  49. is a more secure way to do authentication over public networks than the
  50. regular old-fashioned Basic method.
  51. .IP CURLAUTH_DIGEST_IE
  52. HTTP Digest authentication with an IE flavor. Digest authentication is
  53. defined in RFC 2617 and is a more secure way to do authentication over public
  54. networks than the regular old-fashioned Basic method. The IE flavor is simply
  55. that libcurl will use a special "quirk" that IE is known to have used before
  56. version 7 and that some servers require the client to use.
  57. .IP CURLAUTH_BEARER
  58. HTTP Bearer token authentication, used primarily in OAuth 2.0 protocol.
  59. You can set the Bearer token to use with \fICURLOPT_XOAUTH2_BEARER(3)\fP.
  60. .IP CURLAUTH_NEGOTIATE
  61. HTTP Negotiate (SPNEGO) authentication. Negotiate authentication is defined
  62. in RFC 4559 and is the most secure way to perform authentication over HTTP.
  63. You need to build libcurl with a suitable GSS-API library or SSPI on Windows
  64. for this to work.
  65. .IP CURLAUTH_NTLM
  66. HTTP NTLM authentication. A proprietary protocol invented and used by
  67. Microsoft. It uses a challenge-response and hash concept similar to Digest, to
  68. prevent the password from being eavesdropped.
  69. You need to build libcurl with either OpenSSL, GnuTLS or NSS support for this
  70. option to work, or build libcurl on Windows with SSPI support.
  71. .IP CURLAUTH_NTLM_WB
  72. NTLM delegating to winbind helper. Authentication is performed by a separate
  73. binary application that is executed when needed. The name of the application
  74. is specified at compile time but is typically \fB/usr/bin/ntlm_auth\fP.
  75. Note that libcurl will fork when necessary to run the winbind application and
  76. kill it when complete, calling \fBwaitpid()\fP to await its exit when done. On
  77. POSIX operating systems, killing the process will cause a SIGCHLD signal to be
  78. raised (regardless of whether \fICURLOPT_NOSIGNAL(3)\fP is set), which must be
  79. handled intelligently by the application. In particular, the application must
  80. not unconditionally call wait() in its SIGCHLD signal handler to avoid being
  81. subject to a race condition. This behavior is subject to change in future
  82. versions of libcurl.
  83. .IP CURLAUTH_ANY
  84. This is a convenience macro that sets all bits and thus makes libcurl pick any
  85. it finds suitable. libcurl will automatically select the one it finds most
  86. secure.
  87. .IP CURLAUTH_ANYSAFE
  88. This is a convenience macro that sets all bits except Basic and thus makes
  89. libcurl pick any it finds suitable. libcurl will automatically select the one
  90. it finds most secure.
  91. .IP CURLAUTH_ONLY
  92. This is a meta symbol. OR this value together with a single specific auth
  93. value to force libcurl to probe for unrestricted auth and if not, only that
  94. single auth algorithm is acceptable.
  95. .IP CURLAUTH_AWS_SIGV4
  96. provides AWS V4 signature authentication on HTTPS header
  97. see \fICURLOPT_AWS_SIGV4(3)\fP.
  98. .SH DEFAULT
  99. CURLAUTH_BASIC
  100. .SH PROTOCOLS
  101. HTTP
  102. .SH EXAMPLE
  103. .nf
  104. CURL *curl = curl_easy_init();
  105. if(curl) {
  106. CURLcode ret;
  107. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  108. /* allow whatever auth the server speaks */
  109. curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
  110. curl_easy_setopt(curl, CURLOPT_USERPWD, "james:bond");
  111. ret = curl_easy_perform(curl);
  112. }
  113. .fi
  114. .SH AVAILABILITY
  115. Option Added in 7.10.6.
  116. CURLAUTH_DIGEST_IE was added in 7.19.3
  117. CURLAUTH_ONLY was added in 7.21.3
  118. CURLAUTH_NTLM_WB was added in 7.22.0
  119. CURLAUTH_BEARER was added in 7.61.0
  120. CURLAUTH_AWS_SIGV4 was added in 7.74.0
  121. .SH RETURN VALUE
  122. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  123. CURLE_NOT_BUILT_IN if the bitmask specified no supported authentication
  124. methods.
  125. .SH "SEE ALSO"
  126. .BR CURLOPT_PROXYAUTH "(3), " CURLOPT_USERPWD "(3), "