From 0510c53bc44287d80bb7e92140c2fe4ffe8734bf Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 6 Jul 2024 19:20:14 -0400 Subject: [PATCH 1/5] add statefulApi middleware --- bootstrap/app.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bootstrap/app.php b/bootstrap/app.php index 8a46f47..80e6ca1 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,6 +14,9 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { + + $middleware->statefulApi(); + // $middleware->trustProxies(at: [ '0.0.0.0/0', From c06b8b85bf6c518b6d3ffdd3ac9e8f2e3b4d83e0 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 6 Jul 2024 19:20:23 -0400 Subject: [PATCH 2/5] add session auth guard --- routes/api.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/api.php b/routes/api.php index 58009d2..2aaf128 100644 --- a/routes/api.php +++ b/routes/api.php @@ -5,8 +5,8 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; -Route::post("/share", [CodeController::class, "Share" ]); -Route::post("/compile", [CodeController::class, "Compile" ]); +Route::post("/share", [CodeController::class, "Share" ])->middleware("auth.session"); +Route::post("/compile", [CodeController::class, "Compile" ])->middleware("auth.session"); Route::get("/health-check", [CodeController::class, "HealthCheck" ]); Route::get("/news", function(Request $request) @@ -60,7 +60,7 @@ } return $changeLog; -}); +})->middleware("auth.session"); -Route::get("/supporters", [PatreonController::class, "get_supporters" ]); +Route::get("/supporters", [PatreonController::class, "get_supporters" ])->middleware("auth.session"); Route::post("/update-supporters", [PatreonController::class, "update" ]); From 63f6868a25fb616c88be0b0dfd2ce92cd0a4fc4b Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 6 Jul 2024 19:21:39 -0400 Subject: [PATCH 3/5] formatting --- resources/js/app.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/js/app.ts b/resources/js/app.ts index 3fed0dd..c9caecb 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -225,7 +225,7 @@ export default class PGEtinker if(!this.preCompile()) return; - + axios.post("/api/share", { code: this.editorPanel.getValue() }).then((response) => @@ -265,7 +265,7 @@ export default class PGEtinker } this.compileFailHandler("pgetinker.cpp:1:1: error: compilation failed in a way that's not being handled. please make a bug report.\n"); - }); + }); } async switchToDefaultLayout() @@ -345,7 +345,6 @@ export default class PGEtinker reject(); }); }); - } compileSuccessHandler(data: any) From 8691f91b33fc9e51dd4275484e53397ae4ea1c8c Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sun, 7 Jul 2024 03:56:48 -0400 Subject: [PATCH 4/5] use cookies for auth --- resources/js/lib/monacoConfig.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/resources/js/lib/monacoConfig.js b/resources/js/lib/monacoConfig.js index 7dcc441..f14a73b 100644 --- a/resources/js/lib/monacoConfig.js +++ b/resources/js/lib/monacoConfig.js @@ -12,7 +12,6 @@ import { getStorageValue, setStorageValue } from './storage'; export const getUserConfiguration = () => { - return JSON.stringify({ "workbench.colorTheme": (getStorageValue("theme") == "dark") ? "Default Dark Modern" : "Default Light Modern", "editor.mouseWheelZoom": "on", @@ -29,7 +28,7 @@ export const createUserConfig = (workspaceRoot, code, codeUri) => { let secured = (window.location.protocol.indexOf("https") === 0); let staging = (window.location.pathname.indexOf("/staging/") == 0); - + return { languageClientConfig: { languageId: 'cpp', @@ -39,9 +38,6 @@ export const createUserConfig = (workspaceRoot, code, codeUri) => host: window.location.host, port: secured ? 443 : 80, path: staging ? "staging/clangd" : "clangd", - extraParams: { - authorization: 'UserAuth' - }, secured: secured, startOptions: { onCall: (languageClient) => {}, From 222330d89e856eec371f40db1bf0714b0ada95d5 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sun, 7 Jul 2024 03:59:01 -0400 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd39d2f..b22cf08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,13 @@ All notable changes to this project will be documented in this file. Each batch of changes is marked by the date it was published to the repository for deployment to the PGEtinker site. It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history. -## 20204-07-05 + +## 20204-07-07 - Fixed bug involving shared code persistence - Changed threshold for responsive navbar +- Added session guard to compile and share API +- Added session guard on language client ## 2024-06-30