diff --git a/Makefile b/Makefile index 22407170..b4309dc6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ default: build-frontend cargo build -run: build-frontend-dev +run: build-frontend cargo run dev-env: diff --git a/src/api/v1/pow/mod.rs b/src/api/v1/pow/mod.rs index 5d2f781f..d8e8e843 100644 --- a/src/api/v1/pow/mod.rs +++ b/src/api/v1/pow/mod.rs @@ -26,30 +26,7 @@ pub use super::mcaptcha::duration::GetDurationResp; pub use super::mcaptcha::is_authenticated; pub use super::mcaptcha::levels::I32Levels; -//lazy_static! { -// pub static ref CORS: Cors = Cors::default() -// .allow_any_origin() -// .allowed_methods(vec!["POST"]) -// .allow_any_header() -// .max_age(0) -// .send_wildcard(); -//} - -//pub fn services(cfg: &mut web::ServiceConfig) -> web::Scope { -// let captcha_api_cors = Cors::default() -// .allow_any_origin() -// .allowed_methods(vec!["POST"]) -// .allow_any_header() -// .max_age(0) -// .send_wildcard(); -// -// web::scope("/api/v1/pow/*") -// .wrap(captcha_api_cors) -// .configure(pow_services) -// -// // pow -//} - +// middleware protected by scope pub fn services(cfg: &mut web::ServiceConfig) { let captcha_api_cors = Cors::default() .allow_any_origin() @@ -63,14 +40,11 @@ pub fn services(cfg: &mut web::ServiceConfig) { .wrap(captcha_api_cors) .configure(intenral_services), ); - - // cfg.service( - - // cfg.service(get_config::get_config); - // cfg.service(verify_pow::verify_pow); - // cfg.service(verify_token::validate_captcha_token); } +// internal route aggregator, it's easy to use macros +// to denote paths than having to type it out +// but remember, final path = scope + macro path fn intenral_services(cfg: &mut web::ServiceConfig) { cfg.service(get_config::get_config); cfg.service(verify_pow::verify_pow); diff --git a/src/main.rs b/src/main.rs index e655a75f..a84f635a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,16 +21,14 @@ use actix_web::{ client::Client, error::InternalError, http::StatusCode, middleware, web::JsonConfig, App, HttpServer, }; -//use awc::Client; use cache_buster::Files as FileMap; use lazy_static::lazy_static; use log::info; -mod data; -mod errors; -//mod routes; mod api; +mod data; mod docs; +mod errors; mod settings; mod static_assets; mod templates; @@ -43,15 +41,10 @@ pub use settings::Settings; lazy_static! { pub static ref SETTINGS: Settings = Settings::new().unwrap(); -// pub static ref GIT_COMMIT_HASH: String = env::var("GIT_HASH").unwrap(); - -// pub static ref OPEN_API_DOC: String = env::var("OPEN_API_DOCS").unwrap(); pub static ref S: String = env::var("S").unwrap(); - pub static ref FILES: FileMap = FileMap::load(); pub static ref JS: &'static str = FILES.get("./static/bundle/main.js").unwrap(); pub static ref CSS: &'static str = FILES.get("./static/bundle/main.css").unwrap(); - } pub static OPEN_API_DOC: &str = env!("OPEN_API_DOCS"); @@ -80,13 +73,6 @@ async fn main() -> std::io::Result<()> { HttpServer::new(move || { let client = Client::default(); - // let captcha_api_cors = Cors::default() - // .allow_any_origin() - // .allowed_methods(vec!["POST"]) - // .allow_any_header() - // .max_age(0) - // .send_wildcard(); - App::new() .wrap(middleware::Logger::default()) .wrap(get_identity_service()) @@ -98,16 +84,10 @@ async fn main() -> std::io::Result<()> { )) .configure(v1::pow::services) .configure(v1::services) - //.service( - // scope("/") - // .wrap(captcha_api_cors) - // .configure(v1::pow::services), - //) .configure(docs::services) .configure(templates::services) .configure(static_assets::services) .app_data(get_json_err()) - // .service(Files::new("/", "./prod")) }) .bind(SETTINGS.server.get_ip()) .unwrap() diff --git a/static/bundle/main.js b/static/bundle/main.js index 3ffb1ec7..8053e24f 100644 --- a/static/bundle/main.js +++ b/static/bundle/main.js @@ -1,287 +1 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./templates/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./templates/auth/forms.scss": -/*!****************************************************************************************************************!*\ - !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./templates/auth/forms.scss ***! - \****************************************************************************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/api.js */ \"./node_modules/css-loader/dist/runtime/api.js\")(false);\n// Module\nexports.push([module.i, \"* {\\n padding: 0;\\n margin: 0; }\\n\\na {\\n text-decoration: none;\\n color: inherit; }\\n\\nbody {\\n background-color: #f0f0f0; }\\n\\n.form__logo {\\n width: 110px;\\n padding-top: 50px;\\n display: block;\\n margin: auto;\\n position: relative;\\n top: 20%;\\n transform: translate(0%, -40.9%); }\\n\\n.form__brand {\\n padding: 10px 0;\\n text-align: center;\\n position: relative;\\n top: 20%;\\n transform: translate(0%, -90.9%); }\\n\\n.form-container {\\n max-width: 40%;\\n min-width: 20%;\\n position: absolute;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -49.9%);\\n box-sizing: border-box;\\n margin: auto;\\n padding: 20px 0; }\\n\\n.form__box {\\n border: 1px solid #eaecef;\\n border: 1px solid black;\\n background-color: #f6f8fa;\\n border-radius: 5px;\\n padding: 20px 0; }\\n\\n.form__in-group {\\n display: block;\\n position: relative;\\n margin: auto;\\n max-width: 80%;\\n padding: 10px 0px;\\n box-sizing: content-box;\\n align-items: center;\\n align-content: center; }\\n\\n.form__in-field {\\n display: block;\\n box-sizing: border-box;\\n margin: 10px 0;\\n padding: 10px 0;\\n width: 100%; }\\n\\n.form__in-field--warn {\\n border: solid 1px red; }\\n\\n.form__in-field--success {\\n border: solid 1px #2ea44f; }\\n\\n.form__pw-recovery {\\n text-decoration: none;\\n color: #0366d6;\\n font-size: 0.8rem; }\\n\\n.form__submit-button {\\n display: block;\\n border: 1px solid skyblue;\\n background: #800080;\\n color: rgba(255, 255, 255, 0.87);\\n height: 40px;\\n border-radius: 5px;\\n width: 80%;\\n margin: auto; }\\n\\n.form__secondary-action {\\n display: block;\\n margin-top: 10px; }\\n\\n.form__secondary-action__banner {\\n display: block;\\n margin: auto;\\n max-width: 80%;\\n text-align: center; }\\n\\n.form__secondary-action__link {\\n text-decoration: none;\\n color: #0366d6; }\\n\", \"\"]);\n\n\n\n//# sourceURL=webpack:///./templates/auth/forms.scss?./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js"); - -/***/ }), - -/***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./templates/panel/main.scss": -/*!****************************************************************************************************************!*\ - !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./templates/panel/main.scss ***! - \****************************************************************************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/api.js */ \"./node_modules/css-loader/dist/runtime/api.js\")(false);\n// Module\nexports.push([module.i, \"* {\\n padding: 0;\\n margin: 0; }\\n\\na {\\n text-decoration: none;\\n color: inherit; }\\n\\n* {\\n margin: 0;\\n padding: 0; }\\n\\na {\\n text-decoration: none; }\\n\\nli {\\n list-style: none; }\\n\\n.secondary-menu {\\n position: fixed;\\n width: 14%;\\n left: 0;\\n bottom: 0;\\n top: 0;\\n right: 0;\\n height: 100%;\\n overflow: auto;\\n background-color: #2b2c30;\\n color: rgba(255, 255, 255, 0.87); }\\n\\n.secondary-menu__heading {\\n margin: auto;\\n padding: 20px 5px;\\n display: flex; }\\n\\n.secondary-menu__heading:hover {\\n color: #5cad66;\\n cursor: grab; }\\n\\n.secondary-menu__logo {\\n width: 70px;\\n display: inline-block; }\\n\\n.secondary-menu__brand-name {\\n display: inline-block;\\n margin: auto;\\n font-size: 1.5rem; }\\n\\n.secondary-menu__item {\\n margin: auto;\\n padding: 20px 25px;\\n display: flex; }\\n\\n.secondary-menu__icon {\\n filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(93deg) brightness(103%) contrast(103%);\\n opacity: 0.8;\\n width: 1rem;\\n margin: auto;\\n margin-right: 10px; }\\n\\n.secondary-menu__item-name {\\n display: inline-block;\\n margin: auto;\\n font-size: 1rem; }\\n\\n/*\\n .secondary-menu__section-partition {\\n border-bottom: 1px solid var(--light-text);\\n margin: auto;\\n max-width: 70%;\\n list-style: none;\\n margin: 20px;\\n }\\n */\\n.secondary-menu__item-link:hover {\\n color: #5cad66;\\n cursor: grab;\\n filter: invert(58%) sepia(60%) saturate(331%) hue-rotate(76deg) brightness(91%) contrast(92%); }\\n\\n.secondary-menu__item-link {\\n color: inherit;\\n width: 100%;\\n height: 100%; }\\n\\nmain {\\n position: fixed;\\n top: 0;\\n right: 0;\\n left: 14%;\\n bottom: 0;\\n background-color: #f0f0f0; }\\n\\n.task-bar {\\n display: flex;\\n padding: 0px;\\n margin: 0px;\\n background-color: #fff; }\\n\\n.task-bar__action {\\n display: inline-block;\\n padding: 10px 0px;\\n margin: auto; }\\n\\n.task-bar__spacer {\\n min-width: 250px;\\n flex: 6; }\\n\\n.task-bar__icon {\\n opacity: 0.8;\\n width: 1.5rem;\\n margin: auto 20px; }\\n\\n.task-bar__icon {\\n color: rgba(255, 255, 255, 0.87); }\\n\\n.task-bar__icon:hover {\\n cursor: grab; }\\n\\n.main-menu {\\n display: flex;\\n flex-grow: 0;\\n padding-top: 20px;\\n padding-left: 10px; }\\n\\n.main-menu__item {\\n list-style: none;\\n background-color: #c3c3c3;\\n flex: 2;\\n text-align: center;\\n vertical-align: middle;\\n margin: auto 20px;\\n padding: 10px 0; }\\n\\n.main-menu__item--spacer {\\n list-style: none;\\n flex: 3;\\n text-align: center; }\\n\\n.main-menu__item:hover {\\n background-color: grey;\\n cursor: grab; }\\n\\n.main-menu__item:last-child {\\n padding: 0;\\n display: flex;\\n flex: 2;\\n border: none;\\n background-color: unset; }\\n\\n.main-menu__item:last-child:hover {\\n cursor: unset;\\n background-color: unset; }\\n\\n.main-menu__add-site {\\n display: inline-block;\\n background-color: #800080;\\n color: white;\\n font-weight: 500;\\n font-size: 16px;\\n padding: 10px 15px;\\n border-radius: 5px;\\n border: 1px grey solid;\\n min-height: 45px;\\n margin: auto; }\\n\\n.main-menu__add-site:hover {\\n background-color: #800080;\\n cursor: grab;\\n transform: translateY(-5px); }\\n\\n.help-text {\\n border-radius: 4px;\\n box-shadow: #2b2c30 0px 2px 6px 0px;\\n min-width: 70%;\\n max-width: 80%;\\n min-height: 70px;\\n display: flex;\\n margin-left: 15px;\\n margin-top: 40px; }\\n\\n.help-text__serial-num {\\n display: inline-flex;\\n background-color: #800080;\\n color: rgba(255, 255, 255, 0.87);\\n width: 30px;\\n height: 30px;\\n border-radius: 50%;\\n align-items: center;\\n justify-content: center; }\\n\\n.help-text__instructions {\\n display: inline-block;\\n list-style: none;\\n font-size: 19px;\\n font-weight: 500;\\n padding: 10px;\\n margin: auto; }\\n\\n.inner-container {\\n display: flex;\\n box-sizing: border-box;\\n max-width: 50%;\\n margin: 50px auto;\\n border-radius: 5px;\\n display: flex; }\\n\\n.sitekey-form {\\n display: flex;\\n flex-direction: column;\\n width: 90%;\\n justify-content: center;\\n align-items: center;\\n box-sizing: content-box;\\n background-color: #fff;\\n margin: auto;\\n padding-bottom: 30px; }\\n\\n.sitekey-form__title-flex-container {\\n display: flex;\\n width: 100%;\\n border-bottom: 0.1px solid rgba(0, 0, 0, 0.125); }\\n\\n.sitekey-form__title {\\n padding-left: 10px;\\n font-size: 1rem;\\n padding: 0.75rem 1.25rem; }\\n\\n.sitekey-form__label {\\n display: block;\\n margin: 10px 0;\\n box-sizing: inherit;\\n justify-self: left; }\\n\\n.sitekey-form__input {\\n position: relative;\\n margin-top: 5px;\\n box-sizing: border-box;\\n height: 40px;\\n width: 90%; }\\n\\n.sitekey-form__input--add-level {\\n position: relative;\\n margin-top: 5px;\\n box-sizing: inherit;\\n flex: 3;\\n height: 40px;\\n margin-right: 20px; }\\n\\n.sitekey-form__add-level-flex-container {\\n display: flex;\\n box-sizing: border-box;\\n width: 90%;\\n margin-top: 10px; }\\n\\n.sitekey-form__add-level-spacer {\\n flex: 3; }\\n\\n.sitekey-form__add-level {\\n background-color: #800080;\\n color: white;\\n padding: 5px;\\n font-size: 16px;\\n border-radius: 5px;\\n border: 1px rgba(0, 0, 0, 0.125) solid;\\n height: 40px;\\n min-width: 125px;\\n margin: auto; }\\n\\n.sitekey-form__submit {\\n margin-top: 50px;\\n display: block;\\n background-color: #800080;\\n color: white;\\n padding: 5px;\\n font-size: 20px;\\n border-radius: 5px;\\n border: 1px rgba(0, 0, 0, 0.125) solid;\\n min-height: 45px;\\n width: 125px;\\n width: 90%; }\\n\", \"\"]);\n\n\n\n//# sourceURL=webpack:///./templates/panel/main.scss?./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js"); - -/***/ }), - -/***/ "./node_modules/css-loader/dist/runtime/api.js": -/*!*****************************************************!*\ - !*** ./node_modules/css-loader/dist/runtime/api.js ***! - \*****************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function (useSourceMap) {\n var list = []; // return the list of modules as css string\n\n list.toString = function toString() {\n return this.map(function (item) {\n var content = cssWithMappingToString(item, useSourceMap);\n\n if (item[2]) {\n return '@media ' + item[2] + '{' + content + '}';\n } else {\n return content;\n }\n }).join('');\n }; // import a list of modules into the list\n\n\n list.i = function (modules, mediaQuery) {\n if (typeof modules === 'string') {\n modules = [[null, modules, '']];\n }\n\n var alreadyImportedModules = {};\n\n for (var i = 0; i < this.length; i++) {\n var id = this[i][0];\n\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n\n for (i = 0; i < modules.length; i++) {\n var item = modules[i]; // skip already imported module\n // this implementation is not 100% perfect for weird media query combinations\n // when a module is imported multiple times with different media queries.\n // I hope this will never occur (Hey this way we have smaller bundles)\n\n if (item[0] == null || !alreadyImportedModules[item[0]]) {\n if (mediaQuery && !item[2]) {\n item[2] = mediaQuery;\n } else if (mediaQuery) {\n item[2] = '(' + item[2] + ') and (' + mediaQuery + ')';\n }\n\n list.push(item);\n }\n }\n };\n\n return list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n var content = item[1] || '';\n var cssMapping = item[3];\n\n if (!cssMapping) {\n return content;\n }\n\n if (useSourceMap && typeof btoa === 'function') {\n var sourceMapping = toComment(cssMapping);\n var sourceURLs = cssMapping.sources.map(function (source) {\n return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';\n });\n return [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n }\n\n return [content].join('\\n');\n} // Adapted from convert-source-map (MIT)\n\n\nfunction toComment(sourceMap) {\n // eslint-disable-next-line no-undef\n var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n return '/*# ' + data + ' */';\n}\n\n//# sourceURL=webpack:///./node_modules/css-loader/dist/runtime/api.js?"); - -/***/ }), - -/***/ "./node_modules/style-loader/lib/addStyles.js": -/*!****************************************************!*\ - !*** ./node_modules/style-loader/lib/addStyles.js ***! - \****************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getTarget = function (target, parent) {\n if (parent){\n return parent.querySelector(target);\n }\n return document.querySelector(target);\n};\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(target, parent) {\n // If passing function in options, then use it for resolve \"head\" element.\n // Useful for Shadow Root style i.e\n // {\n // insertInto: function () { return document.querySelector(\"#foo\").shadowRoot }\n // }\n if (typeof target === 'function') {\n return target();\n }\n if (typeof memo[target] === \"undefined\") {\n\t\t\tvar styleTarget = getTarget.call(this, target, parent);\n\t\t\t// Special case to return head of iframe instead of iframe itself\n\t\t\tif (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n\t\t\t\ttry {\n\t\t\t\t\t// This will throw an exception if access to iframe is blocked\n\t\t\t\t\t// due to cross-origin restrictions\n\t\t\t\t\tstyleTarget = styleTarget.contentDocument.head;\n\t\t\t\t} catch(e) {\n\t\t\t\t\tstyleTarget = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemo[target] = styleTarget;\n\t\t}\n\t\treturn memo[target]\n\t};\n})();\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(/*! ./urls */ \"./node_modules/style-loader/lib/urls.js\");\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of