add ensurePermission into server lib