feat(server): protocol v2 with signed handshake, secure voice relay, media broadcast and channel authorization
Revoke voice access on channel delete, kick and permission change, and acknowledge the sender's own chat messages.
This commit is contained in:
parent
bc5157046e
commit
3e7f5b22dc
44 changed files with 2825 additions and 386 deletions
13
docs/design/channel-authorization.md
Normal file
13
docs/design/channel-authorization.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Channel and role authorization
|
||||
|
||||
Channel create, edit and delete require guild ownership or actual current guild membership with `MANAGE_CHANNELS`. A stale role assignment does not substitute for membership. Client-supplied guild IDs cannot authorize modification of a channel in another guild: edit/delete use the channel's persisted scope. Global/default channels have no modeled server-administrator account and cannot be mutated through these authenticated user operations. Operators configure them server-side.
|
||||
|
||||
The channel list exposes global channels and only those guild channels where the requester is a member. Member and role lists also require current membership.
|
||||
|
||||
Role management requires `MANAGE_ROLES`, membership and a role belonging to that same guild. Assignment/removal requires the target to be a current guild member. A role manager may grant or manage only permissions they hold; guild owners and administrators bypass that subset check. This prevents a limited role manager from assigning the owner's administrative role or creating an administrator role. Permission queries additionally join on matching role/assignment guild IDs, so legacy invalid cross-guild assignments cannot supply permissions.
|
||||
|
||||
Access mutations take the gateway's shared access write lease. Joins and media authorization take a read lease through their state transition. No client socket write holds this lease. This orders membership/permission removal against issuance of fresh room credentials.
|
||||
|
||||
Deleting a channel clears active text/voice subscriptions, revokes the in-process UDP credentials and closes screen-share ownership/subscriptions before removing cached channel metadata. Removing `VOICE_SPEAK` through role deletion/unassignment rechecks active voice sessions and revokes their credentials and screen shares if no remaining role or owner status supplies permission. Voice reconnection requires fresh authorization.
|
||||
|
||||
This policy currently applies within one gateway process. It does not claim distributed locking across multiple gateways sharing a database. Existing queued delivery and in-flight network traffic obey the documented delivery-time checks and cannot be recalled after transmission.
|
||||
52
docs/design/media-broadcast.md
Normal file
52
docs/design/media-broadcast.md
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# Authenticated screen broadcast, LNEx media extension
|
||||
|
||||
The gateway authorizes signalling; established WebRTC transports media directly
|
||||
between consenting clients (ICE + DTLS-SRTP, VP8 video and separate Opus audio).
|
||||
An initial publisher has at most four viewers. This mesh is deliberately bounded;
|
||||
an SFU can replace it later inside the combined daemon. No custom packet crypto,
|
||||
UDP video fragmentation, global discovery signalling endpoint, or separate voice
|
||||
machine is introduced.
|
||||
|
||||
## Wire contract
|
||||
|
||||
The existing authenticated/encrypted LNEx connection carries protobuf packets
|
||||
`MediaControl` (0x0180, client→gateway) and `MediaEvent` (0x0181, gateway→client).
|
||||
Control fields: action(1), channel_id(2), share_id(3), target_session_id(4), body(5),
|
||||
mline_index(6), application_audio(7), microphone(8). Event has identical fields,
|
||||
plus server-stamped sender_session_id(9), publisher_user_id(10). Strings are UTF-8;
|
||||
share_id is a UUID and target_session_id is a server session identifier. Actions:
|
||||
START=1, STOP=2, WATCH=3, UNWATCH=4, OFFER=5, ANSWER=6, ICE=7.
|
||||
|
||||
START creates one live share per publisher session; its ack and announcement
|
||||
carry the authenticated publisher identity and track manifest. WATCH is explicit
|
||||
receiver consent and authorizes only that viewer/publisher pair. The publisher
|
||||
then sends OFFER; the viewer replies ANSWER; both may send ICE. SDP is limited to
|
||||
64 KiB and candidates to 2 KiB; no media bytes travel in these packets. The
|
||||
server never trusts a client-supplied sender, publisher identity, room membership,
|
||||
or subscription. Clients ignore ICE/answers not matching a live authorized peer.
|
||||
|
||||
Every operation requires authenticated membership in the exact voice channel.
|
||||
START additionally checks voice-speaking permissions. Guild membership is
|
||||
revalidated; stale roles do not grant access. Off-channel, unknown-share,
|
||||
non-owner STOP, unsolicited offers/answers and unsubscribed ICE are rejected.
|
||||
Channel leave, kick and disconnect revoke shares/subscriptions and emit STOP or
|
||||
UNWATCH. A viewer's connection is closed on revoke; revocation does not pretend
|
||||
to erase media already received. Control uses a per-session token bucket of 20 messages/s with a burst of 64;
|
||||
its entry is removed on revoke/disconnect. Recipient counts are bounded.
|
||||
|
||||
## Client media and explicit consent
|
||||
|
||||
A local portal-approved capture may be published only after a separate user
|
||||
start action. Video, selected application/output audio and microphone have
|
||||
independent track IDs and are not mixed. Missing application audio is an error;
|
||||
it never enables system audio. The microphone follows existing mute permission
|
||||
and remains disabled unless separately requested. Receiver viewing is opt-in;
|
||||
video is rendered in memory, audio uses the selected voice output, and closing
|
||||
stops peer pipelines. Stop closes every peer, clears frames and sends STOP.
|
||||
|
||||
GStreamer webrtcbin provides SDP/ICE/DTLS/SRTP; installed codec/plugin capability
|
||||
is checked before starting. Host candidates work on reachable networks; optional
|
||||
administrator-configured STUN/TURN is needed across some NATs. No public relay or
|
||||
third-party STUN destination is silently chosen. Synthetic two-peer tests must
|
||||
prove decoded video and distinct application/microphone samples reach the peer;
|
||||
private desktop/audio capture is never part of automated verification.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# Community webhook API v1
|
||||
|
||||
Additive LNEx packets `0x0200..0x0205` manage channel-scoped integrations over an already authenticated encrypted session. `MANAGE_WEBHOOKS` is permission bit11. Management requires a persisted text channel in a guild, actual current membership, and the permission (or guild ownership). The operational HTTP listener never exposes management APIs.
|
||||
Additive LNEx packets `0x0200..0x0206` manage channel-scoped integrations over an already authenticated encrypted session. `MANAGE_WEBHOOKS` is permission bit11. Management requires a persisted text channel in a guild, actual current membership, and the permission (or guild ownership). The operational HTTP listener never exposes management APIs.
|
||||
|
||||
- `WebhookCreate`: channel_id, name, direction (`incoming`/`outgoing`), provider (`generic`/`github`), endpoint for outgoing.
|
||||
- `WebhookList`: channel_id; returns descriptors without secrets.
|
||||
|
|
@ -8,6 +8,8 @@ Additive LNEx packets `0x0200..0x0205` manage channel-scoped integrations over a
|
|||
- `WebhookResult`: descriptor plus new secret only for create/rotate.
|
||||
- `WebhookListResult`: descriptors. Descriptors include suspension state. All management requests use the additive `WebhookRequest` message; the packet identifies the operation.
|
||||
|
||||
Requests carry a unique request_id (up to 64 ASCII alphanumeric/hyphen characters), echoed in both success responses and dedicated `WebhookErrorResult` packet `0x0206`. Clients discard stale/unknown replies, including one-time secrets, and refresh after a timeout because a mutation may already have committed.
|
||||
|
||||
Only incoming delivery is public HTTP: `POST /v1/webhooks/{webhook_id}`. Generic integrations use `Authorization: Bearer <secret>` and JSON `{ "content": "..." }`; unknown identity/avatar/mention fields are rejected. Optional `Idempotency-Key` deduplicates retries. GitHub adapters verify `X-Hub-Signature-256` over raw bytes and use `X-GitHub-Delivery` for deduplication. GitHub initially supports push, pull_request, issues, release and ping summaries. Delivery body is capped64KiB, content4000characters; mass mention syntax is denied. A webhook sender has a reserved `webhook:<id>` identity, never a user-provided sender ID. Production publishing requires HTTPS proxying; bearer tokens must not appear in URLs or access logs.
|
||||
|
||||
Incoming generic secrets are random256-bit values stored only as SHA256 hashes. GitHub HMAC and outgoing signing keys require reversible storage and are AEAD-sealed using `VNOX_WEBHOOK_SECRET_KEY` (64hexcharacters, protected environment). Those modes are unavailable if the master key is not configured. Key rotation replaces the active secret and invalidates the old token immediately. No DM/Hub/private-account access is granted.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue