Im working on a concept where users can allow certain organisations to see their data. I want to store the permission on a private ethereum blockchain. I thought smart contracts would be the way to go but I can't really wrap my head around it.
Would I need te create a contract for each user in which they say which organisations should get acces to their data?
Can users change which organisations have acces to their data if I use contracts, say for instance the user wants to change to another organisation?
Can I add more organisations to already existing contracts?
If contracts aren't the way to go here, could somebody give me a point in the right direction?
Image of the intended flow (simplified top more in depth bottom):
EDIT:
I made a start on a contract probably incorrect but lets see it as pseudo code:
pragma solidity >=0.5.0;
contract UserPermissions {
string private notpermitted;
mapping(address => mapping(bytes32 => mapping(address => bool))) permissions;
constructor() public {
notpermitted = "You do not have permission to view this users data";
}
function setPermissions(address they, bytes topic, bool allowed) external {
permissions[msg.sender][topic][they] = allowed;
}
function getPermitted(address they, bytes topic){
if (permissions[they][topic][msg.sender] = true) {
//if permission is granted return this
return permissions[they][topic][msg.sender];
} else {
return notpermitted;
};
}
function getOwnPermitted(){
//returns list of all permissions this acount has granted
}
}