oasis-rs icon indicating copy to clipboard operation
oasis-rs copied to clipboard

Mechanism for permissioning methods as #[owner_only] and transitioning owner

Open nhynes opened this issue 6 years ago • 2 comments

#[service]
struct MyService;

impl MyService {
    #[owner_only]
	fn owner_only(&self, _ctx: &Context) -> Result<u32> {
        Ok(42)
    }

	fn explicit_owner_only(&self, ctx: &Context) -> Result<u32> {
        if ctx.sender() != self._owner { // `self._owner` is auto-added
            return Err(format_err!("Permission denied"));
        }
        Ok(42)
    }
}

nhynes avatar May 07 '19 15:05 nhynes

It's probably worth differentiating mix-in libraries that can be added to services from the core runtime standard library

willscott avatar May 07 '19 15:05 willscott

👍

#[service(plugins = [acl, some_crate::some_plugin])]
struct MyService;

// or maybe 
#[service]
#[plugin(acl)]
#[plugin(some_crate::some_plugin)]
struct MyService;

nhynes avatar May 07 '19 16:05 nhynes