Merge branch 'develop' of github.com:thecodingmachine/workadventure into feature-discussion

This commit is contained in:
David Négrier 2020-11-05 16:47:41 +01:00
commit 8960efca71
5 changed files with 57 additions and 46 deletions

View File

@ -137,7 +137,7 @@ jobs:
check_for_duplicate_msg: true check_for_duplicate_msg: true
- name: Run Cypress tests - name: Run Cypress tests
uses: cypress-io/github-action@v1 uses: cypress-io/github-action@v2
if: ${{ env.GITHUB_REF_SLUG != 'master' }} if: ${{ env.GITHUB_REF_SLUG != 'master' }}
env: env:
CYPRESS_BASE_URL: https://play.${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com CYPRESS_BASE_URL: https://play.${{ env.GITHUB_REF_SLUG }}.workadventure.test.thecodingmachine.com
@ -148,7 +148,7 @@ jobs:
working-directory: e2e working-directory: e2e
- name: Run Cypress tests in prod - name: Run Cypress tests in prod
uses: cypress-io/github-action@v1 uses: cypress-io/github-action@v2
if: ${{ env.GITHUB_REF_SLUG == 'master' }} if: ${{ env.GITHUB_REF_SLUG == 'master' }}
env: env:
CYPRESS_BASE_URL: https://play.workadventu.re CYPRESS_BASE_URL: https://play.workadventu.re

View File

@ -22,7 +22,7 @@ import {adminApi, CharacterTexture, FetchMemberDataByUuidResponse} from "../Serv
import {SocketManager, socketManager} from "../Services/SocketManager"; import {SocketManager, socketManager} from "../Services/SocketManager";
import {emitInBatch, resetPing} from "../Services/IoSocketHelpers"; import {emitInBatch, resetPing} from "../Services/IoSocketHelpers";
import {clientEventsEmitter} from "../Services/ClientEventsEmitter"; import {clientEventsEmitter} from "../Services/ClientEventsEmitter";
import {ADMIN_API_TOKEN} from "../Enum/EnvironmentVariable"; import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable";
export class IoSocketController { export class IoSocketController {
private nextUserId: number = 1; private nextUserId: number = 1;
@ -166,6 +166,7 @@ export class IoSocketController {
if(room.isFull){ if(room.isFull){
throw new Error('Room is full'); throw new Error('Room is full');
} }
if (ADMIN_API_URL) {
try { try {
const userData = await adminApi.fetchMemberDataByUuid(userUuid); const userData = await adminApi.fetchMemberDataByUuid(userUuid);
//console.log('USERDATA', userData) //console.log('USERDATA', userData)
@ -177,8 +178,10 @@ export class IoSocketController {
//console.log('access granted for user '+userUuid+' and room '+roomId); //console.log('access granted for user '+userUuid+' and room '+roomId);
} catch (e) { } catch (e) {
console.log('access not granted for user '+userUuid+' and room '+roomId); console.log('access not granted for user '+userUuid+' and room '+roomId);
console.error(e);
throw new Error('Client cannot acces this ressource.') throw new Error('Client cannot acces this ressource.')
} }
}
// Generate characterLayers objects from characterLayers string[] // Generate characterLayers objects from characterLayers string[]
const characterLayerObjs: CharacterLayer[] = SocketManager.mergeCharacterLayersAndCustomTextures(characterLayers, memberTextures); const characterLayerObjs: CharacterLayer[] = SocketManager.mergeCharacterLayersAndCustomTextures(characterLayers, memberTextures);
@ -238,7 +241,8 @@ export class IoSocketController {
socketManager.handleJoinRoom(client); socketManager.handleJoinRoom(client);
resetPing(client); resetPing(client);
//get data information and shwo messages //get data information and show messages
if (ADMIN_API_URL) {
adminApi.fetchMemberDataByUuid(client.userUuid).then((res: FetchMemberDataByUuidResponse) => { adminApi.fetchMemberDataByUuid(client.userUuid).then((res: FetchMemberDataByUuidResponse) => {
if (!res.messages) { if (!res.messages) {
return; return;
@ -254,6 +258,7 @@ export class IoSocketController {
}).catch((err) => { }).catch((err) => {
console.error('fetchMemberDataByUuid => err', err); console.error('fetchMemberDataByUuid => err', err);
}); });
}
}, },
message: (ws, arrayBuffer, isBinary): void => { message: (ws, arrayBuffer, isBinary): void => {
const client = ws as ExSocketInterface; const client = ws as ExSocketInterface;

View File

@ -3,7 +3,7 @@ const URL_ROOM_STARTED = "/Floor0/floor0.json";
const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64; const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64;
const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48; const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48;
const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false;
const ADMIN_API_URL = process.env.ADMIN_API_URL || 'http://admin'; const ADMIN_API_URL = process.env.ADMIN_API_URL || '';
const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || 'myapitoken'; const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || 'myapitoken';
const MAX_USERS_PER_ROOM = parseInt(process.env.MAX_USERS_PER_ROOM || '') || 600; const MAX_USERS_PER_ROOM = parseInt(process.env.MAX_USERS_PER_ROOM || '') || 600;
const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80; const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80;

View File

@ -1,4 +1,4 @@
import {ALLOW_ARTILLERY, SECRET_KEY} from "../Enum/EnvironmentVariable"; import {ADMIN_API_URL, ALLOW_ARTILLERY, SECRET_KEY} from "../Enum/EnvironmentVariable";
import {uuid} from "uuidv4"; import {uuid} from "uuidv4";
import Jwt from "jsonwebtoken"; import Jwt from "jsonwebtoken";
import {TokenInterface} from "../Controller/AuthenticateController"; import {TokenInterface} from "../Controller/AuthenticateController";
@ -48,6 +48,7 @@ class JWTTokenManager {
return; return;
} }
if (ADMIN_API_URL) {
//verify user in admin //verify user in admin
adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => { adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => {
resolve(tokenInterface.userUuid); resolve(tokenInterface.userUuid);
@ -57,8 +58,11 @@ class JWTTokenManager {
resolve(tokenInterface.userUuid); resolve(tokenInterface.userUuid);
return; return;
} }
reject(new Error('Authentication error, invalid token structure. ' + err)); reject(err);
}); });
} else {
resolve(tokenInterface.userUuid);
}
}); });
}); });
} }

View File

@ -3,6 +3,7 @@
local namespace = env.GITHUB_REF_SLUG, local namespace = env.GITHUB_REF_SLUG,
local tag = namespace, local tag = namespace,
local url = if namespace == "master" then "workadventu.re" else namespace+".workadventure.test.thecodingmachine.com", local url = if namespace == "master" then "workadventu.re" else namespace+".workadventure.test.thecodingmachine.com",
local adminUrl = if namespace == "master" || namespace == "develop" || std.startsWith(namespace, "admin") then "https://admin."+url else null,
"$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json", "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json",
"version": "1.0", "version": "1.0",
"containers": { "containers": {
@ -16,11 +17,12 @@
"env": { "env": {
"SECRET_KEY": "tempSecretKeyNeedsToChange", "SECRET_KEY": "tempSecretKeyNeedsToChange",
"ADMIN_API_TOKEN": env.ADMIN_API_TOKEN, "ADMIN_API_TOKEN": env.ADMIN_API_TOKEN,
"ADMIN_API_URL": "https://admin."+url,
"JITSI_ISS": env.JITSI_ISS, "JITSI_ISS": env.JITSI_ISS,
"JITSI_URL": env.JITSI_URL, "JITSI_URL": env.JITSI_URL,
"SECRET_JITSI_KEY": env.SECRET_JITSI_KEY, "SECRET_JITSI_KEY": env.SECRET_JITSI_KEY,
} } + if adminUrl != null then {
"ADMIN_API_URL": adminUrl,
} else {}
}, },
"front": { "front": {
"image": "thecodingmachine/workadventure-front:"+tag, "image": "thecodingmachine/workadventure-front:"+tag,