WebDavAuthenticationConfig constructor
WebDavAuthenticationConfig({})
Validates and normalizes the credential scope and discovery settings.
Opens no connection. To skip discovery for a known Basic server:
final authentication = WebDavAuthenticationConfig(
scope: Uri.parse('https://example.com/dav/'),
username: 'user',
password: 'app-password',
mode: WebDavAuthenticationMode.basic,
);
Throws ArgumentError for invalid settings and
WebDavAuthenticationError when probeUri lies outside scope.
Implementation
WebDavAuthenticationConfig({
required Uri scope,
Uri? probeUri,
required this.username,
required this.password,
this.mode = WebDavAuthenticationMode.auto,
this.allowInsecureBasic = false,
this.discoveryTimeout = const Duration(seconds: 30),
}) : scope = scope.normalizePath(),
probeUri = (probeUri ?? scope).normalizePath() {
if (!scope.isAbsolute ||
!const ['http', 'https'].contains(scope.scheme) ||
scope.host.isEmpty ||
scope.userInfo.isNotEmpty ||
scope.hasQuery ||
scope.hasFragment ||
!scope.path.endsWith('/') ||
discoveryTimeout <= Duration.zero) {
throw ArgumentError(
'Authentication requires an HTTP(S) directory scope '
'and a positive discovery timeout.',
);
}
_checkUri(this.probeUri);
if (username.contains(':')) {
throw ArgumentError(
'A Basic authentication username cannot contain ":".',
);
}
}