http_auth.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _HTTP_BASIC_AUTH_H_
  14. #define _HTTP_BASIC_AUTH_H_
  15. /**
  16. * HTTP Digest authentication data
  17. */
  18. typedef struct {
  19. char *method; /*!< Request method, example: GET */
  20. char *algorithm; /*!< Authentication algorithm */
  21. char *uri; /*!< URI of request example: /path/to/file.html */
  22. char *realm; /*!< Authentication realm */
  23. char *nonce; /*!< Authentication nonce */
  24. char *qop; /*!< Authentication qop */
  25. char *opaque; /*!< Authentication opaque */
  26. uint64_t cnonce; /*!< Authentication cnonce */
  27. int nc; /*!< Authentication nc */
  28. } esp_http_auth_data_t;
  29. /**
  30. * @brief This use for Http digest authentication method, create http header for digest authentication.
  31. * The returned string need to free after use
  32. *
  33. * @param[in] username The username
  34. * @param[in] password The password
  35. * @param auth_data The auth data
  36. *
  37. * @return
  38. * - HTTP Header value of Authorization, valid for digest authentication, must be freed after usage
  39. * - NULL
  40. */
  41. char *http_auth_digest(const char *username, const char *password, esp_http_auth_data_t *auth_data);
  42. /**
  43. * @brief This use for Http basic authentication method, create header value for basic http authentication
  44. * The returned string need to free after use
  45. *
  46. * @param[in] username The username
  47. * @param[in] password The password
  48. *
  49. * @return
  50. * - HTTP Header value of Authorization, valid for basic authentication, must be free after use
  51. * - NULL
  52. */
  53. char *http_auth_basic(const char *username, const char *password);
  54. #endif