secure DISABLE_ANONYMOUS

This commit is contained in:
_Bastler
2021-10-21 16:23:42 +02:00
parent e3470d3474
commit f984897e80
13 changed files with 55 additions and 77 deletions
+12 -3
View File
@@ -44,13 +44,22 @@ class ConnectionManager {
//TODO fix me to redirect this URL by pusher
if (!this._currentRoom) {
console.error("cannot get currentRoom!");
loginSceneVisibleIframeStore.set(false);
return null;
}
const redirectUrl = `${PUSHER_URL}/login-screen?state=${state}&nonce=${nonce}&playUri=${this._currentRoom.key}`;
window.location.assign(redirectUrl);
// also allow OIDC login without admin API by using pusher
let redirectUrl : URL;
if (this._currentRoom.iframeAuthentication) {
redirectUrl = new URL(`${this._currentRoom.iframeAuthentication}`);
} else {
// need origin if PUSHER_URL is relative (in Single-Domain-Deployment)
redirectUrl = new URL(`${PUSHER_URL}/login-screen`, (!PUSHER_URL.startsWith('http:') || !PUSHER_URL.startsWith('https:')) ? window.location.origin : undefined);
}
redirectUrl.searchParams.append("state", state);
redirectUrl.searchParams.append("nonce", nonce);
redirectUrl.searchParams.append("playUri", this._currentRoom.key);
window.location.assign(redirectUrl.toString());
return redirectUrl;
}
+10 -13
View File
@@ -18,7 +18,7 @@ export class Room {
private _iframeAuthentication?: string;
private _mapUrl: string | undefined;
private _textures: CharacterTexture[] | undefined;
// private instance: string | undefined;
private instance: string | undefined;
private readonly _search: URLSearchParams;
private _contactPage: string | undefined;
private _group: string | null = null;
@@ -75,13 +75,12 @@ export class Room {
const baseUrl = new URL(currentRoomUrl);
const currentRoom = new Room(baseUrl);
// let instance: string = "global";
// if (currentRoom.isPublic) {
// instance = currentRoom.instance as string;
//}
let instance: string = "global";
if (currentRoom.isPublic) {
instance = currentRoom.instance as string;
}
// baseUrl.pathname = "/_/" + instance + "/" + absoluteExitSceneUrl.host + absoluteExitSceneUrl.pathname;
baseUrl.pathname = "/_/" + absoluteExitSceneUrl.host + absoluteExitSceneUrl.pathname;
baseUrl.pathname = "/_/" + instance + "/" + absoluteExitSceneUrl.host + absoluteExitSceneUrl.pathname;
if (absoluteExitSceneUrl.hash) {
baseUrl.hash = absoluteExitSceneUrl.hash;
}
@@ -119,8 +118,6 @@ export class Room {
* - In a private URL: [organizationId/worldId]
*/
public getInstance(): string {
return "";
/*
if (this.instance !== undefined) {
return this.instance;
}
@@ -131,12 +128,12 @@ export class Room {
this.instance = match[1];
return this.instance;
} else {
const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
if (!match) throw new Error('Could not extract instance from "' + this.id + '"');
this.instance = match[1] + "/" + match[2];
//const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
//if (!match) throw new Error('Could not extract instance from "' + this.id + '"');
//this.instance = match[1] + "/" + match[2];
this.instance = ""
return this.instance;
}
*/
}
public isDisconnected(): boolean {
+1 -1
View File
@@ -37,7 +37,7 @@ export class GameManager {
//If player name was not set show login scene with player name
//If Room si not public and Auth was not set, show login scene to authenticate user (OpenID - SSO - Anonymous)
if (!this.playerName || !localUserStore.getAuthToken()) {
if (!this.playerName || (this.startRoom.authenticationMandatory && !localUserStore.getAuthToken())) {
return LoginSceneName;
} else if (!this.characterLayers || !this.characterLayers.length) {
return SelectCharacterSceneName;
-11
View File
@@ -303,17 +303,12 @@ export class GameScene extends DirtyScene {
//remove loader in progress
removeLoader(this);
if (this.roomUrl == localUserStore.getLastRoomUrl()) {
localUserStore.setLastRoomUrl(null);
}
//display an error scene
this.scene.start(ErrorSceneName, {
title: "Network error",
subTitle: "An error occurred while loading resource:",
message: this.originalMapUrl ?? file.src,
});
return;
}
});
this.load.scenePlugin("AnimatedTiles", AnimatedTiles, "animatedTiles", "animatedTiles");
@@ -460,12 +455,6 @@ export class GameScene extends DirtyScene {
//initialise map
this.Map = this.add.tilemap(this.MapUrlFile);
const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf("/"));
if (!this.mapFile) {
localUserStore.setLastRoomUrl(null);
throw new Error("invalid map");
}
this.mapFile.tilesets.forEach((tileset: ITiledTileSet) => {
this.Terrains.push(
this.Map.addTilesetImage(
+3 -1
View File
@@ -23,7 +23,9 @@ export class LoginScene extends ResizableScene {
loginSceneVisibleIframeStore.set(false);
//If authentication is mandatory, push authentication iframe
if (
localUserStore.getAuthToken() == undefined
localUserStore.getAuthToken() == undefined &&
gameManager.currentStartedRoom &&
gameManager.currentStartedRoom.authenticationMandatory
) {
connectionManager.loadOpenIDScreen();
loginSceneVisibleIframeStore.set(true);
+1 -1
View File
@@ -38,7 +38,7 @@ class UrlManager {
}
public pushRoomIdToUrl(room: Room): void {
if (window.location.pathname === room.id || room.isPublic) return;
if (window.location.pathname === room.id) return;
//Set last room visited! (connected or nor, must to be saved in localstorage and cache API)
localUserStore.setLastRoomUrl(room.key);
const hash = window.location.hash;