Compare commits

...

3 Commits

Author SHA1 Message Date
Dmitry Dunaev
6a9b0f143e Chg: version of image to v2.3.0-RC2 2021-11-02 13:17:28 +03:00
Stephane Bourque
736d981853 Merge pull request #23 from Telecominfraproject/main
Fixing token generation.
2021-10-30 13:49:15 -07:00
stephb9959
423aca9892 Fixing token generation. 2021-10-30 09:46:07 -07:00
4 changed files with 53 additions and 4 deletions

2
build
View File

@@ -1 +1 @@
12
14

View File

@@ -8,7 +8,7 @@ fullnameOverride: ""
images:
owsec:
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owsec
tag: v2.3.0-RC1
tag: v2.3.0-RC2
pullPolicy: Always
# regcred:
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io

View File

@@ -143,7 +143,7 @@ namespace OpenWifi {
}
[[nodiscard]] std::string AuthService::GenerateTokenHMAC(const std::string & UserName, ACCESS_TYPE Type) {
std::string Identity(UserName + ":" + Poco::format("%d",(int)std::time(nullptr)));
std::string Identity(UserName + ":" + Poco::format("%d",(int)std::time(nullptr)) + ":" + std::to_string(rand()));
HMAC_.update(Identity);
return Poco::DigestEngine::digestToHex(HMAC_.digest());
}

View File

@@ -277,6 +277,31 @@ namespace OpenWifi::RESTAPI_utils {
return OS.str();
}
template<class T> std::string to_string(const std::vector<std::vector<T>> & ObjectArray) {
Poco::JSON::Array OutputArr;
if(ObjectArray.empty())
return "[]";
for(auto const &i:ObjectArray) {
Poco::JSON::Array InnerArr;
for(auto const &j:i) {
if constexpr(std::is_integral<T>::value) {
InnerArr.add(j);
} if constexpr(std::is_same_v<T,std::string>) {
InnerArr.add(j);
} else {
InnerArr.add(j);
Poco::JSON::Object O;
j.to_json(O);
InnerArr.add(O);
}
}
OutputArr.add(InnerArr);
}
std::ostringstream OS;
Poco::JSON::Stringifier::condense(OutputArr,OS);
return OS.str();
}
template<class T> std::string to_string(const T & Object) {
Poco::JSON::Object OutputObj;
Object.to_json(OutputObj);
@@ -321,7 +346,6 @@ namespace OpenWifi::RESTAPI_utils {
}
template<class T> std::vector<T> to_object_array(const std::string & ObjectString) {
std::vector<T> Result;
if(ObjectString.empty())
return Result;
@@ -341,6 +365,31 @@ namespace OpenWifi::RESTAPI_utils {
return Result;
}
template<class T> std::vector<std::vector<T>> to_array_of_array_of_object(const std::string & ObjectString) {
std::vector<std::vector<T>> Result;
if(ObjectString.empty())
return Result;
try {
Poco::JSON::Parser P1;
auto OutterArray = P1.parse(ObjectString).template extract<Poco::JSON::Array::Ptr>();
for (auto const &i : *OutterArray) {
Poco::JSON::Parser P2;
auto InnerArray = P2.parse(i).template extract<Poco::JSON::Array::Ptr>();
std::vector<T> InnerVector;
for(auto const &j: *InnerArray) {
auto Object = j.template extract<Poco::JSON::Object::Ptr>();
T Obj;
Obj.from_json(Object);
InnerVector.push_back(Obj);
}
Result.push_back(InnerVector);
}
} catch (...) {
}
return Result;
}
template<class T> T to_object(const std::string & ObjectString) {
T Result;