stephb9959
2023-05-24 09:58:09 -07:00
parent 90c700702e
commit 5c6814852e
4 changed files with 22 additions and 0 deletions

View File

@@ -1110,6 +1110,12 @@ paths:
type: string type: string
format: uuid format: uuid
required: true required: true
- in: query
description: When used, signifies the the id is actually the email address of the user, and not its uuid
name: byEmail
schema:
type: boolean
required: false
responses: responses:
200: 200:
$ref: '#/components/schemas/UserInfo' $ref: '#/components/schemas/UserInfo'
@@ -1972,6 +1978,8 @@ paths:
/systemSecret/{secret}: /systemSecret/{secret}:
get: get:
tags:
- System Secrets
description: Retrieve a specific secret description: Retrieve a specific secret
operationId: getSecret operationId: getSecret
parameters: parameters:
@@ -2016,6 +2024,8 @@ paths:
$ref: '#/components/responses/NotFound' $ref: '#/components/responses/NotFound'
put: put:
tags:
- System Secrets
description: Modify a specific secret description: Modify a specific secret
operationId: modifySecret operationId: modifySecret
parameters: parameters:

View File

@@ -14,8 +14,15 @@
#include "framework/OpenWifiTypes.h" #include "framework/OpenWifiTypes.h"
#include "framework/utils.h" #include "framework/utils.h"
#include <RESTObjects/RESTAPI_SecurityObjects.h>
namespace OpenWifi::RESTAPI_utils { namespace OpenWifi::RESTAPI_utils {
inline bool IsRootOrAdmin(const SecurityObjects::UserInfo &UI) {
return UI.userRole==SecurityObjects::ROOT ||
UI.userRole==SecurityObjects::ADMIN;
}
inline void EmbedDocument(const std::string &ObjName, Poco::JSON::Object &Obj, inline void EmbedDocument(const std::string &ObjName, Poco::JSON::Object &Obj,
const std::string &ObjStr) { const std::string &ObjStr) {
std::string D = ObjStr.empty() ? "{}" : ObjStr; std::string D = ObjStr.empty() ? "{}" : ObjStr;

View File

@@ -27,6 +27,10 @@ namespace OpenWifi::Utils {
std::all_of(Serial.begin(), Serial.end(), [](auto i) { return std::isxdigit(i); })); std::all_of(Serial.begin(), Serial.end(), [](auto i) { return std::isxdigit(i); }));
} }
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &numbers) {
return std::all_of(numbers.begin(),numbers.end(),[](auto &number) {return ValidSerialNumber(number);});
}
[[nodiscard]] bool ValidUUID(const std::string &UUID) { [[nodiscard]] bool ValidUUID(const std::string &UUID) {
if (UUID.size() > 36) if (UUID.size() > 36)
return false; return false;

View File

@@ -68,6 +68,7 @@ namespace OpenWifi::Utils {
}; };
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial); [[nodiscard]] bool ValidSerialNumber(const std::string &Serial);
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &Serial);
[[nodiscard]] bool ValidUUID(const std::string &UUID); [[nodiscard]] bool ValidUUID(const std::string &UUID);
[[nodiscard]] bool ValidHostname(const std::string &hostname); [[nodiscard]] bool ValidHostname(const std::string &hostname);