Feat/channel invitation workflow part 4#808
Open
Pranav-d33 wants to merge 5 commits into
Open
Conversation
Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds invitation endpoints to the Channel API — replaces the one-step `add_organization` flow with a proper Fabric channel update workflow.
### New Endpoints
- GET /invitations - List invitations visible to org (any member)
- POST /invitations - Create invitation + generate artifact (admin)
- GET /invitations/{id} - Retrieve invitation details (visibility-gated)
- POST /invitations/{id}/cancel - Cancel invitation (member-admin only)
### Design Decisions
- Admin-only mutations: create/cancel require is_admin
- Signature threshold: all current members by default, overridable
- Cancelable states: DRAFT, SIGNING, FAILED, READY
- Cancel vs Reject (PR 6): Cancel hard-stops the whole invitation. Reject is per-invitee decline.
- Who can cancel: Channel member admin only
- Duplicate protection: Rejects if invitee has PENDING invitee on active invitation
- Reinvite allowed after CANCELED or REJECTED
### Files
views.py: 3 @action methods + helpers
serializers.py: create calls agent, CancelSerializer, duplicate validation
service.py: create_invitation_artifact() agent call
tests.py: 12 endpoint tests (APIClient+JWT), 13 model tests with mocks
Test: 32/32 pass, flake8 clean.
Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
- Add msp_id field to Organization (auto-derives from name as fallback) - Update create_invitation_artifact to pass o.msp_id instead of str(o.id) - Update auth serializer and org service to accept msp_id - Fix pre-existing enum metaclass crash on Python 3.13 - Fix missing max_length on Organization and Chaincode CharFields - Add proper error handling for agent failures in view Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds POST /channels/{channel_name}/invitations/definition on the Fabric agent.
Service generates unsigned channel update artifact:
1. Fetch + decode channel config
2. Build org group entries (MSP + AnchorPeers) with base64 PEM certs
3. Compute config update diff via configtxlator
4. Wrap in unsigned envelope, encode to protobuf
5. Return bytes, clean up temp files
Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
13ea09b to
0534fb0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Fabric agent endpoint for generating unsigned channel update artifacts during the invitation workflow.
Changes
channel/views.py— AddPOST /channels/{name}/invitations/definitionendpoint (returns binary artifact)channel/serializers.py—InvitationDefinitionSerializeracceptsorganization_msp_idschannel/service.py—generate_invitation_definition()fetches current channel config viapeer channel fetch, appends new org MSP definitions viaconfigtxlator compute_update, wraps in envelope; includes_build_org_group(),_read_crypto_config(),_read_b64()channel/tests.py— 7 tests covering serializer validation, artifact generation, temp file cleanup, subprocess error handlingTest Plan
python manage.py test channel.tests— 7 tests, all passingorganization_msp_idsis requiredsubprocess.CalledProcessErrorsurfaces predictablyNotes
finallyblockOrg1MSP)