Beispiel #1
0
    def can_edit(self, raise_exception):
        """是否编辑权限
        """
        return True

        action_id = 'edit'
        can = self.had_perm(action_id)

        msg = self.get_msg(action_id)

        if can is False and raise_exception is True:
            raise NoAuthPermError(msg, self.get_err_data(action_id))
        return can
Beispiel #2
0
    def can_view(self, raise_exception):
        return True

        action_id = 'view'
        msg = self.get_msg(action_id)
        # 集群和命名空间因为对接RBAC时使用单独的命名规范,所以需要兼容
        if self.RESOURCE_TYPE in CLUSTER_NAMESPACE_RESOURCE_TYPE:
            real_action_id = 'cluster-readonly'
        else:
            real_action_id = action_id
        can = self.had_perm(real_action_id)

        if can is False and raise_exception is True:
            raise NoAuthPermError(msg, self.get_err_data(action_id))
        return can
Beispiel #3
0
    def can_delete(self, raise_exception):
        """是否使用删除
        """
        return True

        action_id = 'delete'
        msg = self.get_msg(action_id)
        if self.RESOURCE_TYPE in CLUSTER_NAMESPACE_RESOURCE_TYPE:
            real_action_id = 'cluster-readonly'
        else:
            real_action_id = action_id
        can = self.had_perm(real_action_id)

        if can is False and raise_exception is True:
            raise NoAuthPermError(msg, self.get_err_data(action_id))
        return can