Skip to content

Commit

Permalink
Merge pull request #118 from Moros1138/give-api-a-rudimentary-session…
Browse files Browse the repository at this point in the history
…-guard

Give api a rudimentary session guard
  • Loading branch information
Moros1138 committed Jul 7, 2024
2 parents cd54350 + 222330d commit f4c8f92
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {

$middleware->statefulApi();

//
$middleware->trustProxies(at: [
'0.0.0.0/0',
Expand Down
5 changes: 2 additions & 3 deletions resources/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export default class PGEtinker

if(!this.preCompile())
return;

axios.post("/api/share", {
code: this.editorPanel.getValue()
}).then((response) =>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -345,7 +345,6 @@ export default class PGEtinker
reject();
});
});

}

compileSuccessHandler(data: any)
Expand Down
6 changes: 1 addition & 5 deletions resources/js/lib/monacoConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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',
Expand All @@ -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) => {},
Expand Down
8 changes: 4 additions & 4 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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" ]);

0 comments on commit f4c8f92

Please sign in to comment.