SecurityConfig.fromJson constructor

SecurityConfig.fromJson(
  1. Map<String, dynamic> json
)

Creates a SecurityConfig from a JSON map.

Implementation

factory SecurityConfig.fromJson(Map<String, dynamic> json) {
  return SecurityConfig(
    enableTLS: json['enableTLS'] as bool? ?? false,
    tlsCertificatePath: json['tlsCertificatePath'] as String?,
    tlsPrivateKeyPath: json['tlsPrivateKeyPath'] as String?,
    enableKeyRotation: json['enableKeyRotation'] as bool? ?? true,
    keyRotationInterval: Duration(
      days: json['keyRotationDays'] as int? ?? 30,
    ),
    maxAuthAttempts: json['maxAuthAttempts'] as int? ?? 3,
    enableRateLimiting: json['enableRateLimiting'] as bool? ?? true,
    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),
    denylistCompactFormat: json['denylistCompactFormat'] as bool? ?? true,
    denylistDefaultAction:
        json['denylistDefaultAction'] as String? ?? 'block',
  );
}