roles into wsscnx from sess
This commit is contained in:
+10
-34
@@ -5,17 +5,16 @@ export class WssConnexion {
|
||||
|
||||
constructor(options){
|
||||
Object.assign(this, gatewayActions)
|
||||
|
||||
this.config = options.config;
|
||||
this.socket = options.socket;
|
||||
this.req = options.req;
|
||||
this.uuid = options.uuid;
|
||||
this.wssSrv = options.wssSrv;
|
||||
this.debug = options.debug;
|
||||
this.rediscnx = options.rediscnx;
|
||||
this.roles = []
|
||||
this.accessRights = options.accessRights;
|
||||
this.userId = '';
|
||||
this.config = options.config
|
||||
this.socket = options.socket
|
||||
this.req = options.req
|
||||
this.uuid = options.uuid
|
||||
this.wssSrv = options.wssSrv
|
||||
this.debug = options.debug
|
||||
this.rediscnx = options.rediscnx
|
||||
this.accessRights = options.accessRights
|
||||
this.userId = options.userId
|
||||
this.roles = options.roles
|
||||
this.sessionID = null // null until login
|
||||
|
||||
this.subscriptions = [];
|
||||
@@ -36,29 +35,6 @@ export class WssConnexion {
|
||||
if(this.debug) console.log(`Welcome to UUID ${this.uuid}`)
|
||||
}
|
||||
|
||||
async checkLogin(userInfo, otp){
|
||||
if(!this.config.server.devotpToken){
|
||||
let rawPayload = await this.rediscnx.redisGet(userInfo, this.config.redis.authTokenPrefix)
|
||||
let payload = JSON.parse(rawPayload)
|
||||
if(this.debug) console.log(`Got a token from Redis for ${userInfo} => ${JSON.stringify(payload)}`)
|
||||
if((!payload) || (!payload.token) || (!payload.roles)) return(false) // Redis/sessions issues : don't crash the daemon !
|
||||
this.token = payload.token
|
||||
this.roles = payload.roles
|
||||
this.sessionID = payload.sessionID || '!!no sessionID in the token key in Redis!!'
|
||||
} else {
|
||||
this.token = this.config.server.devotpToken
|
||||
this.roles = ['EIC_Dev']
|
||||
this.sessionID = this.config.server.devotpToken
|
||||
}
|
||||
|
||||
let data = new TextEncoder().encode(this.token+this.challenge)
|
||||
let bytesBuf = await crypto.subtle.digest("SHA-512", data)
|
||||
let arrayBuf = Array.from(new Uint8Array(bytesBuf))
|
||||
let goodOTP = arrayBuf.map((b) => b.toString(16).padStart(2, "0")).join("")
|
||||
if(this.debug) console.log(`Checking challenge-response (token=${this.token}): ${otp} ?? ${goodOTP}`)
|
||||
return(otp == goodOTP)
|
||||
}
|
||||
|
||||
startKeepAlive() {
|
||||
if(this.config.server.keepAliveInterval>0) {
|
||||
if(this.config.server.keepAliveInterval >= (1.5*this.config.server.keepAliveTimeout)) {
|
||||
|
||||
Reference in New Issue
Block a user