mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(web,server): disable password login (#1223)
* feat(web,server): disable password login * chore: unit tests * chore: fix import * chore: linting * feat(cli): server command for enable/disable password login * chore: update docs * feat(web): confirm dialogue * chore: linting * chore: linting * chore: linting * chore: linting * chore: linting * chore: fix web test * chore: server unit tests
This commit is contained in:
@@ -14,12 +14,16 @@ class OAuthConfigResponseDto {
|
||||
/// Returns a new [OAuthConfigResponseDto] instance.
|
||||
OAuthConfigResponseDto({
|
||||
required this.enabled,
|
||||
required this.passwordLoginEnabled,
|
||||
this.url,
|
||||
this.buttonText,
|
||||
this.autoLaunch,
|
||||
});
|
||||
|
||||
bool enabled;
|
||||
|
||||
bool passwordLoginEnabled;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
@@ -36,25 +40,38 @@ class OAuthConfigResponseDto {
|
||||
///
|
||||
String? buttonText;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
bool? autoLaunch;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is OAuthConfigResponseDto &&
|
||||
other.enabled == enabled &&
|
||||
other.passwordLoginEnabled == passwordLoginEnabled &&
|
||||
other.url == url &&
|
||||
other.buttonText == buttonText;
|
||||
other.buttonText == buttonText &&
|
||||
other.autoLaunch == autoLaunch;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(enabled.hashCode) +
|
||||
(passwordLoginEnabled.hashCode) +
|
||||
(url == null ? 0 : url!.hashCode) +
|
||||
(buttonText == null ? 0 : buttonText!.hashCode);
|
||||
(buttonText == null ? 0 : buttonText!.hashCode) +
|
||||
(autoLaunch == null ? 0 : autoLaunch!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'OAuthConfigResponseDto[enabled=$enabled, url=$url, buttonText=$buttonText]';
|
||||
String toString() => 'OAuthConfigResponseDto[enabled=$enabled, passwordLoginEnabled=$passwordLoginEnabled, url=$url, buttonText=$buttonText, autoLaunch=$autoLaunch]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'enabled'] = enabled;
|
||||
_json[r'passwordLoginEnabled'] = passwordLoginEnabled;
|
||||
if (url != null) {
|
||||
_json[r'url'] = url;
|
||||
} else {
|
||||
@@ -65,6 +82,11 @@ class OAuthConfigResponseDto {
|
||||
} else {
|
||||
_json[r'buttonText'] = null;
|
||||
}
|
||||
if (autoLaunch != null) {
|
||||
_json[r'autoLaunch'] = autoLaunch;
|
||||
} else {
|
||||
_json[r'autoLaunch'] = null;
|
||||
}
|
||||
return _json;
|
||||
}
|
||||
|
||||
@@ -88,8 +110,10 @@ class OAuthConfigResponseDto {
|
||||
|
||||
return OAuthConfigResponseDto(
|
||||
enabled: mapValueOfType<bool>(json, r'enabled')!,
|
||||
passwordLoginEnabled: mapValueOfType<bool>(json, r'passwordLoginEnabled')!,
|
||||
url: mapValueOfType<String>(json, r'url'),
|
||||
buttonText: mapValueOfType<String>(json, r'buttonText'),
|
||||
autoLaunch: mapValueOfType<bool>(json, r'autoLaunch'),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
@@ -140,6 +164,7 @@ class OAuthConfigResponseDto {
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'enabled',
|
||||
'passwordLoginEnabled',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class SharedLinkResponseDto {
|
||||
|
||||
String? expiresAt;
|
||||
|
||||
List<String> assets;
|
||||
List<AssetResponseDto> assets;
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
@@ -140,9 +140,7 @@ class SharedLinkResponseDto {
|
||||
key: mapValueOfType<String>(json, r'key')!,
|
||||
createdAt: mapValueOfType<String>(json, r'createdAt')!,
|
||||
expiresAt: mapValueOfType<String>(json, r'expiresAt'),
|
||||
assets: json[r'assets'] is List
|
||||
? (json[r'assets'] as List).cast<String>()
|
||||
: const [],
|
||||
assets: AssetResponseDto.listFromJson(json[r'assets'])!,
|
||||
album: AlbumResponseDto.fromJson(json[r'album']),
|
||||
allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,
|
||||
);
|
||||
|
||||
10
mobile/openapi/lib/model/system_config_dto.dart
generated
10
mobile/openapi/lib/model/system_config_dto.dart
generated
@@ -15,6 +15,7 @@ class SystemConfigDto {
|
||||
SystemConfigDto({
|
||||
required this.ffmpeg,
|
||||
required this.oauth,
|
||||
required this.passwordLogin,
|
||||
required this.storageTemplate,
|
||||
});
|
||||
|
||||
@@ -22,12 +23,15 @@ class SystemConfigDto {
|
||||
|
||||
SystemConfigOAuthDto oauth;
|
||||
|
||||
SystemConfigPasswordLoginDto passwordLogin;
|
||||
|
||||
SystemConfigStorageTemplateDto storageTemplate;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is SystemConfigDto &&
|
||||
other.ffmpeg == ffmpeg &&
|
||||
other.oauth == oauth &&
|
||||
other.passwordLogin == passwordLogin &&
|
||||
other.storageTemplate == storageTemplate;
|
||||
|
||||
@override
|
||||
@@ -35,15 +39,17 @@ class SystemConfigDto {
|
||||
// ignore: unnecessary_parenthesis
|
||||
(ffmpeg.hashCode) +
|
||||
(oauth.hashCode) +
|
||||
(passwordLogin.hashCode) +
|
||||
(storageTemplate.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, oauth=$oauth, storageTemplate=$storageTemplate]';
|
||||
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, oauth=$oauth, passwordLogin=$passwordLogin, storageTemplate=$storageTemplate]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'ffmpeg'] = ffmpeg;
|
||||
_json[r'oauth'] = oauth;
|
||||
_json[r'passwordLogin'] = passwordLogin;
|
||||
_json[r'storageTemplate'] = storageTemplate;
|
||||
return _json;
|
||||
}
|
||||
@@ -69,6 +75,7 @@ class SystemConfigDto {
|
||||
return SystemConfigDto(
|
||||
ffmpeg: SystemConfigFFmpegDto.fromJson(json[r'ffmpeg'])!,
|
||||
oauth: SystemConfigOAuthDto.fromJson(json[r'oauth'])!,
|
||||
passwordLogin: SystemConfigPasswordLoginDto.fromJson(json[r'passwordLogin'])!,
|
||||
storageTemplate: SystemConfigStorageTemplateDto.fromJson(json[r'storageTemplate'])!,
|
||||
);
|
||||
}
|
||||
@@ -121,6 +128,7 @@ class SystemConfigDto {
|
||||
static const requiredKeys = <String>{
|
||||
'ffmpeg',
|
||||
'oauth',
|
||||
'passwordLogin',
|
||||
'storageTemplate',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class SystemConfigOAuthDto {
|
||||
required this.scope,
|
||||
required this.buttonText,
|
||||
required this.autoRegister,
|
||||
required this.autoLaunch,
|
||||
required this.mobileOverrideEnabled,
|
||||
required this.mobileRedirectUri,
|
||||
});
|
||||
@@ -38,6 +39,8 @@ class SystemConfigOAuthDto {
|
||||
|
||||
bool autoRegister;
|
||||
|
||||
bool autoLaunch;
|
||||
|
||||
bool mobileOverrideEnabled;
|
||||
|
||||
String mobileRedirectUri;
|
||||
@@ -51,6 +54,7 @@ class SystemConfigOAuthDto {
|
||||
other.scope == scope &&
|
||||
other.buttonText == buttonText &&
|
||||
other.autoRegister == autoRegister &&
|
||||
other.autoLaunch == autoLaunch &&
|
||||
other.mobileOverrideEnabled == mobileOverrideEnabled &&
|
||||
other.mobileRedirectUri == mobileRedirectUri;
|
||||
|
||||
@@ -64,11 +68,12 @@ class SystemConfigOAuthDto {
|
||||
(scope.hashCode) +
|
||||
(buttonText.hashCode) +
|
||||
(autoRegister.hashCode) +
|
||||
(autoLaunch.hashCode) +
|
||||
(mobileOverrideEnabled.hashCode) +
|
||||
(mobileRedirectUri.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'SystemConfigOAuthDto[enabled=$enabled, issuerUrl=$issuerUrl, clientId=$clientId, clientSecret=$clientSecret, scope=$scope, buttonText=$buttonText, autoRegister=$autoRegister, mobileOverrideEnabled=$mobileOverrideEnabled, mobileRedirectUri=$mobileRedirectUri]';
|
||||
String toString() => 'SystemConfigOAuthDto[enabled=$enabled, issuerUrl=$issuerUrl, clientId=$clientId, clientSecret=$clientSecret, scope=$scope, buttonText=$buttonText, autoRegister=$autoRegister, autoLaunch=$autoLaunch, mobileOverrideEnabled=$mobileOverrideEnabled, mobileRedirectUri=$mobileRedirectUri]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
@@ -79,6 +84,7 @@ class SystemConfigOAuthDto {
|
||||
_json[r'scope'] = scope;
|
||||
_json[r'buttonText'] = buttonText;
|
||||
_json[r'autoRegister'] = autoRegister;
|
||||
_json[r'autoLaunch'] = autoLaunch;
|
||||
_json[r'mobileOverrideEnabled'] = mobileOverrideEnabled;
|
||||
_json[r'mobileRedirectUri'] = mobileRedirectUri;
|
||||
return _json;
|
||||
@@ -110,6 +116,7 @@ class SystemConfigOAuthDto {
|
||||
scope: mapValueOfType<String>(json, r'scope')!,
|
||||
buttonText: mapValueOfType<String>(json, r'buttonText')!,
|
||||
autoRegister: mapValueOfType<bool>(json, r'autoRegister')!,
|
||||
autoLaunch: mapValueOfType<bool>(json, r'autoLaunch')!,
|
||||
mobileOverrideEnabled: mapValueOfType<bool>(json, r'mobileOverrideEnabled')!,
|
||||
mobileRedirectUri: mapValueOfType<String>(json, r'mobileRedirectUri')!,
|
||||
);
|
||||
@@ -168,6 +175,7 @@ class SystemConfigOAuthDto {
|
||||
'scope',
|
||||
'buttonText',
|
||||
'autoRegister',
|
||||
'autoLaunch',
|
||||
'mobileOverrideEnabled',
|
||||
'mobileRedirectUri',
|
||||
};
|
||||
|
||||
111
mobile/openapi/lib/model/system_config_password_login_dto.dart
generated
Normal file
111
mobile/openapi/lib/model/system_config_password_login_dto.dart
generated
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class SystemConfigPasswordLoginDto {
|
||||
/// Returns a new [SystemConfigPasswordLoginDto] instance.
|
||||
SystemConfigPasswordLoginDto({
|
||||
required this.enabled,
|
||||
});
|
||||
|
||||
bool enabled;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is SystemConfigPasswordLoginDto &&
|
||||
other.enabled == enabled;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(enabled.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'SystemConfigPasswordLoginDto[enabled=$enabled]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final _json = <String, dynamic>{};
|
||||
_json[r'enabled'] = enabled;
|
||||
return _json;
|
||||
}
|
||||
|
||||
/// Returns a new [SystemConfigPasswordLoginDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static SystemConfigPasswordLoginDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "SystemConfigPasswordLoginDto[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "SystemConfigPasswordLoginDto[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return SystemConfigPasswordLoginDto(
|
||||
enabled: mapValueOfType<bool>(json, r'enabled')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<SystemConfigPasswordLoginDto>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <SystemConfigPasswordLoginDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = SystemConfigPasswordLoginDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, SystemConfigPasswordLoginDto> mapFromJson(dynamic json) {
|
||||
final map = <String, SystemConfigPasswordLoginDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = SystemConfigPasswordLoginDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of SystemConfigPasswordLoginDto-objects as value to a dart map
|
||||
static Map<String, List<SystemConfigPasswordLoginDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<SystemConfigPasswordLoginDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = SystemConfigPasswordLoginDto.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'enabled',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user