Feat/channel invitation workflow part 5#809
Open
Pranav-d33 wants to merge 6 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>
58cc347 to
38c4faa
Compare
- Fabric agent: sign_config_update() service, InvitationSignSerializer, invitation_sign endpoint - API engine: sign_invitation_artifact() service, ChannelInvitationSignSerializer, sign_invitation endpoint - Auto-transitions DRAFT->SIGNING->READY at signature threshold; FAILED on agent error - 42 API engine tests pass (8 new sign tests + 34 existing) - Fix: invitations POST returning 200 instead of 201 (pre-existing bug) - Fix: sign endpoint returning 403 instead of 404 for non-members - Add test_settings.py for SQLite-based local test runs Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Fabric agent: - join_channel() service: submits signed config update, fetches block, joins peer - InvitationJoinSerializer, invitation_join endpoint (POST .../invitations/join) API engine: - accept_invitation() service helper: contacts agent join endpoint - ChannelInvitationAcceptSerializer: validates READY status + PENDING invitee, calls agent, adds org to channel, marks ACCEPTED - ChannelInvitationRejectSerializer: validates READY status + PENDING invitee, marks REJECTED (no agent call) - accept_invitation and reject_invitation view actions with 404/400/500 handling - 49 channel tests pass (7 new accept/reject tests + 42 existing) Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
38c4faa to
2eee94c
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.
No description provided.