Check whether the service is authorized to access the resource

        :param requested_access: "r", "w", or "rw"
        :param resource: a Resource or SubResource with "permissions" attribute
        :returns: True if has access, False otherwise

def authorized(self, requested_access, resource):
        """
        Check whether the service is authorized to access the resource

        :param requested_access: "r", "w", or "rw"
        :param resource: a Resource or SubResource with "permissions" attribute
        :returns: True if has access, False otherwise
        """
        if {self.state, resource.state} != {State.approved}:
            return False

        permissions = group_permissions(getattr(resource, 'permissions', []))

        org_permissions = permissions['organisation_id'][self.organisation_id]
        type_permissions = permissions['service_type'][self.service_type]
        all_permissions = permissions['all']

        for permission_set in [org_permissions, type_permissions, all_permissions]:
            if '-' in permission_set:
                return False
            elif set([x for x in requested_access]).issubset(permission_set):
                return True

        return False