Refacto on all CNXID replacements in myaccess & consequences

This commit is contained in:
STEINNI
2026-06-26 18:42:59 +00:00
parent 155692f71d
commit a868caf8c9
4 changed files with 37 additions and 22 deletions
+11 -7
View File
@@ -21,7 +21,8 @@ export const methods = {
for(var chan of payload){
if((!chan) || (typeof(chan)!='string')) continue
chan = chan.replace(/\[UID\]/g, this.userId)
if(!this.accessRights.canSubscribe(this.userId, this.roles, chan)) {
chan = chan.replace(/\[CNXID\]/g, this.uuid)
if(!this.accessRights.canSubscribe(this.userId, this.roles, chan, this.uuid)) {
if(this.debug) console.log('SUB: No rights to this chan!', this.userId, this.roles, chan)
continue
}
@@ -73,8 +74,9 @@ export const methods = {
let unSubscribed = []
for(var chan of payload){
if((!chan) || (typeof(chan)!='string')) continue
chan = chan.replace(/\[UID\]/g, this.userId)
if(this.accessRights.isMandatory(this.userId, this.roles, chan)) continue
chan = chan.replace(/\[UID\]/g, this.userId)
chan = chan.replace(/\[CNXID\]/g, this.uuid)
if(this.accessRights.isMandatory(this.userId, this.roles, chan, this.uuid)) continue
let couldUnsubscribe = false
for(const rediscnx of this.allRediscnx){
@@ -148,7 +150,7 @@ export const methods = {
return;
};
if( (!this.accessRights.canPublish(this.userId, this.roles, payload.chan)) ) {
if( (!this.accessRights.canPublish(this.userId, this.roles, payload.chan, this.uuid)) ) {
this.sendErr(action, 'Unauthorized chan !', reqid);
if(this.debug) console.log('PUB: Unauthorized chan', payload.chan, this.userId, this.roles)
return
@@ -228,15 +230,17 @@ export const methods = {
return
}
if( (!this.accessRights.canSubscribe(this.userId, this.roles, payload.channel)) ) {
payload.channel = payload.channel.replace(/\[UID\]/g, this.userId)
.replace(/\[CNXID\]/g, this.uuid)
if( (!this.accessRights.canSubscribe(this.userId, this.roles, payload.channel, this.uuid)) ) {
this.sendErr(action, 'CHANHIST: Unauthorized channel !', reqid)
return
}
const primaryRediscnx = this.allRediscnx.find(cnx => ((chan.startsWith(cnx.redisConfig.chansNamespace)) &&(cnx.redisConfig.role=='primary')) )
const primaryRediscnx = this.allRediscnx.find(cnx => ((payload.channel.startsWith(cnx.redisConfig.chansNamespace)) &&(cnx.redisConfig.role=='primary')) )
if(!primaryRediscnx){
this.sendErr(action, 'No primary redis for this chan !', reqid);
if(this.debug) console.log('CHANHIST: No primary redis for this chan ', chan)
if(this.debug) console.log('CHANHIST: No primary redis for this chan ', payload.channel)
return
}
+2 -2
View File
@@ -30,7 +30,7 @@ export const methods = {
return
}
if(!this.accessRights.canSet(this.userId, this.roles, payload.key)){
if(!this.accessRights.canSet(this.userId, this.roles, payload.key, this.uuid)){
this.sendErr(action, 'Unauthorized key !', reqid);
return
}
@@ -92,7 +92,7 @@ export const methods = {
return;
};
if(!this.accessRights.canGet(this.userId, this.roles, payload.key)) {
if(!this.accessRights.canGet(this.userId, this.roles, payload.key, this.uuid)) {
console.log('Unauth GET key:',this.userId, this.roles, payload.key)
this.sendErr(action, 'Unauthorized key !', reqid);
return