CURLOPT_UNRESTRICTED_AUTH.3 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .\" generated by cd2nroff 0.1 from CURLOPT_UNRESTRICTED_AUTH.md
  2. .TH CURLOPT_UNRESTRICTED_AUTH 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_UNRESTRICTED_AUTH \- send credentials to other hosts too
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNRESTRICTED_AUTH,
  9. long goahead);
  10. .fi
  11. .SH DESCRIPTION
  12. Set the long \fIgohead\fP parameter to 1L to make libcurl continue to send
  13. authentication (user+password) credentials when following locations, even when
  14. hostname changed. This option is meaningful only when setting
  15. \fICURLOPT_FOLLOWLOCATION(3)\fP.
  16. Further, when this option is not used or set to \fB0L\fP, libcurl does not
  17. send custom nor internally generated Authentication: headers on requests done
  18. to other hosts than the one used for the initial URL.
  19. By default, libcurl only sends credentials and Authentication headers to the
  20. initial hostname as given in the original URL, to avoid leaking username +
  21. password to other sites.
  22. This option should be used with caution: when curl follows redirects it
  23. blindly fetches the next URL as instructed by the server. Setting
  24. \fICURLOPT_UNRESTRICTED_AUTH(3)\fP to 1L makes curl trust the server and sends
  25. possibly sensitive credentials to any host the server points to, possibly
  26. again and again as the following hosts can keep redirecting to new hosts.
  27. .SH DEFAULT
  28. 0
  29. .SH PROTOCOLS
  30. This functionality affects http only
  31. .SH EXAMPLE
  32. .nf
  33. int main(void)
  34. {
  35. CURL *curl = curl_easy_init();
  36. if(curl) {
  37. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  38. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  39. curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L);
  40. curl_easy_perform(curl);
  41. }
  42. }
  43. .fi
  44. .SH AVAILABILITY
  45. Added in curl 7.10.4
  46. .SH RETURN VALUE
  47. Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
  48. .SH SEE ALSO
  49. .BR CURLINFO_REDIRECT_COUNT (3),
  50. .BR CURLOPT_FOLLOWLOCATION (3),
  51. .BR CURLOPT_MAXREDIRS (3),
  52. .BR CURLOPT_REDIR_PROTOCOLS_STR (3),
  53. .BR CURLOPT_USERPWD (3)