2
0

vauth.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef HEADER_CURL_VAUTH_H
  2. #define HEADER_CURL_VAUTH_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include <curl/curl.h>
  27. #include "bufref.h"
  28. struct Curl_easy;
  29. #if !defined(CURL_DISABLE_DIGEST_AUTH)
  30. struct digestdata;
  31. #endif
  32. #if defined(USE_NTLM)
  33. struct ntlmdata;
  34. #endif
  35. #if defined(USE_KERBEROS5)
  36. struct kerberos5data;
  37. #endif
  38. #if (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) && defined(USE_SPNEGO)
  39. struct negotiatedata;
  40. #endif
  41. #if defined(USE_GSASL)
  42. struct gsasldata;
  43. #endif
  44. #if defined(USE_WINDOWS_SSPI)
  45. #define GSS_ERROR(status) ((status) & 0x80000000)
  46. #endif
  47. /*
  48. * Curl_auth_allowed_to_host() tells if authentication, cookies or other
  49. * "sensitive data" can (still) be sent to this host.
  50. */
  51. bool Curl_auth_allowed_to_host(struct Curl_easy *data);
  52. /* This is used to build a SPN string */
  53. #if !defined(USE_WINDOWS_SSPI)
  54. char *Curl_auth_build_spn(const char *service, const char *host,
  55. const char *realm);
  56. #else
  57. TCHAR *Curl_auth_build_spn(const char *service, const char *host,
  58. const char *realm);
  59. #endif
  60. /* This is used to test if the user contains a Windows domain name */
  61. bool Curl_auth_user_contains_domain(const char *user);
  62. /* This is used to generate a PLAIN cleartext message */
  63. CURLcode Curl_auth_create_plain_message(const char *authzid,
  64. const char *authcid,
  65. const char *passwd,
  66. struct bufref *out);
  67. /* This is used to generate a LOGIN cleartext message */
  68. void Curl_auth_create_login_message(const char *value, struct bufref *out);
  69. /* This is used to generate an EXTERNAL cleartext message */
  70. void Curl_auth_create_external_message(const char *user, struct bufref *out);
  71. #ifndef CURL_DISABLE_DIGEST_AUTH
  72. /* This is used to generate a CRAM-MD5 response message */
  73. CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg,
  74. const char *userp,
  75. const char *passwdp,
  76. struct bufref *out);
  77. /* This is used to evaluate if DIGEST is supported */
  78. bool Curl_auth_is_digest_supported(void);
  79. /* This is used to generate a base64 encoded DIGEST-MD5 response message */
  80. CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
  81. const struct bufref *chlg,
  82. const char *userp,
  83. const char *passwdp,
  84. const char *service,
  85. struct bufref *out);
  86. /* This is used to decode an HTTP DIGEST challenge message */
  87. CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
  88. struct digestdata *digest);
  89. /* This is used to generate an HTTP DIGEST response message */
  90. CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
  91. const char *userp,
  92. const char *passwdp,
  93. const unsigned char *request,
  94. const unsigned char *uri,
  95. struct digestdata *digest,
  96. char **outptr, size_t *outlen);
  97. /* This is used to clean up the digest specific data */
  98. void Curl_auth_digest_cleanup(struct digestdata *digest);
  99. #endif /* !CURL_DISABLE_DIGEST_AUTH */
  100. #ifdef USE_GSASL
  101. /* This is used to evaluate if MECH is supported by gsasl */
  102. bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
  103. const char *mech,
  104. struct gsasldata *gsasl);
  105. /* This is used to start a gsasl method */
  106. CURLcode Curl_auth_gsasl_start(struct Curl_easy *data,
  107. const char *userp,
  108. const char *passwdp,
  109. struct gsasldata *gsasl);
  110. /* This is used to process and generate a new SASL token */
  111. CURLcode Curl_auth_gsasl_token(struct Curl_easy *data,
  112. const struct bufref *chlg,
  113. struct gsasldata *gsasl,
  114. struct bufref *out);
  115. /* This is used to clean up the gsasl specific data */
  116. void Curl_auth_gsasl_cleanup(struct gsasldata *digest);
  117. #endif
  118. #if defined(USE_NTLM)
  119. /* This is used to evaluate if NTLM is supported */
  120. bool Curl_auth_is_ntlm_supported(void);
  121. /* This is used to generate a base64 encoded NTLM type-1 message */
  122. CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
  123. const char *userp,
  124. const char *passwdp,
  125. const char *service,
  126. const char *host,
  127. struct ntlmdata *ntlm,
  128. struct bufref *out);
  129. /* This is used to decode a base64 encoded NTLM type-2 message */
  130. CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
  131. const struct bufref *type2,
  132. struct ntlmdata *ntlm);
  133. /* This is used to generate a base64 encoded NTLM type-3 message */
  134. CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
  135. const char *userp,
  136. const char *passwdp,
  137. struct ntlmdata *ntlm,
  138. struct bufref *out);
  139. /* This is used to clean up the NTLM specific data */
  140. void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm);
  141. #endif /* USE_NTLM */
  142. /* This is used to generate a base64 encoded OAuth 2.0 message */
  143. CURLcode Curl_auth_create_oauth_bearer_message(const char *user,
  144. const char *host,
  145. const long port,
  146. const char *bearer,
  147. struct bufref *out);
  148. /* This is used to generate a base64 encoded XOAuth 2.0 message */
  149. CURLcode Curl_auth_create_xoauth_bearer_message(const char *user,
  150. const char *bearer,
  151. struct bufref *out);
  152. #if defined(USE_KERBEROS5)
  153. /* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
  154. bool Curl_auth_is_gssapi_supported(void);
  155. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
  156. message */
  157. CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
  158. const char *userp,
  159. const char *passwdp,
  160. const char *service,
  161. const char *host,
  162. const bool mutual,
  163. const struct bufref *chlg,
  164. struct kerberos5data *krb5,
  165. struct bufref *out);
  166. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
  167. token message */
  168. CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
  169. const char *authzid,
  170. const struct bufref *chlg,
  171. struct kerberos5data *krb5,
  172. struct bufref *out);
  173. /* This is used to clean up the GSSAPI specific data */
  174. void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5);
  175. #endif /* USE_KERBEROS5 */
  176. #if defined(USE_SPNEGO)
  177. /* This is used to evaluate if SPNEGO (Negotiate) is supported */
  178. bool Curl_auth_is_spnego_supported(void);
  179. /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge
  180. message */
  181. CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
  182. const char *user,
  183. const char *password,
  184. const char *service,
  185. const char *host,
  186. const char *chlg64,
  187. struct negotiatedata *nego);
  188. /* This is used to generate a base64 encoded SPNEGO (Negotiate) response
  189. message */
  190. CURLcode Curl_auth_create_spnego_message(struct negotiatedata *nego,
  191. char **outptr, size_t *outlen);
  192. /* This is used to clean up the SPNEGO specific data */
  193. void Curl_auth_cleanup_spnego(struct negotiatedata *nego);
  194. #endif /* USE_SPNEGO */
  195. #endif /* HEADER_CURL_VAUTH_H */