def propose_remove_task_owners(txn_key, batch_key, proposal_id, task_id,
                               user_id, reason, metadata):
    propose = task_transaction_pb2.ProposeRemoveTaskOwner(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.user.address(user_id),
        addresser.user.address(txn_key.public_key),
        addresser.task.owner.address(task_id, user_id),
        addresser.proposal.address(task_id, user_id),
        addresser.task.address(task_id),
    ]

    outputs = [addresser.proposal.address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_REMOVE_TASK_OWNER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def propose_remove_task_admins(txn_key, batch_key, proposal_id, task_id,
                               user_id, reason, metadata):
    propose = task_transaction_pb2.ProposeRemoveTaskAdmin(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.make_user_address(user_id),
        addresser.make_task_admins_address(task_id=task_id, user_id=user_id),
        addresser.make_proposal_address(task_id, user_id),
        addresser.make_task_attributes_address(task_id),
    ]

    outputs = [addresser.make_proposal_address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_REMOVE_TASK_ADMINS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#3
0
def propose_add_role_tasks(txn_key, batch_key, proposal_id, role_id, task_id,
                           reason, metadata):
    propose_payload = role_transaction_pb2.ProposeAddRoleTask(
        proposal_id=proposal_id,
        role_id=role_id,
        task_id=task_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.make_proposal_address(role_id, task_id),
        addresser.make_role_tasks_address(role_id, task_id),
        addresser.make_role_owners_address(role_id, txn_key.public_key),
        addresser.make_role_attributes_address(role_id),
        addresser.make_task_attributes_address(task_id),
    ]

    outputs = [addresser.make_proposal_address(role_id, task_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_ADD_ROLE_TASKS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#4
0
def propose_remove_role_members(txn_key, batch_key, proposal_id, role_id,
                                user_id, reason, metadata):
    propose = role_transaction_pb2.ProposeRemoveRoleMember(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.make_role_members_address(role_id, user_id),
        addresser.make_role_attributes_address(role_id=role_id),
        addresser.make_user_address(user_id=user_id),
        addresser.make_proposal_address(role_id, user_id),
    ]

    outputs = [addresser.make_proposal_address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_REMOVE_ROLE_MEMBERS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#5
0
def confirm_add_role_tasks(txn_key, batch_key, proposal_id, role_id, task_id,
                           reason):

    confirm_payload = role_transaction_pb2.ConfirmAddRoleTask(
        proposal_id=proposal_id,
        role_id=role_id,
        task_id=task_id,
        reason=reason)

    inputs = [
        addresser.make_proposal_address(role_id, task_id),
        addresser.make_task_owners_address(task_id, txn_key.public_key),
    ]

    outputs = [
        addresser.make_proposal_address(role_id, task_id),
        addresser.make_role_tasks_address(role_id, task_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_ADD_ROLE_TASKS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#6
0
def confirm_remove_role_owners(txn_key, batch_key, proposal_id, role_id,
                               user_id, reason):

    confirm_payload = role_transaction_pb2.ConfirmRemoveRoleOwner(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.make_proposal_address(role_id, user_id),
        addresser.make_role_admins_address(role_id, txn_key.public_key),
    ]

    outputs = [
        addresser.make_proposal_address(role_id, user_id),
        addresser.make_role_owners_address(role_id, user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_REMOVE_ROLE_OWNERS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#7
0
def confirm_add_role_members(txn_key, batch_key, proposal_id, role_id, user_id,
                             reason):

    confirm_payload = role_transaction_pb2.ConfirmAddRoleMember(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.role.owner.address(role_id, txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.role.member.address(role_id, user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_ADD_ROLE_MEMBER,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def reject_remove_task_owners(txn_key, batch_key, proposal_id, task_id,
                              user_id, reason):
    reject = task_transaction_pb2.RejectRemoveTaskOwner(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(task_id, user_id),
        addresser.user.address(txn_key.public_key),
        addresser.task.admin.address(task_id, txn_key.public_key),
    ]

    outputs = [addresser.proposal.address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_REMOVE_TASK_OWNER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def confirm_add_task_admins(txn_key, batch_key, proposal_id, task_id, user_id,
                            reason):
    confirm_payload = task_transaction_pb2.ConfirmAddTaskAdmin(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.task.admin.address(task_id, txn_key.public_key),
        addresser.proposal.address(task_id, user_id),
    ]

    outputs = [
        addresser.proposal.address(task_id, user_id),
        addresser.task.admin.address(task_id, user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_ADD_TASK_ADMINS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def create_task(txn_key, batch_key, task_id, task_name, admins, owners,
                metadata):

    create_payload = task_transaction_pb2.CreateTask(task_id=task_id,
                                                     name=task_name)

    create_payload.admins.extend(admins)

    inputs = [
        addresser.task.address(task_id),
        addresser.sysadmin.member.address(txn_key.public_key),
    ]

    inputs.extend([addresser.user.address(u) for u in admins])
    inputs.extend([addresser.task.admin.address(task_id, u) for u in admins])

    outputs = [addresser.task.address(task_id)]

    outputs.extend([addresser.task.admin.address(task_id, u) for u in admins])

    if owners:
        create_payload.owners.extend(owners)
        inputs.extend([addresser.user.address(u) for u in owners])
        inputs.extend(
            [addresser.task.owner.address(task_id, u) for u in owners])
        outputs.extend(
            [addresser.task.owner.address(task_id, u) for u in owners])

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=create_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CREATE_TASK,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def propose_add_task_admins(txn_key, batch_key, proposal_id, task_id, user_id,
                            reason, metadata):
    propose_payload = task_transaction_pb2.ProposeAddTaskAdmin(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.user.address(user_id),
        addresser.task.admin.address(task_id, user_id),
        addresser.proposal.address(task_id, user_id),
        addresser.task.address(task_id),
    ]

    outputs = [addresser.proposal.address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_ADD_TASK_ADMINS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def propose_add_task_owner(txn_key, batch_key, proposal_id, task_id, user_id,
                           reason, metadata):
    propose = task_transaction_pb2.ProposeAddTaskOwner(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.make_user_address(user_id),
        addresser.make_task_owners_address(task_id, user_id),
        addresser.make_task_attributes_address(task_id),
        addresser.make_proposal_address(task_id, user_id),
    ]

    outputs = [addresser.make_proposal_address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_ADD_TASK_OWNERS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#13
0
def propose_add_role_members(txn_key, batch_key, proposal_id, role_id, user_id,
                             reason, metadata):

    propose_payload = role_transaction_pb2.ProposeAddRoleMember(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.role.member.address(role_id, user_id),
        addresser.role.address(role_id),
        addresser.user.address(user_id),
        addresser.proposal.address(role_id, user_id),
    ]

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_ADD_ROLE_MEMBER,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#14
0
def propose_remove_role_tasks(txn_key, batch_key, proposal_id, role_id,
                              task_id, reason, metadata):
    propose = role_transaction_pb2.ProposeRemoveRoleTask(
        proposal_id=proposal_id,
        role_id=role_id,
        task_id=task_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.proposal.address(role_id, task_id),
        addresser.role.task.address(role_id, task_id),
        addresser.role.address(role_id),
        addresser.task.address(task_id),
    ]

    outputs = [addresser.proposal.address(role_id, task_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_REMOVE_ROLE_TASK,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def reject_add_task_admins(txn_key, batch_key, proposal_id, task_id, user_id,
                           reason):
    reject_payload = task_transaction_pb2.RejectAddTaskAdmin(
        proposal_id=proposal_id,
        task_id=task_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.task.admin.address(task_id, txn_key.public_key),
        addresser.user.address(txn_key.public_key),
        addresser.proposal.address(task_id, user_id),
    ]

    outputs = [addresser.proposal.address(task_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_ADD_TASK_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#16
0
def reject_remove_role_members(txn_key, batch_key, proposal_id, role_id,
                               user_id, reason):
    reject_payload = role_transaction_pb2.RejectRemoveRoleMember(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.user.address(txn_key.public_key),
        addresser.role.owner.address(role_id, txn_key.public_key),
    ]

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_REMOVE_ROLE_MEMBER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#17
0
def reject_remove_role_admins(txn_key, batch_key, proposal_id, role_id,
                              user_id, reason):

    reject_add_payload = role_transaction_pb2.RejectRemoveRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.role.admin.address(role_id, txn_key.public_key),
        addresser.user.address(txn_key.public_key),
    ]
    inputs.append(addresser.proposal.address(role_id, user_id))

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_REMOVE_ROLE_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#18
0
def propose_remove_role_admins(txn_key, batch_key, proposal_id, role_id,
                               user_id, reason, metadata):
    propose = role_transaction_pb2.ProposeRemoveRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.user.address(user_id),
        addresser.user.address(txn_key.public_key),
        addresser.proposal.address(role_id, user_id),
        addresser.role.admin.address(role_id, user_id),
        addresser.role.address(role_id),
    ]

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_REMOVE_ROLE_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#19
0
def confirm_remove_role_tasks(txn_key, batch_key, proposal_id, role_id,
                              task_id, reason):

    confirm_payload = role_transaction_pb2.ConfirmRemoveRoleTask(
        proposal_id=proposal_id,
        role_id=role_id,
        task_id=task_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(role_id, task_id),
        addresser.task.owner.address(task_id, txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(role_id, task_id),
        addresser.role.task.address(role_id, task_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_REMOVE_ROLE_TASK,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#20
0
def create_role(txn_key, batch_key, role_name, role_id, metadata, admins,
                owners):
    """Create a BatchList with a CreateRole transaction in it.

    Args:
        txn_key (Key): The transaction signer's key pair.
        batch_key (Key): The batch signer's key pair.
        role_name (str): The name of the Role.
        role_id (str): A uuid that identifies this Role.
        metadata (str): Client supplied information that is not parsed.
        admins (list): A list of User ids of the Users who are admins of this
            Role.
        owners (list): A list of User ids of the Users who are owners of this
            Role.

    Returns:
        tuple
            BatchList, batch header_signature tuple
    """

    create_role_payload = role_transaction_pb2.CreateRole(role_id=role_id,
                                                          name=role_name,
                                                          metadata=metadata,
                                                          admins=admins,
                                                          owners=owners)

    inputs = [
        addresser.make_sysadmin_members_address(txn_key.public_key),
        addresser.make_role_attributes_address(role_id),
    ]
    inputs.extend([addresser.make_user_address(u) for u in admins])
    inputs.extend([addresser.make_user_address(u) for u in owners])
    inputs.extend([
        addresser.make_role_admins_address(role_id=role_id, user_id=a)
        for a in admins
    ])
    inputs.extend([
        addresser.make_role_owners_address(role_id=role_id, user_id=o)
        for o in owners
    ])

    outputs = [addresser.make_role_attributes_address(role_id)]
    outputs.extend([
        addresser.make_role_admins_address(role_id=role_id, user_id=a)
        for a in admins
    ])
    outputs.extend([
        addresser.make_role_owners_address(role_id=role_id, user_id=o)
        for o in owners
    ])

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=create_role_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CREATE_ROLE,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def propose_manager(txn_key, batch_key, proposal_id, user_id, new_manager_id,
                    reason, metadata):
    """Create a BatchList with a ProposeUpdateUserManager transaction
    in it.

    Args:
        txn_key (Key): The transaction signer public/private key pair
        batch_key (Key): The batch signer public/private key pair
        proposal_id (str): The id of the proposal supplied by the rest api.
        user_id (str): The User id of the user whose manager will be updated.
        new_manager_id (str): The new manager's id.
        reason (str): The reason for this update.
        metadata (str): Client supplied metadata.

    Returns:
        tuple
            BatchList, batch header_signature tuple
    """

    propose_update_payload = user_transaction_pb2.ProposeUpdateUserManager(
        proposal_id=proposal_id,
        user_id=user_id,
        new_manager_id=new_manager_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.user.address(user_id),
        addresser.user.address(new_manager_id),
        addresser.proposal.address(object_id=user_id,
                                   related_id=new_manager_id),
        addresser.user.address(txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(object_id=user_id,
                                   related_id=new_manager_id)
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose_update_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_UPDATE_USER_MANAGER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def reject_manager(txn_key, batch_key, proposal_id, reason, user_id,
                   manager_id):
    """Create a BatchList with a RejectUpdateUserManager in it.

    Args:
        txn_key (Key): The public/private key pair for signing the txn.
        batch_key (Key): The public/private key pair for signing the batch.
        proposal_id (str): The identifier of the proposal.
        reason (str): The client supplied reason for rejecting the proposal.
        user_id (str): The user's public key.
        manager_id (str): The manager's public key.

    Returns:
        tuple
            BatchList, signature tuple
    """

    reject_update_payload = user_transaction_pb2.RejectUpdateUserManager(
        proposal_id=proposal_id,
        user_id=user_id,
        manager_id=manager_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(object_id=user_id, related_id=manager_id),
        addresser.user.address(txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(object_id=user_id, related_id=manager_id)
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_update_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_UPDATE_USER_MANAGER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(
        rbac_payload=rbac_payload,
        inputs=inputs,
        outputs=outputs,
        txn_key=txn_key,
        batch_key=batch_key,
    )
示例#23
0
def propose_add_role_admins(txn_key, batch_key, proposal_id, role_id, user_id,
                            reason, metadata):
    """Create a BatchList with a ProposeAddRoleAdmins transaction in it.

    Args:
        txn_key (Key): The txn signer key pair.
        batch_key (Key): The batch signer key pair.
        role_id (str): The role's id.
        user_id (str): The user that is being proposed to be an admin.
        reason (str): The client supplied reason for the proposal.
        metadata (str): The client supplied metadata.

    Returns:
        tuple
            BatchList, batch header_signature tuple
    """

    propose_add_payload = role_transaction_pb2.ProposeAddRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason,
        metadata=metadata,
    )

    inputs = [
        addresser.user.address(user_id),
        addresser.user.address(txn_key.public_key),
        addresser.proposal.address(role_id, user_id),
        addresser.role.admin.address(role_id, user_id),
        addresser.role.address(role_id),
    ]

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=propose_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.PROPOSE_ADD_ROLE_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#24
0
def confirm_add_role_admins(txn_key, batch_key, proposal_id, role_id, user_id,
                            reason):
    """Creates a BatchList with a ConfirmAddRoleAdmin transaction in it.

    Args:
        txn_key (Key): The txn signer key pair.
        batch_key (Key): The batch signer key pair.
        proposal_id (str): The proposal's identifier.
        role_id (str): The role's identifier.
        user_id (str): The user's signer public key.
        reason (str): The client supplied reason to confirm.

    Returns:
        tuple
            BatchList, batch header_signature tuple
    """

    confirm_add_payload = role_transaction_pb2.ConfirmAddRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.role.admin.address(role_id, txn_key.public_key),
        addresser.user.address(txn_key.public_key),
    ]
    inputs.append(addresser.proposal.address(role_id, user_id))

    outputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.role.admin.address(role_id, user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_ADD_ROLE_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#25
0
def create_user(txn_key,
                batch_key,
                name,
                user_name,
                user_id,
                metadata,
                manager_id=None):
    """Create a BatchList with a CreateUser RBAC transaction.

    Args:
        txn_key (Key): The transaction signer's public/private key pair.
        batch_key (Key): The batch signer's public/private key pair.
        user_name (str): The user name of the User.
        user_id (str): The User's public key.
        metadata (str): Client supplied metadata.
        manager_id (str): The optional id of the manager of this User.

    Returns:
        tuple
            The CreateUser BatchList as the zeroth element and the
            batch header_signature as the first element.

    """

    create_user_payload = user_transaction_pb2.CreateUser(name=name,
                                                          user_name=user_name,
                                                          user_id=user_id,
                                                          metadata=metadata)
    inputs = [addresser.make_user_address(user_id=user_id)]
    outputs = [addresser.make_user_address(user_id=user_id)]
    if manager_id:
        create_user_payload.manager_id = manager_id
        inputs.append(addresser.make_user_address(user_id=manager_id))
        outputs.append(addresser.make_user_address(user_id=manager_id))

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=create_user_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CREATE_USER,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def confirm_manager(txn_key, batch_key, proposal_id, user_id, manager_id,
                    reason):
    """Create a BatchList with a ConfirmUpdateUserManager transaction in it.

    Args:
        txn_key (Key): The transaction signer public/private key pair.
        batch_key (Key): The batch signer public/private key pair.
        proposal_id (str): The identifier of the proposal.
        reason (str): The client supplied reason for the confirmation.

    Returns:
        tuple
            BatchList, batch header_signature tuple
    """

    confirm_update_payload = user_transaction_pb2.ConfirmUpdateUserManager(
        proposal_id=proposal_id,
        user_id=user_id,
        manager_id=manager_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(user_id, manager_id),
        addresser.user.address(user_id),
        addresser.user.address(txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(user_id, manager_id),
        addresser.user.address(user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_update_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_UPDATE_USER_MANAGER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#27
0
def reject_add_role_owners(txn_key, batch_key, proposal_id, role_id, user_id,
                           reason):
    reject_payload = role_transaction_pb2.RejectAddRoleOwner(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.role.admin.address(role_id, txn_key.public_key),
    ]

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_ADD_ROLE_OWNER,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#28
0
def reject_remove_role_tasks(txn_key, batch_key, proposal_id, role_id, task_id,
                             reason):

    reject_payload = role_transaction_pb2.RejectRemoveRoleTask(
        proposal_id=proposal_id,
        role_id=role_id,
        task_id=task_id,
        reason=reason)

    inputs = [
        addresser.make_proposal_address(role_id, task_id),
        addresser.make_task_owners_address(task_id, txn_key.public_key),
    ]

    outputs = [addresser.make_proposal_address(role_id, task_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_REMOVE_ROLE_TASKS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
示例#29
0
def reject_add_role_admins(txn_key, batch_key, proposal_id, role_id, user_id,
                           reason):

    reject_add_payload = role_transaction_pb2.RejectAddRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.make_role_admins_address(role_id=role_id,
                                           user_id=txn_key.public_key)
    ]
    inputs.append(addresser.make_proposal_address(role_id, user_id))

    outputs = [addresser.make_proposal_address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_ADD_ROLE_ADMINS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def confirm_remove_role_admins(txn_key, batch_key, proposal_id, role_id,
                               user_id, reason):

    confirm_add_payload = role_transaction_pb2.ConfirmRemoveRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [addresser.role.admin.address(role_id, txn_key.public_key)]
    inputs.append(addresser.proposal.address(role_id, user_id))

    outputs = [
        addresser.proposal.address(role_id, user_id),
        addresser.role.admin.address(role_id, user_id),
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=confirm_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.CONFIRM_REMOVE_ROLE_ADMINS,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)