- Created AuthStrategy interface for polymorphic authentication - Implemented NoAuthStrategy for open servers (local IP, no reverse proxy) - Implemented BasicAuthStrategy for HTTP Basic Auth reverse proxies - Implemented AutheliaStrategy (migrated from existing auth_service.dart) - Created AuthManager with auto-detection logic - Supports universal compatibility: local IP, basic auth, Authelia setups Phase 1 complete. Next: integrate with existing app layers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
/// Authentication credentials container
|
|
class AuthCredentials {
|
|
final String strategyName;
|
|
final Map<String, dynamic> data;
|
|
|
|
AuthCredentials(this.strategyName, this.data);
|
|
}
|
|
|
|
/// Abstract authentication strategy interface
|
|
/// Implementations handle different auth methods (none, basic, Authelia, HA, etc.)
|
|
abstract class AuthStrategy {
|
|
/// Strategy name identifier (e.g., 'none', 'basic', 'authelia')
|
|
String get name;
|
|
|
|
/// Attempt login and return auth credentials/token
|
|
/// Returns null if login fails
|
|
Future<AuthCredentials?> login(
|
|
String serverUrl,
|
|
String username,
|
|
String password,
|
|
);
|
|
|
|
/// Test if current credentials are still valid
|
|
Future<bool> validateCredentials(
|
|
String serverUrl,
|
|
AuthCredentials credentials,
|
|
);
|
|
|
|
/// Build headers for WebSocket connection
|
|
/// Example: {'Authorization': 'Basic xyz'} or {'Cookie': 'session=abc'}
|
|
Map<String, dynamic> buildWebSocketHeaders(AuthCredentials credentials);
|
|
|
|
/// Build headers for HTTP streaming requests
|
|
/// Example: {'Authorization': 'Basic xyz'}
|
|
Map<String, String> buildStreamingHeaders(AuthCredentials credentials);
|
|
|
|
/// Serialize credentials for persistent storage
|
|
Map<String, dynamic> serializeCredentials(AuthCredentials credentials);
|
|
|
|
/// Deserialize credentials from persistent storage
|
|
AuthCredentials deserializeCredentials(Map<String, dynamic> data);
|
|
}
|