jwtEndpoint.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2020 HPCC Systems®.
  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. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef JWTENDPOINT_HPP_
  14. #define JWTENDPOINT_HPP_
  15. #include <string>
  16. /**
  17. * Calls the JWT login endpoint, submitting user credentials. Expects a
  18. * JSON-formatted response.
  19. *
  20. * @param jwtLoginEndpoint Full URL to JWT login endpoint
  21. * @param allowSelfSignedCert If true, allow a self-signed certificate
  22. * to validate https conneection; ignored
  23. * for http connections, but you shouldn't
  24. * be using those anyway
  25. * @param userStr Username to validate
  26. * @param pwStr Password to validate
  27. * @param clientID The client_id to pass to the endpoint
  28. * @param nonce Nonce to pass to the endpoint
  29. *
  30. * @return String containing a JSON response from the endpoint. If an
  31. * error occurs that results in something other than a JSON
  32. * string then an empty string will be returned.
  33. */
  34. std::string tokenFromLogin(const std::string& jwtLoginEndpoint, bool allowSelfSignedCert, const std::string& userStr, const std::string& pwStr, const std::string& clientID, const std::string& nonce);
  35. /**
  36. * Calls the JWT refress endpoint, submitting a refresh token. Expects a
  37. * JSON-formatted response.
  38. *
  39. * @param jwtEndPoint Full URL to JWT refresh endpoint
  40. * @param allowSelfSignedCert If true, allow a self-signed certificate
  41. * to validate https conneection; ignored
  42. * for http connections, but you shouldn't
  43. * be using those anyway
  44. * @param clientID The client_id to pass to the endpoint
  45. * @param refreshToken Refresh token to pass to the endpoint
  46. *
  47. * @return String containing a JSON response from the endpoint. If an
  48. * error occurs that results in something other than a JSON
  49. * string then an empty string will be returned.
  50. */
  51. std::string tokenFromRefresh(const std::string& jwtEndPoint, bool allowSelfSignedCert, const std::string& clientID, const std::string& refreshToken);
  52. #endif // JWTENDPOINT_HPP_