[bug] Do not request keys when we are not in the role in decryptAttribute
This commit is contained in:
parent
bb5d3ff16d
commit
6076c342f8
@ -1049,9 +1049,26 @@ export default class Services {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let key = state.keys[attribute];
|
let key = state.keys[attribute];
|
||||||
|
const pairingProcessId = this.getPairingProcessId();
|
||||||
|
|
||||||
// If key is missing, request an update and then retry
|
// If key is missing, request an update and then retry
|
||||||
if (!key) {
|
if (!key) {
|
||||||
|
const roles = state.roles;
|
||||||
|
let hasAccess = false;
|
||||||
|
// If we're not supposed to have access to this attribute, ignore
|
||||||
|
for (const role of Object.values(roles)) {
|
||||||
|
if (role.validation_rules.includes(attribute)) {
|
||||||
|
if (role.members.includes(pairingProcessId)) {
|
||||||
|
// We have access to this attribute
|
||||||
|
hasAccess = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasAccess) return null;
|
||||||
|
|
||||||
|
// We should have the key, so we're going to ask other members for it
|
||||||
await this.requestDataFromPeers(processId, [state.state_id], [state.roles]);
|
await this.requestDataFromPeers(processId, [state.state_id], [state.roles]);
|
||||||
|
|
||||||
const maxRetries = 5;
|
const maxRetries = 5;
|
||||||
@ -1292,7 +1309,6 @@ export default class Services {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
||||||
const lastCommitedState = this.getLastCommitedState(process);
|
const lastCommitedState = this.getLastCommitedState(process);
|
||||||
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
||||||
@ -1358,7 +1374,6 @@ export default class Services {
|
|||||||
|
|
||||||
public async requestDataFromPeers(processId: string, stateIds: string[], roles: Record<string, RoleDefinition>[]) {
|
public async requestDataFromPeers(processId: string, stateIds: string[], roles: Record<string, RoleDefinition>[]) {
|
||||||
console.log('Requesting data from peers');
|
console.log('Requesting data from peers');
|
||||||
console.log(roles);
|
|
||||||
const membersList = this.getAllMembers();
|
const membersList = this.getAllMembers();
|
||||||
try {
|
try {
|
||||||
const res = this.sdkClient.request_data(processId, stateIds, roles, membersList);
|
const res = this.sdkClient.request_data(processId, stateIds, roles, membersList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user