memoize ensure_privilige function

There are multiple calls verifying same permissions again.
the cache values here will be stored in global memory and thus will never be removed or garbage collected, because of how memoized works, so this approach isn't the best. A version of memoized that evicts would be ideal, or one that stores the cache on the request object, but for now you'd have to do that explicitly.