Enhancement for Permission Inheritance of Resource

I enhanced the isAllowed and middleware to support permission inheritance. Please check the new test cases for usage.