RemoteAuthenticatorConfig.parse constructor
RemoteAuthenticatorConfig.parse(
- Map<
String, Object?> options, - RealmSettings realm
Implementation
factory RemoteAuthenticatorConfig.parse(
Map<String, Object?> options,
RealmSettings realm,
) {
final method = options['method'] as String? ?? 'remote';
final timeoutMs =
(options['challenge_timeout_ms'] as num?)
?.clamp(0, 10 * 60 * 1000)
.toInt() ??
realm.limits.authTimeoutMs;
final copy = Map<String, Object?>.from(options)..remove('method');
copy.remove('challenge_timeout_ms');
final rpcDelegate = copy.containsKey('rpc')
? RemoteWampDelegateConfig.parse(copy, realm)
: null;
copy.remove('rpc');
final delegateIds = rpcDelegate == null
? _parseDelegateIds(copy.remove('delegates'))
: const <String>[];
final allowedRoles = _parseStringSet(copy.remove('allowed_roles'));
final allowedProviders = _parseStringSet(copy.remove('allowed_providers'));
final fakeChallengeOnHelloFailure =
copy.remove('fake_challenge_on_hello_failure') != false;
final rateLimitMaxAttempts = _parsePositiveInt(
copy.remove('rate_limit_max_attempts'),
5,
);
final rateLimitWindowMs = _parsePositiveInt(
copy.remove('rate_limit_window_ms'),
10000,
);
final backoffBaseMs = _parsePositiveInt(
copy.remove('backoff_base_ms'),
500,
);
final backoffMaxMs = _parsePositiveInt(
copy.remove('backoff_max_ms'),
30000,
);
final backoffFactor = _parsePositiveDouble(
copy.remove('backoff_factor'),
2.0,
);
final delegateRetryMs = _parsePositiveInt(
copy.remove('delegate_retry_ms'),
5000,
);
return RemoteAuthenticatorConfig(
realm: realm,
options: Map<String, Object?>.unmodifiable(copy),
method: method,
delegateIds: delegateIds,
challengeTimeoutMs: timeoutMs,
allowedRoles: allowedRoles,
allowedProviders: allowedProviders,
fakeChallengeOnHelloFailure: fakeChallengeOnHelloFailure,
rpcDelegate: rpcDelegate,
rateLimitMaxAttempts: rateLimitMaxAttempts,
rateLimitWindowMs: rateLimitWindowMs,
backoffBaseMs: backoffBaseMs,
backoffFactor: backoffFactor,
backoffMaxMs: backoffMaxMs,
delegateRetryDelay: Duration(milliseconds: delegateRetryMs),
);
}