Make permission checking more generic