From 8fff2ced69a38947112d57298520480d368edb5e Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 31 Jan 2023 14:33:58 -0800 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-12068 Signed-off-by: stephb9959 --- openpapi/owsec.yaml | 17 ++++++++++++++++ src/RESTAPI/RESTAPI_systemSecret_handler.cpp | 21 ++++++++++++++++++++ test_scripts/curl/cli | 8 ++++++++ 3 files changed, 46 insertions(+) diff --git a/openpapi/owsec.yaml b/openpapi/owsec.yaml index 151c7bf..aaf31c2 100644 --- a/openpapi/owsec.yaml +++ b/openpapi/owsec.yaml @@ -1988,12 +1988,29 @@ paths: schema: type: boolean required: false + - in: query + name: dictionary + schema: + type: boolean + required: false responses: 200: + description: Successfull retrieval content: application/json: schema: oneOf: + - type: object + properties: + knownKeys: + type: array + items: + type: object + properties: + key: + type: string + helper: + type: string - $ref: '#/components/schemas/SystemSecretEntry' - $ref: '#/components/schemas/SystemSecretEntryList' 403: diff --git a/src/RESTAPI/RESTAPI_systemSecret_handler.cpp b/src/RESTAPI/RESTAPI_systemSecret_handler.cpp index 343acd2..9c390e4 100644 --- a/src/RESTAPI/RESTAPI_systemSecret_handler.cpp +++ b/src/RESTAPI/RESTAPI_systemSecret_handler.cpp @@ -27,6 +27,27 @@ namespace OpenWifi { return ReturnObject(List); } + if(GetBoolParameter("dictionary")) { + static std::vector> KnownKeys = + { + { "google.maps.apikey" , "A Google Key specific for the Google MAPS API."}, + { "iptocountry.ipinfo.token", "IPInfo.io service token."}, + { "iptocountry.ipdata.apikey", "IPData.co API Key."}, + { "iptocountry.ip2location.apikey", "IP2Location.com API Key"} + }; + + Poco::JSON::Object Answer; + Poco::JSON::Array Entries; + for(const auto &[key,description]:KnownKeys) { + Poco::JSON::Object E; + E.set("key",key); + E.set("description",description); + Entries.add(E); + } + Answer.set("knownKeys", Entries); + return ReturnObject(Answer); + } + auto Key = GetBinding("secret"); if(Key.empty()) { return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters); diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index c1d3719..140d79e 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -425,6 +425,14 @@ getsecret() { jq < ${result_file} } +getsecretdictionary() { + curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemSecret/0?dictionary=true" \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Authorization: Bearer ${token}" > ${result_file} + jq < ${result_file} +} + getallsecrets() { curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemSecret/0?all=true" \ -H "Content-Type: application/json" \