http_auth.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _HTTP_BASIC_AUTH_H_
  7. #define _HTTP_BASIC_AUTH_H_
  8. /**
  9. * HTTP Digest authentication data
  10. */
  11. typedef struct {
  12. char *method; /*!< Request method, example: GET */
  13. char *algorithm; /*!< Authentication algorithm */
  14. char *uri; /*!< URI of request example: /path/to/file.html */
  15. char *realm; /*!< Authentication realm */
  16. char *nonce; /*!< Authentication nonce */
  17. char *qop; /*!< Authentication qop */
  18. char *opaque; /*!< Authentication opaque */
  19. uint64_t cnonce; /*!< Authentication cnonce */
  20. int nc; /*!< Authentication nc */
  21. } esp_http_auth_data_t;
  22. /**
  23. * @brief This use for Http digest authentication method, create http header for digest authentication.
  24. * The returned string need to free after use
  25. *
  26. * @param[in] username The username
  27. * @param[in] password The password
  28. * @param auth_data The auth data
  29. *
  30. * @return
  31. * - HTTP Header value of Authorization, valid for digest authentication, must be freed after usage
  32. * - NULL
  33. */
  34. char *http_auth_digest(const char *username, const char *password, esp_http_auth_data_t *auth_data);
  35. /**
  36. * @brief This use for Http basic authentication method, create header value for basic http authentication
  37. * The returned string need to free after use
  38. *
  39. * @param[in] username The username
  40. * @param[in] password The password
  41. *
  42. * @return
  43. * - HTTP Header value of Authorization, valid for basic authentication, must be free after use
  44. * - NULL
  45. */
  46. char *http_auth_basic(const char *username, const char *password);
  47. #endif