Refactor permission provider to be more flexible