Refactor authentication system: centralize credential handling in Builder

Major architectural improvement to eliminate duplicate credential embedding
and simplify authentication logic across the codebase.

Changes:
- Builder now generates all URL variants with proper authentication upfront
  * RTSP: generates URLs with embedded credentials and without (for open cameras)
  * HTTP/JPEG/MJPEG: generates variants with query params and for Basic Auth
- Tester simplified to only test ready-to-use URLs without modification
  * Removed auth chain logic and multiple authentication method attempts
  * Removed AuthMethod enum and related complexity
  * Credentials automatically extracted from URLs when needed
- Scanner cleaned up by removing embedCredentialsInURL function
  * All TestStream calls now use single URL parameter
  * Removed AuthMethod from DiscoveredStream model

Benefits:
- Eliminates bug where credentials were added up to 3 times
- Centralizes all URL generation logic in one place (Builder)
- Cleaner, more maintainable code with clear separation of concerns
- Reduces complexity by ~200 lines of code
- All authentication scenarios still fully supported
This commit is contained in:
eduard256
2025-11-07 19:08:05 +03:00
parent 292d5f8049
commit 88e76eadb5
8 changed files with 351 additions and 397 deletions
-1
View File
@@ -67,7 +67,6 @@ type DiscoveredStream struct {
Protocol string `json:"protocol"`
Port int `json:"port"`
Working bool `json:"working"`
AuthMethod string `json:"auth_method,omitempty"` // no_auth, basic_auth, query_params, combined, digest
Resolution string `json:"resolution,omitempty"`
Codec string `json:"codec,omitempty"`
FPS int `json:"fps,omitempty"`