SecurityConfig.fromJson constructor
Creates a SecurityConfig from a JSON map.
Implementation
factory SecurityConfig.fromJson(Map<String, dynamic> json) {
return SecurityConfig(
// ignore: deprecated_member_use_from_same_package
enableTLS: json['enableTLS'] as bool? ?? false,
// ignore: deprecated_member_use_from_same_package
tlsCertificatePath: json['tlsCertificatePath'] as String?,
// ignore: deprecated_member_use_from_same_package
tlsPrivateKeyPath: json['tlsPrivateKeyPath'] as String?,
// ignore: deprecated_member_use_from_same_package
enableKeyRotation: json['enableKeyRotation'] as bool? ?? true,
// ignore: deprecated_member_use_from_same_package
keyRotationInterval: Duration(
days: json['keyRotationDays'] as int? ?? 30,
),
// ignore: deprecated_member_use_from_same_package
maxAuthAttempts: json['maxAuthAttempts'] as int? ?? 3,
// ignore: deprecated_member_use_from_same_package
enableRateLimiting: json['enableRateLimiting'] as bool? ?? true,
// ignore: deprecated_member_use_from_same_package
maxRequestsPerMinute: json['maxRequestsPerMinute'] as int? ?? 100,
dhtDifficulty: json['dhtDifficulty'] as int? ?? 0,
enableDenylist: json['enableDenylist'] as bool? ?? false,
denylistPath: json['denylistPath'] as String?,
denylistStoragePath: json['denylistStoragePath'] as String?,
denylistRefreshInterval: json['denylistRefreshIntervalSeconds'] != null
? Duration(seconds: json['denylistRefreshIntervalSeconds'] as int)
: const Duration(hours: 1),
// ignore: deprecated_member_use_from_same_package
denylistCompactFormat: json['denylistCompactFormat'] as bool? ?? true,
denylistDefaultAction:
json['denylistDefaultAction'] as String? ?? 'block',
);
}