@@ -770,6 +770,130 @@ Configure permissions in the Strapi admin panel:
770770
771771---
772772
773+ ## Security
774+
775+ The plugin implements multiple security layers to protect your real-time connections.
776+
777+ ### Admin Session Tokens
778+
779+ For admin panel connections (Live Presence), the plugin uses secure session tokens:
780+
781+ ```
782+ +------------------+ +------------------+ +------------------+
783+ | Admin Browser | ---> | Session Endpoint| ---> | Socket.IO |
784+ | (Strapi Admin) | | /io/presence/ | | Server |
785+ +------------------+ +------------------+ +------------------+
786+ | | |
787+ | 1. Request session | |
788+ | (Admin JWT in header) | |
789+ +------------------------>| |
790+ | | |
791+ | 2. Return session token | |
792+ | (UUID, 10 min TTL) | |
793+ |<------------------------+ |
794+ | | |
795+ | 3. Connect Socket.IO | |
796+ | (Session token in auth) | |
797+ +-------------------------------------------------->|
798+ | | |
799+ | 4. Validate & connect | |
800+ |<--------------------------------------------------+
801+ ```
802+
803+ ** Security Features:**
804+ - ** Token Hashing** : Tokens stored as SHA-256 hashes (plaintext never persisted)
805+ - ** Short TTL** : 10-minute expiration with automatic refresh at 70%
806+ - ** Usage Limits** : Max 10 reconnects per token to prevent replay attacks
807+ - ** Rate Limiting** : 30-second cooldown between token requests
808+ - ** Minimal Data** : Only essential user info stored (ID, firstname, lastname)
809+
810+ ### Rate Limiting
811+
812+ Prevent abuse with configurable rate limits:
813+
814+ ``` javascript
815+ // In config/plugins.js
816+ module .exports = {
817+ io: {
818+ enabled: true ,
819+ config: {
820+ security: {
821+ rateLimit: {
822+ enabled: true ,
823+ maxEventsPerSecond: 10 , // Max events per socket per second
824+ maxConnectionsPerIp: 50 // Max connections from single IP
825+ }
826+ }
827+ }
828+ }
829+ };
830+ ```
831+
832+ ### IP Whitelisting/Blacklisting
833+
834+ Restrict access by IP address:
835+
836+ ``` javascript
837+ // In config/plugins.js
838+ module .exports = {
839+ io: {
840+ enabled: true ,
841+ config: {
842+ security: {
843+ ipWhitelist: [' 192.168.1.0/24' , ' 10.0.0.1' ], // Only these IPs allowed
844+ ipBlacklist: [' 203.0.113.50' ], // These IPs blocked
845+ requireAuthentication: true // Require JWT/API token
846+ }
847+ }
848+ }
849+ };
850+ ```
851+
852+ ### Security Monitoring API
853+
854+ Monitor active sessions via admin API:
855+
856+ ``` bash
857+ # Get session statistics
858+ GET /io/security/sessions
859+ Authorization: Bearer < admin-jwt>
860+
861+ # Response:
862+ {
863+ " data" : {
864+ " activeSessions" : 5,
865+ " expiringSoon" : 1,
866+ " activeSocketConnections" : 3,
867+ " sessionTTL" : 600000,
868+ " refreshCooldown" : 30000
869+ }
870+ }
871+
872+ # Force logout a user (invalidate all their sessions)
873+ POST /io/security/invalidate/:userId
874+ Authorization: Bearer < admin-jwt>
875+
876+ # Response:
877+ {
878+ " data" : {
879+ " userId" : 1,
880+ " invalidatedSessions" : 2,
881+ " message" : " Successfully invalidated 2 session(s)"
882+ }
883+ }
884+ ```
885+
886+ ### Best Practices
887+
888+ 1 . ** Always use HTTPS** in production for encrypted WebSocket connections
889+ 2 . ** Enable authentication** for sensitive content types
890+ 3 . ** Configure CORS** to only allow your frontend domains
891+ 4 . ** Monitor connections** via the admin dashboard
892+ 5 . ** Set reasonable rate limits** based on your use case
893+ 6 . ** Review access logs** periodically for suspicious activity
894+
895+ ---
896+
773897## Admin Panel
774898
775899The plugin provides a full admin interface for configuration and monitoring.
@@ -1327,6 +1451,9 @@ Copyright (c) 2024 Strapi Community
13271451- ** Admin Panel Sidebar** - Live presence panel integrated into edit view
13281452- ** Admin Session Authentication** - Secure session tokens for Socket.IO
13291453- ** Admin JWT Strategy** - New authentication strategy for admin users
1454+ - ** Enhanced Security** - Token hashing (SHA-256), usage limits, rate limiting
1455+ - ** Automatic Token Refresh** - Tokens auto-refresh at 70% of TTL
1456+ - ** Security Monitoring API** - Session stats and force-logout endpoints
13301457
13311458### v5.0.0
13321459- Strapi v5 support
0 commit comments