secure remaining endpoints to authenticated users
This commit is contained in:
parent
3009e120a6
commit
0708a54780
@ -1,7 +1,9 @@
|
|||||||
#include <APStatus.h>
|
#include <APStatus.h>
|
||||||
|
|
||||||
APStatus::APStatus(AsyncWebServer *server) : _server(server) {
|
APStatus::APStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
|
||||||
_server->on(AP_STATUS_SERVICE_PATH, HTTP_GET, std::bind(&APStatus::apStatus, this, std::placeholders::_1));
|
_server->on(AP_STATUS_SERVICE_PATH, HTTP_GET,
|
||||||
|
_securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APStatus::apStatus(AsyncWebServerRequest *request) {
|
void APStatus::apStatus(AsyncWebServerRequest *request) {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <AsyncArduinoJson6.h>
|
#include <AsyncArduinoJson6.h>
|
||||||
#include <IPAddress.h>
|
#include <IPAddress.h>
|
||||||
|
#include <SecurityManager.h>
|
||||||
|
|
||||||
#define MAX_AP_STATUS_SIZE 1024
|
#define MAX_AP_STATUS_SIZE 1024
|
||||||
#define AP_STATUS_SERVICE_PATH "/rest/apStatus"
|
#define AP_STATUS_SERVICE_PATH "/rest/apStatus"
|
||||||
@ -21,11 +22,12 @@ class APStatus {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
APStatus(AsyncWebServer *server);
|
APStatus(AsyncWebServer *server, SecurityManager* securityManager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AsyncWebServer* _server;
|
AsyncWebServer* _server;
|
||||||
|
SecurityManager* _securityManager;
|
||||||
|
|
||||||
void apStatus(AsyncWebServerRequest *request);
|
void apStatus(AsyncWebServerRequest *request);
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include <NTPStatus.h>
|
#include <NTPStatus.h>
|
||||||
|
|
||||||
NTPStatus::NTPStatus(AsyncWebServer *server) : _server(server) {
|
NTPStatus::NTPStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
|
||||||
_server->on(NTP_STATUS_SERVICE_PATH, HTTP_GET, std::bind(&NTPStatus::ntpStatus, this, std::placeholders::_1));
|
_server->on(NTP_STATUS_SERVICE_PATH, HTTP_GET,
|
||||||
|
_securityManager->wrapRequest(std::bind(&NTPStatus::ntpStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NTPStatus::ntpStatus(AsyncWebServerRequest *request) {
|
void NTPStatus::ntpStatus(AsyncWebServerRequest *request) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <AsyncArduinoJson6.h>
|
#include <AsyncArduinoJson6.h>
|
||||||
#include <TimeLib.h>
|
#include <TimeLib.h>
|
||||||
#include <NtpClientLib.h>
|
#include <NtpClientLib.h>
|
||||||
|
#include <SecurityManager.h>
|
||||||
|
|
||||||
#define MAX_NTP_STATUS_SIZE 1024
|
#define MAX_NTP_STATUS_SIZE 1024
|
||||||
#define NTP_STATUS_SERVICE_PATH "/rest/ntpStatus"
|
#define NTP_STATUS_SERVICE_PATH "/rest/ntpStatus"
|
||||||
@ -22,11 +23,12 @@ class NTPStatus {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NTPStatus(AsyncWebServer *server);
|
NTPStatus(AsyncWebServer *server, SecurityManager* securityManager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AsyncWebServer* _server;
|
AsyncWebServer* _server;
|
||||||
|
SecurityManager* _securityManager;
|
||||||
|
|
||||||
void ntpStatus(AsyncWebServerRequest *request);
|
void ntpStatus(AsyncWebServerRequest *request);
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include <SystemStatus.h>
|
#include <SystemStatus.h>
|
||||||
|
|
||||||
SystemStatus::SystemStatus(AsyncWebServer *server) : _server(server) {
|
SystemStatus::SystemStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
|
||||||
_server->on(SYSTEM_STATUS_SERVICE_PATH, HTTP_GET, std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1));
|
_server->on(SYSTEM_STATUS_SERVICE_PATH, HTTP_GET,
|
||||||
|
_securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemStatus::systemStatus(AsyncWebServerRequest *request) {
|
void SystemStatus::systemStatus(AsyncWebServerRequest *request) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <AsyncArduinoJson6.h>
|
#include <AsyncArduinoJson6.h>
|
||||||
|
#include <SecurityManager.h>
|
||||||
|
|
||||||
#define MAX_ESP_STATUS_SIZE 1024
|
#define MAX_ESP_STATUS_SIZE 1024
|
||||||
#define SYSTEM_STATUS_SERVICE_PATH "/rest/systemStatus"
|
#define SYSTEM_STATUS_SERVICE_PATH "/rest/systemStatus"
|
||||||
@ -20,11 +21,12 @@ class SystemStatus {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SystemStatus(AsyncWebServer *server);
|
SystemStatus(AsyncWebServer *server, SecurityManager* securityManager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AsyncWebServer* _server;
|
AsyncWebServer* _server;
|
||||||
|
SecurityManager* _securityManager;
|
||||||
|
|
||||||
void systemStatus(AsyncWebServerRequest *request);
|
void systemStatus(AsyncWebServerRequest *request);
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include <WiFiStatus.h>
|
#include <WiFiStatus.h>
|
||||||
|
|
||||||
WiFiStatus::WiFiStatus(AsyncWebServer *server) : _server(server) {
|
WiFiStatus::WiFiStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
|
||||||
_server->on(WIFI_STATUS_SERVICE_PATH, HTTP_GET, std::bind(&WiFiStatus::wifiStatus, this, std::placeholders::_1));
|
_server->on(WIFI_STATUS_SERVICE_PATH, HTTP_GET,
|
||||||
|
_securityManager->wrapRequest(std::bind(&WiFiStatus::wifiStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
|
||||||
|
);
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
_onStationModeConnectedHandler = WiFi.onStationModeConnected(onStationModeConnected);
|
_onStationModeConnectedHandler = WiFi.onStationModeConnected(onStationModeConnected);
|
||||||
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(onStationModeDisconnected);
|
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(onStationModeDisconnected);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <AsyncArduinoJson6.h>
|
#include <AsyncArduinoJson6.h>
|
||||||
#include <IPAddress.h>
|
#include <IPAddress.h>
|
||||||
|
#include <SecurityManager.h>
|
||||||
|
|
||||||
#define MAX_WIFI_STATUS_SIZE 1024
|
#define MAX_WIFI_STATUS_SIZE 1024
|
||||||
#define WIFI_STATUS_SERVICE_PATH "/rest/wifiStatus"
|
#define WIFI_STATUS_SERVICE_PATH "/rest/wifiStatus"
|
||||||
@ -21,11 +22,12 @@ class WiFiStatus {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WiFiStatus(AsyncWebServer *server);
|
WiFiStatus(AsyncWebServer *server, SecurityManager* securityManager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AsyncWebServer* _server;
|
AsyncWebServer* _server;
|
||||||
|
SecurityManager* _securityManager;
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
// handler refrences for logging important WiFi events over serial
|
// handler refrences for logging important WiFi events over serial
|
||||||
|
@ -35,10 +35,10 @@ OTASettingsService otaSettingsService = OTASettingsService(&server, &SPIFFS, &se
|
|||||||
AuthenticationService authenticationService = AuthenticationService(&server, &securitySettingsService);
|
AuthenticationService authenticationService = AuthenticationService(&server, &securitySettingsService);
|
||||||
|
|
||||||
WiFiScanner wifiScanner = WiFiScanner(&server, &securitySettingsService);
|
WiFiScanner wifiScanner = WiFiScanner(&server, &securitySettingsService);
|
||||||
WiFiStatus wifiStatus = WiFiStatus(&server);
|
WiFiStatus wifiStatus = WiFiStatus(&server, &securitySettingsService);
|
||||||
NTPStatus ntpStatus = NTPStatus(&server);
|
NTPStatus ntpStatus = NTPStatus(&server, &securitySettingsService);
|
||||||
APStatus apStatus = APStatus(&server);
|
APStatus apStatus = APStatus(&server, &securitySettingsService);
|
||||||
SystemStatus systemStatus = SystemStatus(&server);
|
SystemStatus systemStatus = SystemStatus(&server, &securitySettingsService);;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Disable wifi config persistance
|
// Disable wifi config persistance
|
||||||
|
Loading…
Reference in New Issue
Block a user