feat: add ValidateDeviceToken method to device auth middleware
Add device token validation method for WebSocket authentication: - Validates device auth tokens against database - Returns device information for valid tokens - Used by WebSocket handler for device authentication This enables devices to authenticate WebSocket connections using their bearer tokens.
This commit is contained in:
@@ -2,6 +2,7 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bookmann/internal/database"
|
"bookmann/internal/database"
|
||||||
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -173,3 +174,7 @@ func (m *DeviceAuthMiddleware) UpdateLastSeen(next echo.HandlerFunc) echo.Handle
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *DeviceAuthMiddleware) ValidateDeviceToken(token string) (database.Devices, error) {
|
||||||
|
return m.db.GetDeviceByAuthToken(context.Background(), token)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user