Add permissions methods to API

This adds /permissions and /permissions/PERMNAME to the API, allowing
retrieval of all permissions and all groups and users that have a given
permission.

This also updates the users and groups API methods to return permissions
with distance/path information. This allows consumers to know more about
the state of permissions.