Added permissions backend and refactored couchbase client code