diff --git a/interface/src/App.tsx b/interface/src/App.tsx index f69032319..77f79e41d 100644 --- a/interface/src/App.tsx +++ b/interface/src/App.tsx @@ -4,7 +4,6 @@ import { ToastContainer, Slide } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.min.css'; import { localStorageDetector } from 'typesafe-i18n/detectors'; -import { FeaturesLoader } from './contexts/features'; import type { FC } from 'react'; import AppRouting from 'AppRouting'; import CustomTheme from 'CustomTheme'; @@ -27,9 +26,7 @@ const App: FC = () => { return ( - - - + { const { LL, setLocale, locale } = useContext(I18nContext); - const { features } = useContext(FeaturesContext); - const [signInRequest, setSignInRequest] = useState({ username: '', password: '' @@ -112,7 +109,6 @@ const SignIn: FC = () => { })} > {PROJECT_NAME} - {features.version} diff --git a/interface/src/api/features.ts b/interface/src/api/features.ts deleted file mode 100644 index c0dd66e4f..000000000 --- a/interface/src/api/features.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { alovaInstance } from './endpoints'; - -import type { Features } from 'types'; - -export const readFeatures = () => alovaInstance.Get('/rest/features'); diff --git a/interface/src/contexts/features/FeaturesLoader.tsx b/interface/src/contexts/features/FeaturesLoader.tsx deleted file mode 100644 index 38e5e0196..000000000 --- a/interface/src/contexts/features/FeaturesLoader.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useRequest } from 'alova'; - -import { FeaturesContext } from '.'; -import type { FC } from 'react'; - -import type { RequiredChildrenProps } from 'utils'; -import * as FeaturesApi from 'api/features'; - -const FeaturesLoader: FC = (props) => { - const { data: features } = useRequest(FeaturesApi.readFeatures); - - if (features) { - return ( - - {props.children} - - ); - } -}; - -export default FeaturesLoader; diff --git a/interface/src/contexts/features/context.ts b/interface/src/contexts/features/context.ts deleted file mode 100644 index 78a8f1ec2..000000000 --- a/interface/src/contexts/features/context.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createContext } from 'react'; - -import type { Features } from 'types'; - -export interface FeaturesContextValue { - features: Features; -} - -const FeaturesContextDefaultValue = {} as FeaturesContextValue; -export const FeaturesContext = createContext(FeaturesContextDefaultValue); diff --git a/interface/src/contexts/features/index.ts b/interface/src/contexts/features/index.ts deleted file mode 100644 index f8df83c02..000000000 --- a/interface/src/contexts/features/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './context'; -export { default as FeaturesLoader } from './FeaturesLoader'; diff --git a/interface/src/framework/system/SystemStatusForm.tsx b/interface/src/framework/system/SystemStatusForm.tsx index f6f7203cb..ba710e36e 100644 --- a/interface/src/framework/system/SystemStatusForm.tsx +++ b/interface/src/framework/system/SystemStatusForm.tsx @@ -29,7 +29,6 @@ import { import { useRequest } from 'alova'; import { useContext, useState } from 'react'; import { toast } from 'react-toastify'; -import { FeaturesContext } from '../../contexts/features'; import RestartMonitor from './RestartMonitor'; import SystemStatusVersionDialog from './SystemStatusVersionDialog'; import type { FC } from 'react'; @@ -54,8 +53,6 @@ const SystemStatusForm: FC = () => { const [restarting, setRestarting] = useState(); const [versionDialogOpen, setVersionDialogOpen] = useState(false); - const { features } = useContext(FeaturesContext); - const { send: restartCommand } = useRequest(SystemApi.restart(), { immediate: false }); @@ -355,7 +352,7 @@ const SystemStatusForm: FC = () => { open={versionDialogOpen} onClose={() => setVersionDialogOpen(false)} version={data.emsesp_version} - platform={features.platform} + platform={data.esp_platform} /> )} diff --git a/interface/src/types/index.ts b/interface/src/types/index.ts index 632d8907b..420f7e2bf 100644 --- a/interface/src/types/index.ts +++ b/interface/src/types/index.ts @@ -1,5 +1,4 @@ export * from './ap'; -export * from './features'; export * from './me'; export * from './mqtt'; export * from './ntp'; diff --git a/lib/framework/AuthenticationService.cpp b/lib/framework/AuthenticationService.cpp index fd316a87c..f0fc92dbb 100644 --- a/lib/framework/AuthenticationService.cpp +++ b/lib/framework/AuthenticationService.cpp @@ -2,8 +2,6 @@ using namespace std::placeholders; // for `_1` etc -#if FT_ENABLED(FT_SECURITY) - AuthenticationService::AuthenticationService(AsyncWebServer * server, SecurityManager * securityManager) : _securityManager(securityManager) , _signInHandler(SIGN_IN_PATH, std::bind(&AuthenticationService::signIn, this, _1, _2)) { @@ -43,5 +41,3 @@ void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant AsyncWebServerResponse * response = request->beginResponse(401); request->send(response); } - -#endif diff --git a/lib/framework/AuthenticationService.h b/lib/framework/AuthenticationService.h index d8a823485..c7ca70646 100644 --- a/lib/framework/AuthenticationService.h +++ b/lib/framework/AuthenticationService.h @@ -10,8 +10,6 @@ #define MAX_AUTHENTICATION_SIZE 256 -#if FT_ENABLED(FT_SECURITY) - class AuthenticationService { public: AuthenticationService(AsyncWebServer * server, SecurityManager * securityManager); @@ -26,5 +24,3 @@ class AuthenticationService { }; #endif - -#endif diff --git a/lib/framework/ESP8266React.cpp b/lib/framework/ESP8266React.cpp index 8fd7719da..94a3b78fd 100644 --- a/lib/framework/ESP8266React.cpp +++ b/lib/framework/ESP8266React.cpp @@ -3,8 +3,7 @@ #include ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs) - : _featureService(server) - , _securitySettingsService(server, fs) + : _securitySettingsService(server, fs) , _networkSettingsService(server, fs, &_securitySettingsService) , _wifiScanner(server, &_securitySettingsService) , _networkStatus(server, &_securitySettingsService) @@ -20,12 +19,12 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs) , _restartService(server, &_securitySettingsService) , _factoryResetService(server, fs, &_securitySettingsService) , _systemStatus(server, &_securitySettingsService) { - // Serve static resources from PROGMEM + // Serve static resources WWWData::registerRoutes([server, this](const String & uri, const String & contentType, const uint8_t * content, size_t len) { ArRequestHandlerFunction requestHandler = [contentType, content, len](AsyncWebServerRequest * request) { AsyncWebServerResponse * response = request->beginResponse_P(200, contentType, content, len); response->addHeader("Content-Encoding", "gzip"); - // response->addHeader("Cache-Control", "public, immutable, max-age=31536000"); + response->addHeader("Cache-Control", "public, immutable, max-age=31536000"); // response->addHeader("Content-Encoding", "br"); // only works over HTTPS request->send(response); }; diff --git a/lib/framework/ESP8266React.h b/lib/framework/ESP8266React.h index 2bab9e190..2a86019e1 100644 --- a/lib/framework/ESP8266React.h +++ b/lib/framework/ESP8266React.h @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -72,7 +71,6 @@ class ESP8266React { } private: - FeaturesService _featureService; SecuritySettingsService _securitySettingsService; NetworkSettingsService _networkSettingsService; WiFiScanner _wifiScanner; diff --git a/lib/framework/Features.h b/lib/framework/Features.h index 204caaa18..1629b39ef 100644 --- a/lib/framework/Features.h +++ b/lib/framework/Features.h @@ -1,10 +1,6 @@ #ifndef Features_h #define Features_h -// modified by Proddy - -#define FT_ENABLED(feature) feature - // project feature on by default #ifndef FT_PROJECT #define FT_PROJECT 1 diff --git a/lib/framework/FeaturesService.cpp b/lib/framework/FeaturesService.cpp deleted file mode 100644 index cddb85586..000000000 --- a/lib/framework/FeaturesService.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include "../../src/emsesp_stub.hpp" - -using namespace std::placeholders; // for `_1` etc - -FeaturesService::FeaturesService(AsyncWebServer * server) { - server->on(FEATURES_SERVICE_PATH, HTTP_GET, std::bind(&FeaturesService::features, this, _1)); -} - -void FeaturesService::features(AsyncWebServerRequest * request) { - AsyncJsonResponse * response = new AsyncJsonResponse(false); - JsonObject root = response->getRoot(); - - root["version"] = EMSESP_APP_VERSION; - root["platform"] = EMSESP_PLATFORM; - - response->setLength(); - request->send(response); -} diff --git a/lib/framework/FeaturesService.h b/lib/framework/FeaturesService.h deleted file mode 100644 index dc64a8b3d..000000000 --- a/lib/framework/FeaturesService.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FeaturesService_h -#define FeaturesService_h - -#include - -#include -#include -#include -#include - -// #define MAX_FEATURES_SIZE 256 -#define FEATURES_SERVICE_PATH "/rest/features" - -class FeaturesService { - public: - FeaturesService(AsyncWebServer * server); - - private: - void features(AsyncWebServerRequest * request); -}; - -#endif diff --git a/lib/framework/SecuritySettingsService.cpp b/lib/framework/SecuritySettingsService.cpp index 9b5ab85c6..2a83e34b6 100644 --- a/lib/framework/SecuritySettingsService.cpp +++ b/lib/framework/SecuritySettingsService.cpp @@ -1,7 +1,5 @@ #include -#if FT_ENABLED(FT_SECURITY) - #include "../../src/emsesp_stub.hpp" SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) @@ -125,33 +123,3 @@ void SecuritySettingsService::generateToken(AsyncWebServerRequest * request) { } request->send(401); } - -#else - -User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); - -SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) - : SecurityManager() { -} -SecuritySettingsService::~SecuritySettingsService() { -} - -ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest * request) { return true; }; -} - -// Return the admin user on all request - disabling security features -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { - return Authentication(ADMIN_USER); -} - -// Return the function unwrapped -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -#endif diff --git a/lib/framework/SecuritySettingsService.h b/lib/framework/SecuritySettingsService.h index f122d0ba2..3ec8dd755 100644 --- a/lib/framework/SecuritySettingsService.h +++ b/lib/framework/SecuritySettingsService.h @@ -28,11 +28,9 @@ #define GENERATE_TOKEN_SIZE 512 #define GENERATE_TOKEN_PATH "/rest/generateToken" -#if FT_ENABLED(FT_SECURITY) - class SecuritySettings { public: - String jwtSecret; + String jwtSecret; std::vector users; // std::list users; @@ -102,19 +100,4 @@ class SecuritySettingsService : public StatefulService, public boolean validatePayload(JsonObject parsedPayload, User * user); }; -#else - -class SecuritySettingsService : public SecurityManager { - public: - SecuritySettingsService(AsyncWebServer * server, FS * fs); - ~SecuritySettingsService(); - - // minimal set of functions to support framework with security settings disabled - Authentication authenticateRequest(AsyncWebServerRequest * request); - ArRequestFilterFunction filterRequest(AuthenticationPredicate predicate); - ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate); - ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate); -}; - -#endif -#endif +#endif \ No newline at end of file diff --git a/lib_standalone/Features.h b/lib_standalone/Features.h index 28cd6d551..526806569 100644 --- a/lib_standalone/Features.h +++ b/lib_standalone/Features.h @@ -1,8 +1,6 @@ #ifndef Features_h #define Features_h -#define FT_ENABLED(feature) feature - // project feature off by default #ifndef FT_PROJECT #define FT_PROJECT 0 diff --git a/lib_standalone/SecurityManager.h b/lib_standalone/SecurityManager.h index cebff2229..d9e73e68c 100644 --- a/lib_standalone/SecurityManager.h +++ b/lib_standalone/SecurityManager.h @@ -69,10 +69,8 @@ class AuthenticationPredicates { class SecurityManager { public: -#if FT_ENABLED(FT_SECURITY) virtual Authentication authenticate(const String & username, const String & password) = 0; virtual String generateJWT(User * user) = 0; -#endif virtual Authentication authenticateRequest(AsyncWebServerRequest * request) = 0; virtual ArRequestFilterFunction filterRequest(AuthenticationPredicate predicate) = 0; diff --git a/lib_standalone/SecuritySettingsService.cpp b/lib_standalone/SecuritySettingsService.cpp index 7cc393418..97e7d9223 100644 --- a/lib_standalone/SecuritySettingsService.cpp +++ b/lib_standalone/SecuritySettingsService.cpp @@ -2,8 +2,6 @@ #include -#if FT_ENABLED(FT_SECURITY) - #include "../../src/emsesp_stub.h" // proddy added SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) @@ -110,34 +108,4 @@ ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequest }; } -#else - -User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); - -SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs) - : SecurityManager() { -} -SecuritySettingsService::~SecuritySettingsService() { -} - -ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPredicate predicate) { - return [this, predicate](AsyncWebServerRequest * request) { return true; }; -} - -// Return the admin user on all request - disabling security features -Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest * request) { - return Authentication(ADMIN_USER); -} - -// Return the function unwrapped -ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) { - return onRequest; -} - -#endif - #endif \ No newline at end of file diff --git a/lib_standalone/SecuritySettingsService.h b/lib_standalone/SecuritySettingsService.h index a283854e0..4195cf1e6 100644 --- a/lib_standalone/SecuritySettingsService.h +++ b/lib_standalone/SecuritySettingsService.h @@ -25,8 +25,6 @@ #define SECURITY_SETTINGS_FILE "/config/securitySettings.json" #define SECURITY_SETTINGS_PATH "/rest/securitySettings" -#if FT_ENABLED(FT_SECURITY) - class SecuritySettings { public: String jwtSecret; @@ -103,4 +101,3 @@ class SecuritySettingsService : public SecurityManager { }; #endif -#endif