SP4: Server-derived member_id for SyncPlay group operations#342
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 1 medium |
| BestPractice | 5 medium |
| Documentation | 47 minor |
| ErrorProne | 1 medium |
| Security | 2 high |
| CodeStyle | 30 minor |
| Complexity | 12 medium |
| Comprehensibility | 2 minor |
🟢 Metrics 64 complexity · 3 duplication
Metric Results Complexity 64 Duplication 3
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This implements SP4 spec requirement that member_id is server-derived from the authenticated connection's userId, not from the client wire payload. Changes: - handleGroupCreate(): Use $connection->getUserId() as member_id - handleGroupJoin(): Use $connection->getUserId() as member_id - handlePlaybackPlay/Pause/Seek/Queue(): Use $connection->getUserId() for host authorization (check if connection's userId is the host) - Added NOT_AUTHENTICATED error when connection has no userId - GroupState::getState() now returns members as keyed dict (not list) - Extracted TestConnection to separate PSR-12 compliant file The host authorization fix prevents spoofed member_id attacks where a client claims to be a different member. The server now always uses the authenticated connection's userId for authorization decisions.
bbb320b to
1271134
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.
Summary
Implements SP4 specification requirement that
member_idis server-derived from the authenticated connection'suserId, not from the client wire payload.Changes
Core SP4 Logic
$connection->getUserId()as themember_idfor the creating member$connection->getUserId()as themember_idfor the joining member$connection->getUserId() === $group['host_member_id']instead of trusting client-suppliedmember_idin payloadNOT_AUTHENTICATEDerror when connection'sgetUserId()returns nullGroupState::getState()
Returns
membersas an associative array keyed by member_id (instead of a numeric list) to support server-derived member_id lookup.Test Infrastructure
TestConnectionclass to separate PSR-12 compliant filetests/Unit/Server/WebSocket/TestConnection.phpWsAuthenticationTest.phpupdated to use the extracted classSecurity Fix
This prevents spoofed
member_idattacks where a malicious client claims to be a different member. The server now always uses the authenticated connection'suserIdfor authorization decisions, ensuring only the actual group host can control playback.Test Results
PHPStan level 9: ✅ PASS
PHPCS PSR-12: ✅ PASS