Merging Security login.

This commit is contained in:
stephb9959
2021-11-28 14:32:14 -08:00
parent 760c42e25b
commit ff4017e530
25 changed files with 394 additions and 162 deletions

View File

@@ -68,7 +68,7 @@ add_executable(owsub
src/APIServers.cpp
src/Daemon.cpp src/Daemon.h
src/Dashboard.h src/Dashboard.cpp
src/StorageService.cpp src/StorageService.h src/RESTAPI/RESTAPI_internetConnection_handler.cpp src/RESTAPI/RESTAPI_internetConnection_handler.h src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp src/RESTAPI/RESTAPI_homeDeviceMode_handler.h src/RESTAPI/RESTAPI_ipReservations_handler.cpp src/RESTAPI/RESTAPI_ipReservations_handler.h src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp src/RESTAPI/RESTAPI_wifiNetworks_handler.h src/RESTAPI/RESTAPI_wiredClients_handler.cpp src/RESTAPI/RESTAPI_wiredClients_handler.h src/RESTAPI/RESTAPI_wifiClients_handler.cpp src/RESTAPI/RESTAPI_wifiClients_handler.h src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp src/RESTAPI/RESTAPI_subscriberDevices_handler.h src/RESTObjects/RESTAPI_SubObjects.cpp src/RESTObjects/RESTAPI_SubObjects.h src/storage/storage_reservations.cpp src/storage/storage_reservations.h src/RESTAPI/RESTAPI_accessPoints_handler.cpp src/RESTAPI/RESTAPI_accessPoints_handler.h src/RESTAPI/RESTAPI_subscriber_handler.cpp src/RESTAPI/RESTAPI_subscriber_handler.h src/RESTAPI/RESTAPI_login_handler.cpp src/RESTAPI/RESTAPI_login_handler.h)
src/StorageService.cpp src/StorageService.h src/RESTAPI/RESTAPI_internetConnection_handler.cpp src/RESTAPI/RESTAPI_internetConnection_handler.h src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp src/RESTAPI/RESTAPI_homeDeviceMode_handler.h src/RESTAPI/RESTAPI_ipReservations_handler.cpp src/RESTAPI/RESTAPI_ipReservations_handler.h src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp src/RESTAPI/RESTAPI_wifiNetworks_handler.h src/RESTAPI/RESTAPI_wiredClients_handler.cpp src/RESTAPI/RESTAPI_wiredClients_handler.h src/RESTAPI/RESTAPI_wifiClients_handler.cpp src/RESTAPI/RESTAPI_wifiClients_handler.h src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp src/RESTAPI/RESTAPI_subscriberDevices_handler.h src/RESTObjects/RESTAPI_SubObjects.cpp src/RESTObjects/RESTAPI_SubObjects.h src/storage/storage_reservations.cpp src/storage/storage_reservations.h src/RESTAPI/RESTAPI_accessPoints_handler.cpp src/RESTAPI/RESTAPI_accessPoints_handler.h src/RESTAPI/RESTAPI_subscriber_handler.cpp src/RESTAPI/RESTAPI_subscriber_handler.h src/RESTAPI/RESTAPI_oauth2_handler.cpp src/RESTAPI/RESTAPI_oauth2_handler.h)
target_link_libraries(owsub PUBLIC
${Poco_LIBRARIES} ${MySQL_LIBRARIES}

2
build
View File

@@ -1 +1 @@
1
3

View File

@@ -495,7 +495,184 @@ components:
type: string
format: password
MFAChallengeRequest:
type: object
properties:
uuid:
type: string
format: uuid
question:
type: string
created:
type: integer
format: integer64
method:
type: string
MFAChallengeResponse:
type: object
properties:
uuid:
type: string
format: uuid
answer:
type: string
WebTokenRequest:
description: User Id and password.
type: object
required:
- userId
- password
properties:
userId:
type: string
default: support@example.com
password:
type: string
default: support
newPassword:
type: string
default: support
refreshToken:
type: string
example:
userId: support@example.com
password: support
WebTokenResult:
description: Login and Refresh Tokens to be used in subsequent API calls.
type: object
properties:
access_token:
type: string
refresh_token:
type: string
token_type:
type: string
expires_in:
type: integer
format: int32
idle_timeout:
type: integer
format: int32
username:
type: string
created:
type: integer
format: int64
userMustChangePassword:
type: boolean
errorCode:
type: integer # 0 = no error, 1 = passwordAlreadyUsed, 2=invalidPassword
aclTemplate:
$ref: '#/components/schemas/WebTokenAclTemplate'
AclTemplate:
type: object
properties:
Read:
type: boolean
ReadWrite:
type: boolean
ReadWriteCreate:
type: boolean
Delete:
type: boolean
PortalLogin:
type: boolean
WebTokenAclTemplate:
type: object
properties:
aclTemplate:
$ref: '#/components/schemas/AclTemplate'
paths:
/oauth2:
post:
tags:
- Authentication
summary: Get access token - to be used as Bearer token header for all other API requests.
operationId: getAccessToken
parameters:
- in: query
name: newPassword
description: used when a user is trying to change her password. This will be the new password.
schema:
type: string
required: false
- in: query
name: forgotPassword
description: A user forgot her password. She needs to present her e-mail address in the userId and set this to true
schema:
type: boolean
required: false
- in: query
name: requirements
description: A user forgot her password. She needs to present her e-mail address in the userId and set this to true
schema:
type: boolean
required: false
- in: query
name: resendMFACode
schema:
type: boolean
required: false
- in: query
name: completeMFAChallenge
schema:
type: boolean
required: false
requestBody:
description: User id and password
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/WebTokenRequest'
- $ref: '#/components/schemas/MFAChallengeResponse'
responses:
200:
description: successful operation
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/WebTokenResult'
- $ref: '#/components/schemas/MFAChallengeRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/oauth2/{token}:
delete:
tags:
- Authentication
summary: Revoke a token.
operationId: removeAccessToken
parameters:
- in: path
name: token
schema:
type:
string
required: true
responses:
204:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/responses/Success'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/accessPoints:
get:
tags:

View File

@@ -12,7 +12,7 @@
#include "RESTAPI//RESTAPI_wiredClients_handler.h"
#include "RESTAPI/RESTAPI_accessPoints_handler.h"
#include "RESTAPI/RESTAPI_subscriber_handler.h"
#include "RESTAPI/RESTAPI_login_handler.h"
#include "RESTAPI/RESTAPI_oauth2_handler.h"
namespace OpenWifi {
@@ -28,7 +28,7 @@ namespace OpenWifi {
RESTAPI_wiredClients_handler,
RESTAPI_accessPoints_handler,
RESTAPI_subscriber_handler,
RESTAPI_login_handler,
RESTAPI_oauth2_handler,
RESTAPI_system_command>(Path, Bindings, L, S);
}

View File

@@ -1,12 +0,0 @@
//
// Created by stephane bourque on 2021-11-07.
//
#include "RESTAPI_login_handler.h"
namespace OpenWifi {
void RESTAPI_login_handler::DoPost() {
}
}

View File

@@ -1,32 +0,0 @@
//
// Created by stephane bourque on 2021-11-07.
//
#ifndef OWSUB_RESTAPI_LOGIN_HANDLER_H
#define OWSUB_RESTAPI_LOGIN_HANDLER_H
#include "framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_login_handler : public RESTAPIHandler {
public:
RESTAPI_login_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
Internal){}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/login"}; };
void DoGet() final {};
void DoPost() final;
void DoPut() final {};
void DoDelete() final {};
private:
};
}
#endif //OWSUB_RESTAPI_LOGIN_HANDLER_H

View File

@@ -0,0 +1,21 @@
//
// Created by stephane bourque on 2021-11-28.
//
#include "RESTAPI_oauth2_handler.h"
namespace OpenWifi {
void RESTAPI_oauth2_handler::DoPost() {
}
void RESTAPI_oauth2_handler::DoGet() {
}
void RESTAPI_oauth2_handler::DoDelete() {
}
}

View File

@@ -0,0 +1,33 @@
//
// Created by stephane bourque on 2021-11-28.
//
#ifndef OWSUB_RESTAPI_OAUTH2_HANDLER_H
#define OWSUB_RESTAPI_OAUTH2_HANDLER_H
#include "framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_oauth2_handler : public RESTAPIHandler {
public:
RESTAPI_oauth2_handler(const RESTAPIHandler::BindingMap &bindings,
Poco::Logger &L,
RESTAPI_GenericServer & Server, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_POST,
Poco::Net::HTTPRequest::HTTP_DELETE,
Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
Internal, false, true , RateLimit{.Interval=1000,.MaxCalls=10}) {}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/oauth2/{token}","/api/v1/oauth2"}; };
void DoGet() final;
void DoPost() final;
void DoPut() final {};
void DoDelete() final;
private:
};
}
#endif //OWSUB_RESTAPI_OAUTH2_HANDLER_H

View File

@@ -12,6 +12,7 @@
#include "Daemon.h"
#ifdef TIP_GATEWAY_SERVICE
#include "DeviceRegistry.h"
#include "CapabilitiesCache.h"
#endif
#include "RESTAPI_GWobjects.h"
@@ -26,7 +27,7 @@ namespace OpenWifi::GWObjects {
void Device::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber", SerialNumber);
#ifdef TIP_GATEWAY_SERVICE
field_to_json(Obj,"deviceType", Daemon::instance()->IdentifyDevice(Compatible));
field_to_json(Obj,"deviceType", CapabilitiesCache::instance()->Get(Compatible));
#endif
field_to_json(Obj,"macAddress", MACAddress);
field_to_json(Obj,"manufacturer", Manufacturer);

View File

@@ -6,8 +6,7 @@
// Arilia Wireless Inc.
//
#ifndef UCENTRAL_RESTAPI_OBJECTS_H
#define UCENTRAL_RESTAPI_OBJECTS_H
#pragma once
#include "Poco/JSON/Object.h"
#include "RESTAPI_SecurityObjects.h"
@@ -111,7 +110,7 @@ namespace OpenWifi::GWObjects {
struct DefaultConfiguration {
std::string Name;
std::string Configuration;
std::string Models;
Types::StringVec Models;
std::string Description;
uint64_t Created;
uint64_t LastModified;
@@ -191,5 +190,3 @@ namespace OpenWifi::GWObjects {
void to_json(Poco::JSON::Object &Obj) const;
};
}
#endif //UCENTRAL_RESTAPI_OBJECTS_H

View File

@@ -440,11 +440,11 @@ namespace OpenWifi::ProvObjects {
return false;
}
void UserList::to_json(Poco::JSON::Object &Obj) const {
void UuidList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "list", list);
}
bool UserList::from_json(const Poco::JSON::Object::Ptr &Obj) {
bool UuidList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "list", list);
return true;
@@ -454,14 +454,46 @@ namespace OpenWifi::ProvObjects {
return false;
}
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, ACLACCESS A) {
switch(A) {
case READ: Obj.set(FieldName,"read"); break;
case MODIFY: Obj.set(FieldName,"modify"); break;
case CREATE: Obj.set(FieldName,"create"); break;
case DELETE: Obj.set(FieldName,"delete"); break;
case NONE:
default:
Obj.set(FieldName,"none");
}
}
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, ACLACCESS &A) {
if(Obj->has(FieldName)) {
auto V = Obj->getValue<std::string>(FieldName);
if(V=="read")
A = READ;
else if(V=="modify")
A = MODIFY;
else if(V=="create")
A = CREATE;
else if(V=="delete")
A = DELETE;
else if(V=="none")
A = NONE;
else
throw Poco::Exception("invalid JSON");
}
}
void ObjectACL::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "users", users);
RESTAPI_utils::field_to_json(Obj, "users", users);
RESTAPI_utils::field_to_json(Obj, "roles", roles);
field_to_json(Obj, "access", access);
}
bool ObjectACL::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "users", users);
RESTAPI_utils::field_from_json(Obj, "users", users);
RESTAPI_utils::field_from_json(Obj, "roles", roles);
field_from_json(Obj, "access", access);
return true;
} catch(...) {
@@ -471,12 +503,12 @@ namespace OpenWifi::ProvObjects {
}
void ObjectACLList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "list", list);
RESTAPI_utils::field_to_json(Obj, "list", list);
}
bool ObjectACLList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "list", list);
RESTAPI_utils::field_from_json(Obj, "list", list);
return true;
} catch(...) {
@@ -484,23 +516,54 @@ namespace OpenWifi::ProvObjects {
return false;
}
std::string to_string(VISIBILITY A) {
switch(A) {
case PUBLIC: return "public";
case SELECT: return "select";
case PRIVATE:
default:
return "private";
}
}
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, VISIBILITY A) {
Obj.set(FieldName,to_string(A));
}
VISIBILITY visibility_from_string(const std::string &V) {
if(V=="public")
return PUBLIC;
else if(V=="select")
return SELECT;
else if(V=="private")
return PRIVATE;
throw Poco::Exception("invalid json");
}
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, VISIBILITY &A) {
if(Obj->has(FieldName)) {
auto V = Obj->getValue<std::string>(FieldName);
A = visibility_from_string(V);
}
}
void Map::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"data",data);
field_to_json( Obj,"entity",entity);
field_to_json( Obj,"creator",creator);
RESTAPI_utils::field_to_json( Obj,"data",data);
RESTAPI_utils::field_to_json( Obj,"entity",entity);
RESTAPI_utils::field_to_json( Obj,"creator",creator);
field_to_json( Obj,"visibility",visibility);
field_to_json( Obj,"access",access);
RESTAPI_utils::field_to_json( Obj,"access",access);
}
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"data",data);
field_from_json( Obj,"entity",entity);
field_from_json( Obj,"creator",creator);
RESTAPI_utils::field_from_json( Obj,"data",data);
RESTAPI_utils::field_from_json( Obj,"entity",entity);
RESTAPI_utils::field_from_json( Obj,"creator",creator);
field_from_json( Obj,"visibility",visibility);
field_from_json( Obj,"access",access);
RESTAPI_utils::field_from_json( Obj,"access",access);
return true;
} catch(...) {
@@ -509,12 +572,12 @@ namespace OpenWifi::ProvObjects {
}
void MapList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj,"list",list);
RESTAPI_utils::field_to_json( Obj,"list",list);
}
bool MapList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj,"list",list);
RESTAPI_utils::field_from_json( Obj,"list",list);
return true;
} catch(...) {
@@ -530,7 +593,7 @@ namespace OpenWifi::ProvObjects {
if(I.name.empty())
return false;
if(O->has("description"))
if(O->has("description"))
I.description = O->get("description").toString();
SecurityObjects::MergeNotes(O,U,I.notes);
SecurityObjects::NoteInfoVec N;
@@ -566,4 +629,5 @@ namespace OpenWifi::ProvObjects {
return true;
}
};
}

View File

@@ -6,9 +6,7 @@
// Arilia Wireless Inc.
//
#ifndef OWPROV_RESTAPI_PROVOBJECTS_H
#define OWPROV_RESTAPI_PROVOBJECTS_H
#pragma once
#include <string>
#include "RESTAPI_SecurityObjects.h"
@@ -324,16 +322,21 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct UserList {
struct UuidList {
std::vector<std::string> list;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum ACLACCESS {
NONE, READ, MODIFY, CREATE, DELETE
};
struct ObjectACL {
UserList users;
std::string access;
UuidList users;
UuidList roles;
ACLACCESS access = NONE;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -346,12 +349,19 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum VISIBILITY {
PUBLIC, PRIVATE, SELECT
};
std::string to_string(VISIBILITY A);
VISIBILITY visibility_from_string(const std::string &V);
struct Map {
ObjectInfo info;
std::string data;
std::string entity;
std::string creator;
std::string visibility;
VISIBILITY visibility = PRIVATE;
ObjectACLList access;
void to_json(Poco::JSON::Object &Obj) const;
@@ -367,8 +377,4 @@ namespace OpenWifi::ProvObjects {
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
};
#endif //OWPROV_RESTAPI_PROVOBJECTS_H

View File

@@ -491,7 +491,6 @@ namespace OpenWifi::SecurityObjects {
field_to_json(Obj,"expires",expires);
field_to_json(Obj,"completed",completed);
field_to_json(Obj,"canceled",canceled);
}
bool ActionLink::from_json(Poco::JSON::Object::Ptr &Obj) {
@@ -511,6 +510,24 @@ namespace OpenWifi::SecurityObjects {
return true;
} catch(...) {
}
return false;
}
void Preferences::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"id",id);
field_to_json(Obj,"modified",modified);
field_to_json(Obj,"data",data);
}
bool Preferences::from_json(Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"id",id);
field_from_json(Obj,"modified",modified);
field_from_json(Obj,"data",data);
return true;
} catch(...) {
}
return false;
}

View File

@@ -9,8 +9,8 @@
#ifndef UCENTRAL_RESTAPI_SECURITYOBJECTS_H
#define UCENTRAL_RESTAPI_SECURITYOBJECTS_H
#include "Poco/JSON/Object.h"
#include "framework/OpenWifiTypes.h"
#include "Poco/JSON/Object.h"
namespace OpenWifi::SecurityObjects {
@@ -244,6 +244,14 @@ namespace OpenWifi::SecurityObjects {
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(Poco::JSON::Object::Ptr &Obj);
};
struct Preferences {
std::string id;
uint64_t modified;
Types::StringPairVec data;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(Poco::JSON::Object::Ptr &Obj);
};
}
#endif //UCENTRAL_RESTAPI_SECURITYOBJECTS_H

View File

@@ -424,32 +424,4 @@ namespace OpenWifi::SubObjects {
}
return false;
}
void PasswordChange::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "oldPassword", oldPassword);
field_to_json(Obj, "newPassword", newPassword);
}
bool PasswordChange::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "oldPassword", oldPassword);
field_from_json(Obj, "newPassword", newPassword);
return true;
} catch (...) {
}
return false;
}
void PasswordCreation::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "newPassword", newPassword);
}
bool PasswordCreation::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "newPassword", newPassword);
return true;
} catch (...) {
}
return false;
}
}

View File

@@ -226,21 +226,6 @@ namespace OpenWifi::SubObjects {
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct PasswordChange {
std::string oldPassword;
std::string newPassword;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct PasswordCreation {
std::string newPassword;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
}
#endif //OWSUB_RESTAPI_SUBOBJECTS_H

View File

@@ -2,8 +2,7 @@
// Created by stephane bourque on 2021-09-14.
//
#ifndef OWPROV_CONFIGURATIONVALIDATOR_H
#define OWPROV_CONFIGURATIONVALIDATOR_H
#pragma once
#include <nlohmann/json-schema.hpp>
#include "framework/MicroService.h"
@@ -43,4 +42,3 @@ namespace OpenWifi {
inline bool ValidateUCentralConfiguration(const std::string &C, std::string &Error) { return ConfigurationValidator::instance()->Validate(C, Error); }
}
#endif //OWPROV_CONFIGURATIONVALIDATOR_H

View File

@@ -2,8 +2,7 @@
// Created by stephane bourque on 2021-10-08.
//
#ifndef OWPROV_COUNTRYCODES_H
#define OWPROV_COUNTRYCODES_H
#pragma once
#include <vector>
#include <string>
@@ -270,4 +269,3 @@ namespace OpenWifi {
}
#endif //OWPROV_COUNTRYCODES_H

View File

@@ -5,8 +5,8 @@
// Created by Stephane Bourque on 2021-03-04.
// Arilia Wireless Inc.
//
#ifndef UCENTRALGW_KAFKA_TOPICS_H
#define UCENTRALGW_KAFKA_TOPICS_H
#pragma once
namespace OpenWifi::KafkaTopics {
static const std::string HEALTHCHECK{"healthcheck"};
@@ -37,4 +37,3 @@ namespace OpenWifi::KafkaTopics {
}
}
#endif // UCENTRALGW_KAFKA_TOPICS_H

View File

@@ -803,6 +803,20 @@ namespace OpenWifi::Utils {
return R;
}
[[nodiscard]] inline std::string IntToSerialNumber(uint64_t S) {
char b[16];
for(int i=0;i<12;++i) {
int B = (S & 0x0f);
if(B<10)
b[11-i] = B+'0';
else
b[11-i] = B - 10 + 'a';
S >>= 4 ;
}
b[12]=0;
return b;
}
[[nodiscard]] inline bool SerialNumberMatch(const std::string &S1, const std::string &S2, int Bits=2) {
auto S1_i = SerialNumberToInt(S1);
@@ -1904,7 +1918,7 @@ namespace OpenWifi {
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 1);
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 0);
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
@@ -1916,7 +1930,7 @@ namespace OpenWifi {
QB_.AdditionalInfo = GetBoolParameter(RESTAPI::Protocol::WITHEXTENDEDINFO,false);
if(QB_.Offset<1)
QB_.Offset=1;
QB_.Offset=0;
return true;
}

View File

@@ -2,8 +2,7 @@
// Created by stephane bourque on 2021-09-12.
//
#ifndef OWPROV_RESTAPI_ERRORS_H
#define OWPROV_RESTAPI_ERRORS_H
#pragma once
namespace OpenWifi::RESTAPI::Errors {
static const std::string MissingUUID{"Missing UUID."};
@@ -62,4 +61,3 @@ namespace OpenWifi::RESTAPI::Errors {
static const std::string ExpiredToken{"Token has expired, user must login."};
}
#endif //OWPROV_RESTAPI_ERRORS_H

View File

@@ -6,8 +6,7 @@
// Arilia Wireless Inc.
//
#ifndef UCENTRALGW_RESTAPI_PROTOCOL_H
#define UCENTRALGW_RESTAPI_PROTOCOL_H
#pragma once
namespace OpenWifi::RESTAPI::Protocol {
static const char * CAPABILITIES = "capabilities";
@@ -136,5 +135,3 @@ namespace OpenWifi::RESTAPI::Protocol {
static const char * UI = "UI";
}
#endif // UCENTRALGW_RESTAPI_PROTOCOL_H

View File

@@ -2,8 +2,7 @@
// Created by stephane bourque on 2021-10-06.
//
#ifndef OPENWIFI_STORAGE_H
#define OPENWIFI_STORAGE_H
#pragma once
#include "Poco/Data/Session.h"
#include "Poco/Data/SessionPool.h"
@@ -54,13 +53,13 @@ namespace OpenWifi {
[[nodiscard]] inline std::string ComputeRange(uint64_t From, uint64_t HowMany) {
if(dbType_==sqlite) {
return " LIMIT " + std::to_string(From-1) + ", " + std::to_string(HowMany) + " ";
return " LIMIT " + std::to_string(From) + ", " + std::to_string(HowMany) + " ";
} else if(dbType_==pgsql) {
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
} else if(dbType_==mysql) {
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
}
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
}
inline std::string ConvertParams(const std::string & S) const {
@@ -165,5 +164,3 @@ namespace OpenWifi {
#endif
}
#endif //OPENWIFI_STORAGE_H

View File

@@ -6,8 +6,7 @@
// Arilia Wireless Inc.
//
#ifndef __OPENWIFI_ORM_H__
#define __OPENWIFI_ORM_H__
#pragma once
#include <string>
#include <memory>
@@ -755,4 +754,3 @@ namespace ORM {
};
}
#endif

View File

@@ -5,9 +5,7 @@
// Created by Stephane Bourque on 2021-03-04.
// Arilia Wireless Inc.
//
#ifndef UCENTRALGW_UCENTRALPROTOCOL_H
#define UCENTRALGW_UCENTRALPROTOCOL_H
#pragma once
#include "Poco/String.h"
@@ -130,5 +128,3 @@ namespace OpenWifi::uCentralProtocol {
return ET_UNKNOWN;
};
}
#endif // UCENTRALGW_UCENTRALPROTOCOL_H