Greetings from a chilly Guildford,
We are happy to announce a new WebVM SDK feature release, which includes support
for permission checks. The webvm.h version has been increased to 0.3 due to the
fact that the checkPermission call has changed and that a couple of new types
have been introduced.
The simple example has been updated to provide an initial idea for permission checks in the get42 function:
static WVMStatus get42(WVM *instance, WVMObjectReference ref, WVMVariant *vArgs, WVMVariant *vResultArgs) {
static WVMPermissionQuery permQuery = { "device:test.prompt", NULL };
static WVMError permDenied = { "Error", "Permission denied.", NULL };
WVMDecision decision;
wvcf->checkPermission(instance, &permQuery, &decision);
if(decision == DecisionPermit) {
vResultArgs->value.intValue = 42;
return OK;
}
else {
vResultArgs->type = AtxError;
vResultArgs->value.errValue = &permDenied;
return Error_Native;
}
}
The default WebVM policy.conf file, which contains the permission check rules, has been extended with the following test rules used by the simple example:
grant "device:test.grant"
prompt "device:test.prompt"
deny "device:test.deny"
Querying for device:test.grant should return DecisionPermit. Whereas
querying for device:test.prompt will prompt the user (like in the get42
example) and either return with DecisionPermit or DecisionDeny. Querying
for device.test:deny will return with DecisionDeny.
We will describe the permission API in more detail in the tutorial next week.
You can re-use your WebVM SDK download URL from your mail inbox or re-register at sdk.webvm.net.