Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_owner condition for custom action #270

Open
morrisson opened this issue Jul 21, 2016 · 5 comments
Open

is_owner condition for custom action #270

morrisson opened this issue Jul 21, 2016 · 5 comments
Labels

Comments

@morrisson
Copy link
Contributor

If developers want to restrict using action for some resources to those owner, developers want to write is_owner condition for this custom action policy. However, currently it does not work. This is because owner is checked in GET/PUT/POST/DELETE action by adding tenant_id to (pre)fetch some resource, but there is no this kind of logic in ActionResource.

@morrisson morrisson added the bug label Jul 21, 2016
@marcin-ptaszynski
Copy link
Contributor

In order to enforce this policy, we'd need to prefetch the subject resource. What do you think about it, @nati?

@nati
Copy link
Contributor

nati commented Jul 21, 2016

I think we should prefetch resource and apply policy for also action.
But this could be backward incompatible change, so I wanna know how side effect this for existing projects.

@morrisson
Copy link
Contributor Author

Thanks. Ok, prefetch resource is a good option.

As far as I can think of, side effect is that, for example, admin action to some users' resource might be prohibited without modifying policy condition to allow tenant_id: <admin_tenant_id> access.

@morrisson
Copy link
Contributor Author

I think we can check by policy.Check same as checking 'create' policy (line 407-411 in resource_management.go)

//Apply policy for api input
err = policy.Check(schema.ActionCreate, auth, dataMap)
if err != nil {
    return ResourceError{err, err.Error(), Unauthorized}
}

Is there a reason that we should use prefetching?

@nati
Copy link
Contributor

nati commented Jul 22, 2016

It is because any action may performed after we crated a resource, and parameters for action won't have a resource information except ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants