http_auth.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * HTTP Digest authentication data
  20. */
  21. typedef struct {
  22. char *method; /*!< Request method, example: GET */
  23. char *algorithm; /*!< Authentication algorithm */
  24. char *uri; /*!< URI of request example: /path/to/file.html */
  25. char *realm; /*!< Authentication realm */
  26. char *nonce; /*!< Authentication nonce */
  27. char *qop; /*!< Authentication qop */
  28. char *opaque; /*!< Authentication opaque */
  29. uint64_t cnonce; /*!< Authentication cnonce */
  30. int nc; /*!< Authentication nc */
  31. } http_auth_data_t;
  32. /**
  33. * @brief This use for Http digest authentication method, create http header for digest authentication.
  34. * The returned string need to free after use
  35. *
  36. * @param[in] username The username
  37. * @param[in] password The password
  38. * @param auth_data The auth data
  39. *
  40. * @return
  41. * - HTTP Header value of Authorization, valid for digest authentication, must be freed after usage
  42. * - NULL
  43. */
  44. char *http_auth_digest(const char *username, const char *password, http_auth_data_t *auth_data);
  45. /**
  46. * @brief This use for Http basic authentication method, create header value for basic http authentication
  47. * The returned string need to free after use
  48. *
  49. * @param[in] username The username
  50. * @param[in] password The password
  51. *
  52. * @return
  53. * - HTTP Header value of Authorization, valid for basic authentication, must be free after use
  54. * - NULL
  55. */
  56. char *http_auth_basic(const char *username, const char *password);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif