Closes #116 Signed-off-by: Jon Koops <jonkoops@gmail.com> Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
2c069433f9
commit
cbc4a8c305
1 changed files with 8 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
}
|
||||
|
||||
let init;
|
||||
let preventAdditionalRequests = false;
|
||||
|
||||
async function checkState(clientId, origin, sessionState) {
|
||||
// Check if the browser has granted us access to 3rd-party storage (such as cookies).
|
||||
|
@ -41,6 +42,13 @@
|
|||
|
||||
// If not initialized, verify this client is allowed access with a call to the server.
|
||||
if (!init) {
|
||||
// Prevent additional requests to the server to avoid potential DoS attacks.
|
||||
if (preventAdditionalRequests) {
|
||||
return "error";
|
||||
} else {
|
||||
preventAdditionalRequests = true;
|
||||
}
|
||||
|
||||
const url = new URL(`${location.origin}${location.pathname}/init`);
|
||||
|
||||
url.searchParams.set("client_id", clientId);
|
||||
|
|
Loading…
Reference in a new issue