mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-13 20:33:25 +00:00
Unified Ed25519 authentication - remove peer_id/credentials system
BREAKING CHANGE: Remove dual authentication system
- Remove POST /register endpoint - no longer needed
- Remove peer_id/secret credential-based auth
- All authentication now uses username + Ed25519 signatures
- Anonymous users can generate random usernames (anon-{timestamp}-{hex})
Database schema:
- Rename peer_id → username in offers table
- Rename answerer_peer_id → answerer_username in offers table
- Rename peer_id → username in ice_candidates table
- Remove secret column from offers table
- Add FK constraints for username columns
Storage layer:
- Update D1 and SQLite implementations
- All methods use username instead of peerId
- Remove secret-related code
Auth middleware:
- Replace validateCredentials() with Ed25519 signature verification
- Extract auth from request body (POST) or query params (GET)
- Verify signature against username's public key
- Validate message format and timestamp
Crypto utilities:
- Remove generatePeerId(), encryptPeerId(), decryptPeerId(), validateCredentials()
- Add generateAnonymousUsername() - creates anon-{timestamp}-{random}
- Add validateAuthMessage() - validates auth message format
Config:
- Remove authSecret from Config interface (no longer needed)
All server endpoints updated to use getAuthenticatedUsername()
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
-- Fresh schema for Rondevu v0.4.1+
|
||||
-- Fresh schema for Rondevu v0.5.0+
|
||||
-- Unified Ed25519 authentication - username/keypair only
|
||||
-- This is the complete schema without migration steps
|
||||
|
||||
-- Drop existing tables if they exist
|
||||
@@ -7,44 +8,7 @@ DROP TABLE IF EXISTS services;
|
||||
DROP TABLE IF EXISTS offers;
|
||||
DROP TABLE IF EXISTS usernames;
|
||||
|
||||
-- Offers table
|
||||
CREATE TABLE offers (
|
||||
id TEXT PRIMARY KEY,
|
||||
peer_id TEXT NOT NULL,
|
||||
service_id TEXT,
|
||||
sdp TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
expires_at INTEGER NOT NULL,
|
||||
last_seen INTEGER NOT NULL,
|
||||
secret TEXT,
|
||||
answerer_peer_id TEXT,
|
||||
answer_sdp TEXT,
|
||||
answered_at INTEGER
|
||||
);
|
||||
|
||||
CREATE INDEX idx_offers_peer ON offers(peer_id);
|
||||
CREATE INDEX idx_offers_service ON offers(service_id);
|
||||
CREATE INDEX idx_offers_expires ON offers(expires_at);
|
||||
CREATE INDEX idx_offers_last_seen ON offers(last_seen);
|
||||
CREATE INDEX idx_offers_answerer ON offers(answerer_peer_id);
|
||||
|
||||
-- ICE candidates table
|
||||
CREATE TABLE ice_candidates (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
offer_id TEXT NOT NULL,
|
||||
peer_id TEXT NOT NULL,
|
||||
role TEXT NOT NULL CHECK(role IN ('offerer', 'answerer')),
|
||||
candidate TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (offer_id) REFERENCES offers(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_ice_offer ON ice_candidates(offer_id);
|
||||
CREATE INDEX idx_ice_peer ON ice_candidates(peer_id);
|
||||
CREATE INDEX idx_ice_role ON ice_candidates(role);
|
||||
CREATE INDEX idx_ice_created ON ice_candidates(created_at);
|
||||
|
||||
-- Usernames table
|
||||
-- Usernames table (now required for all users, even anonymous)
|
||||
CREATE TABLE usernames (
|
||||
username TEXT PRIMARY KEY,
|
||||
public_key TEXT NOT NULL UNIQUE,
|
||||
@@ -75,3 +39,43 @@ CREATE INDEX idx_services_fqn ON services(service_fqn);
|
||||
CREATE INDEX idx_services_discovery ON services(service_name, version);
|
||||
CREATE INDEX idx_services_username ON services(username);
|
||||
CREATE INDEX idx_services_expires ON services(expires_at);
|
||||
|
||||
-- Offers table (now uses username instead of peer_id)
|
||||
CREATE TABLE offers (
|
||||
id TEXT PRIMARY KEY,
|
||||
username TEXT NOT NULL,
|
||||
service_id TEXT,
|
||||
service_fqn TEXT,
|
||||
sdp TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
expires_at INTEGER NOT NULL,
|
||||
last_seen INTEGER NOT NULL,
|
||||
answerer_username TEXT,
|
||||
answer_sdp TEXT,
|
||||
answered_at INTEGER,
|
||||
FOREIGN KEY (username) REFERENCES usernames(username) ON DELETE CASCADE,
|
||||
FOREIGN KEY (answerer_username) REFERENCES usernames(username) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_offers_username ON offers(username);
|
||||
CREATE INDEX idx_offers_service ON offers(service_id);
|
||||
CREATE INDEX idx_offers_expires ON offers(expires_at);
|
||||
CREATE INDEX idx_offers_last_seen ON offers(last_seen);
|
||||
CREATE INDEX idx_offers_answerer ON offers(answerer_username);
|
||||
|
||||
-- ICE candidates table (now uses username instead of peer_id)
|
||||
CREATE TABLE ice_candidates (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
offer_id TEXT NOT NULL,
|
||||
username TEXT NOT NULL,
|
||||
role TEXT NOT NULL CHECK(role IN ('offerer', 'answerer')),
|
||||
candidate TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (offer_id) REFERENCES offers(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (username) REFERENCES usernames(username) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_ice_offer ON ice_candidates(offer_id);
|
||||
CREATE INDEX idx_ice_username ON ice_candidates(username);
|
||||
CREATE INDEX idx_ice_role ON ice_candidates(role);
|
||||
CREATE INDEX idx_ice_created ON ice_candidates(created_at);
|
||||
|
||||
Reference in New Issue
Block a user