Browse Source

nextcloud,specs: Adapt to per operation security

pull/232/head
jld3103 2 years ago
parent
commit
97965e2043
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 10
      packages/nextcloud/lib/src/client.dart
  2. 321
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  3. 1
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 1
      packages/nextcloud/lib/src/webdav/client.dart
  5. 1
      specs/core.json

10
packages/nextcloud/lib/src/client.dart

@ -20,12 +20,14 @@ class NextcloudClient extends openapi.NextcloudClient {
}..removeWhere((final _, final value) => value == null)) }..removeWhere((final _, final value) => value == null))
.cast<String, String>(), .cast<String, String>(),
userAgent: userAgentOverride ?? appType.userAgent, userAgent: userAgentOverride ?? appType.userAgent,
authentication: loginName != null && password != null authentications: [
? openapi.NextcloudHttpBasicAuthentication( if (loginName != null && password != null) ...[
openapi.NextcloudHttpBasicAuthentication(
username: loginName, username: loginName,
password: password, password: password,
) ),
: null, ],
],
); );
/// Identifier used for authentication. This can be the username or email or something else. /// Identifier used for authentication. This can be the username or email or something else.

321
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -71,6 +71,7 @@ class NextcloudApiException extends _Response implements Exception {
} }
abstract class NextcloudAuthentication { abstract class NextcloudAuthentication {
String get id;
Map<String, String> get headers; Map<String, String> get headers;
} }
@ -84,6 +85,9 @@ class NextcloudHttpBasicAuthentication extends NextcloudAuthentication {
final String password; final String password;
@override
String get id => 'basic_auth';
@override
Map<String, String> get headers => { Map<String, String> get headers => {
'Authorization': 'Basic ${base64.encode(utf8.encode('$username:$password'))}', 'Authorization': 'Basic ${base64.encode(utf8.encode('$username:$password'))}',
}; };
@ -96,15 +100,12 @@ class NextcloudClient {
String? userAgent, String? userAgent,
HttpClient? httpClient, HttpClient? httpClient,
this.cookieJar, this.cookieJar,
this.authentication, this.authentications = const [],
}) { }) {
this.baseHeaders = { this.baseHeaders = {
if (baseHeaders != null) ...{ if (baseHeaders != null) ...{
...baseHeaders, ...baseHeaders,
}, },
if (authentication != null) ...{
...authentication!.headers,
},
}; };
this.httpClient = (httpClient ?? HttpClient())..userAgent = userAgent; this.httpClient = (httpClient ?? HttpClient())..userAgent = userAgent;
} }
@ -117,7 +118,7 @@ class NextcloudClient {
final CookieJar? cookieJar; final CookieJar? cookieJar;
final NextcloudAuthentication? authentication; final List<NextcloudAuthentication> authentications;
Future<_Response> doRequest( Future<_Response> doRequest(
String method, String method,
@ -193,6 +194,11 @@ class NextcloudCoreClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -213,6 +219,11 @@ class NextcloudCoreClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -233,6 +244,11 @@ class NextcloudCoreClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -253,6 +269,11 @@ class NextcloudCoreClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['token'] = token; queryParameters['token'] = token;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -281,6 +302,11 @@ class NextcloudCoreClient {
'Accept': 'image/png', 'Accept': 'image/png',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (file != '') { if (file != '') {
queryParameters['file'] = file; queryParameters['file'] = file;
} }
@ -321,6 +347,11 @@ class NextcloudCoreClient {
'Accept': 'image/png', 'Accept': 'image/png',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -345,6 +376,11 @@ class NextcloudCoreClient {
'Accept': 'image/png', 'Accept': 'image/png',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString())); path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -373,6 +409,11 @@ class NextcloudCoreClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['search'] = search; queryParameters['search'] = search;
queryParameters['itemType'] = itemType; queryParameters['itemType'] = itemType;
queryParameters['itemId'] = itemId; queryParameters['itemId'] = itemId;
@ -409,6 +450,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -429,6 +475,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -449,6 +500,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['name'] = name; queryParameters['name'] = name;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -471,6 +527,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString()));
queryParameters['name'] = name; queryParameters['name'] = name;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -490,6 +551,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -511,6 +577,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString())); path = path.replaceAll('{folderId}', Uri.encodeQueryComponent(folderId.toString()));
queryParameters['newestItemId'] = newestItemId.toString(); queryParameters['newestItemId'] = newestItemId.toString();
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -532,6 +603,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -554,6 +630,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['url'] = url; queryParameters['url'] = url;
if (folderId != null) { if (folderId != null) {
queryParameters['folderId'] = folderId.toString(); queryParameters['folderId'] = folderId.toString();
@ -575,6 +656,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -596,6 +682,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
if (folderId != null) { if (folderId != null) {
queryParameters['folderId'] = folderId.toString(); queryParameters['folderId'] = folderId.toString();
@ -620,6 +711,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
queryParameters['feedTitle'] = feedTitle; queryParameters['feedTitle'] = feedTitle;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -642,6 +738,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString())); path = path.replaceAll('{feedId}', Uri.encodeQueryComponent(feedId.toString()));
queryParameters['newestItemId'] = newestItemId.toString(); queryParameters['newestItemId'] = newestItemId.toString();
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -670,6 +771,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (type != 3) { if (type != 3) {
queryParameters['type'] = type.toString(); queryParameters['type'] = type.toString();
} }
@ -712,6 +818,11 @@ class NextcloudNewsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (type != 3) { if (type != 3) {
queryParameters['type'] = type.toString(); queryParameters['type'] = type.toString();
} }
@ -739,6 +850,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -757,6 +873,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -775,6 +896,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -793,6 +919,11 @@ class NextcloudNewsClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString())); path = path.replaceAll('{itemId}', Uri.encodeQueryComponent(itemId.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -826,6 +957,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (category != null) { if (category != null) {
queryParameters['category'] = category; queryParameters['category'] = category;
} }
@ -871,6 +1007,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (category != '') { if (category != '') {
queryParameters['category'] = category; queryParameters['category'] = category;
} }
@ -909,6 +1050,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
if (exclude != '') { if (exclude != '') {
queryParameters['exclude'] = exclude; queryParameters['exclude'] = exclude;
@ -943,6 +1089,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
if (content != null) { if (content != null) {
queryParameters['content'] = content; queryParameters['content'] = content;
@ -981,6 +1132,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -1001,6 +1157,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1020,6 +1181,11 @@ class NextcloudNotesClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
headers['Content-Type'] = 'application/json'; headers['Content-Type'] = 'application/json';
body = Uint8List.fromList(utf8.encode(json.encode(notesSettings.toJson()))); body = Uint8List.fromList(utf8.encode(json.encode(notesSettings.toJson())));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -1047,6 +1213,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1067,6 +1238,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1086,6 +1262,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
@ -1107,6 +1288,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString())); path = path.replaceAll('{id}', Uri.encodeQueryComponent(id.toString()));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -1131,6 +1317,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['pushTokenHash'] = pushTokenHash; queryParameters['pushTokenHash'] = pushTokenHash;
queryParameters['devicePublicKey'] = devicePublicKey; queryParameters['devicePublicKey'] = devicePublicKey;
queryParameters['proxyServer'] = proxyServer; queryParameters['proxyServer'] = proxyServer;
@ -1154,6 +1345,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1177,6 +1373,11 @@ class NextcloudNotificationsClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
queryParameters['shortMessage'] = shortMessage; queryParameters['shortMessage'] = shortMessage;
if (longMessage != '') { if (longMessage != '') {
@ -1207,6 +1408,11 @@ class NextcloudProvisioningApiClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1227,6 +1433,11 @@ class NextcloudProvisioningApiClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
@ -1255,6 +1466,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1279,6 +1495,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['keepalive'] = keepalive.toString(); queryParameters['keepalive'] = keepalive.toString();
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'put', 'put',
@ -1302,6 +1523,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['deviceName'] = deviceName; queryParameters['deviceName'] = deviceName;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'put', 'put',
@ -1327,6 +1553,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
@ -1350,6 +1581,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId)); path = path.replaceAll('{deviceId}', Uri.encodeQueryComponent(deviceId));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -1375,6 +1611,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['deviceId'] = deviceId; queryParameters['deviceId'] = deviceId;
queryParameters['appName'] = appName; queryParameters['appName'] = appName;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
@ -1398,6 +1639,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); path = path.replaceAll('{token}', Uri.encodeQueryComponent(token));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
@ -1421,6 +1667,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); path = path.replaceAll('{token}', Uri.encodeQueryComponent(token));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
@ -1443,6 +1694,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{token}', Uri.encodeQueryComponent(token)); path = path.replaceAll('{token}', Uri.encodeQueryComponent(token));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
@ -1465,6 +1721,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1486,6 +1747,11 @@ class NextcloudUnifiedPushProviderClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'post', 'post',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1512,6 +1778,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1532,6 +1803,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId)); path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId));
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
@ -1553,6 +1829,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1573,6 +1854,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['statusType'] = statusType.value; queryParameters['statusType'] = statusType.value;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'put', 'put',
@ -1597,6 +1883,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['messageId'] = messageId; queryParameters['messageId'] = messageId;
if (clearAt != null) { if (clearAt != null) {
queryParameters['clearAt'] = clearAt.toString(); queryParameters['clearAt'] = clearAt.toString();
@ -1625,6 +1916,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
if (statusIcon != null) { if (statusIcon != null) {
queryParameters['statusIcon'] = statusIcon; queryParameters['statusIcon'] = statusIcon;
} }
@ -1652,6 +1948,11 @@ class NextcloudUserStatusClient {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'delete', 'delete',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1671,6 +1972,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'get', 'get',
Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(), Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null).toString(),
@ -1691,6 +1997,11 @@ class NextcloudUserStatusClient {
'Accept': 'application/json', 'Accept': 'application/json',
}; };
Uint8List? body; Uint8List? body;
if (rootClient.authentications.map((final a) => a.id).contains('basic_auth')) {
headers.addAll(rootClient.authentications.singleWhere((final a) => a.id == 'basic_auth').headers);
} else {
throw Exception('Missing authentication for basic_auth');
}
queryParameters['status'] = status.value; queryParameters['status'] = status.value;
final response = await rootClient.doRequest( final response = await rootClient.doRequest(
'put', 'put',

1
packages/nextcloud/lib/src/nextcloud.openapi.json

@ -2008,6 +2008,7 @@
"tags": [ "tags": [
"core" "core"
], ],
"security": [],
"responses": { "responses": {
"200": { "200": {
"description": "Status of the Nextcloud instance", "description": "Status of the Nextcloud instance",

1
packages/nextcloud/lib/src/webdav/client.dart

@ -43,6 +43,7 @@ class WebDavClient {
HttpHeaders.contentTypeHeader: 'application/xml', HttpHeaders.contentTypeHeader: 'application/xml',
...rootClient.baseHeaders, ...rootClient.baseHeaders,
if (headers != null) ...headers, if (headers != null) ...headers,
if (rootClient.authentications.isNotEmpty) ...rootClient.authentications.first.headers,
}.entries) { }.entries) {
request.headers.add(header.key, header.value); request.headers.add(header.key, header.value);
} }

1
specs/core.json

@ -982,6 +982,7 @@
"tags": [ "tags": [
"core" "core"
], ],
"security": [],
"responses": { "responses": {
"200": { "200": {
"description": "Status of the Nextcloud instance", "description": "Status of the Nextcloud instance",

Loading…
Cancel
Save