Skip to content

Commit 2105964

Browse files
committed
Disable App Platform authentication
1 parent fcfc92c commit 2105964

8 files changed

Lines changed: 110 additions & 1 deletion

File tree

src/Platforms/SecureFolderFS.Maui/Platforms/Android/ServiceImplementation/AndroidVaultCredentialsService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,18 @@ protected override async IAsyncEnumerable<AuthenticationViewModel> GetLoginAsync
4040
{
4141
yield return item switch
4242
{
43+
// Password
4344
Constants.Vault.Authentication.AUTH_PASSWORD => new PasswordLoginViewModel(),
45+
46+
// Key File
4447
Constants.Vault.Authentication.AUTH_KEYFILE => new KeyFileLoginViewModel(vaultFolder),
48+
49+
// Android Biometrics
4550
Constants.Vault.Authentication.AUTH_ANDROID_BIOMETRIC => new AndroidBiometricLoginViewModel(vaultFolder, vaultId),
51+
52+
// App Platform
53+
Constants.Vault.Authentication.AUTH_APP_PLATFORM => new AppPlatformLoginViewModel(),
54+
4655
_ => throw new NotSupportedException($"The authentication method '{item}' is not supported by the platform.")
4756
};
4857
}

src/Platforms/SecureFolderFS.Maui/Platforms/iOS/ServiceImplementation/IOSVaultCredentialsService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,24 @@ protected override async IAsyncEnumerable<AuthenticationViewModel> GetLoginAsync
4747
{
4848
yield return item switch
4949
{
50+
// Password
5051
Constants.Vault.Authentication.AUTH_PASSWORD => new PasswordLoginViewModel(),
52+
53+
// Key File
5154
Constants.Vault.Authentication.AUTH_KEYFILE => new KeyFileLoginViewModel(vaultFolder),
55+
56+
// Apple Biometrics
5257
Constants.Vault.Authentication.AUTH_APPLE_BIOMETRIC when AreBiometricsAvailable(out var biometryType) =>
5358
new IOSBiometricLoginViewModel(vaultFolder, vaultId, biometryType switch
5459
{
5560
LABiometryType.FaceId => "Face ID",
5661
LABiometryType.TouchId => "Touch ID",
5762
_ => string.Empty
5863
}),
64+
65+
// App Platform
66+
Constants.Vault.Authentication.AUTH_APP_PLATFORM => new AppPlatformLoginViewModel(),
67+
5968
_ => throw new NotSupportedException($"The authentication method '{item}' is not supported by the platform.")
6069
};
6170
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using SecureFolderFS.Sdk.Enums;
5+
using SecureFolderFS.Sdk.EventArguments;
6+
using SecureFolderFS.Sdk.ViewModels.Controls.Authentication;
7+
using SecureFolderFS.Shared.ComponentModel;
8+
9+
namespace SecureFolderFS.UI.ViewModels.Authentication
10+
{
11+
public sealed partial class AppPlatformLoginViewModel : AuthenticationViewModel
12+
{
13+
/// <inheritdoc/>
14+
public override event EventHandler<EventArgs>? StateChanged;
15+
16+
/// <inheritdoc/>
17+
public override event EventHandler<CredentialsProvidedEventArgs>? CredentialsProvided;
18+
19+
/// <inheritdoc/>
20+
public override bool CanComplement { get; } = false;
21+
22+
/// <inheritdoc/>
23+
public override AuthenticationStage Availability { get; } = AuthenticationStage.FirstStageOnly;
24+
25+
public AppPlatformLoginViewModel()
26+
: base(Core.Constants.Vault.Authentication.AUTH_APP_PLATFORM)
27+
{
28+
}
29+
30+
/// <inheritdoc/>
31+
public override Task RevokeAsync(string? id, CancellationToken cancellationToken = default)
32+
{
33+
return Task.FromException(new NotSupportedException());
34+
}
35+
36+
/// <inheritdoc/>
37+
public override Task<IResult<IKeyBytes>> EnrollAsync(string id, byte[]? data, CancellationToken cancellationToken = default)
38+
{
39+
return Task.FromException<IResult<IKeyBytes>>(new NotSupportedException());
40+
}
41+
42+
/// <inheritdoc/>
43+
public override Task<IResult<IKeyBytes>> AcquireAsync(string id, byte[]? data, CancellationToken cancellationToken = default)
44+
{
45+
return Task.FromException<IResult<IKeyBytes>>(new NotSupportedException());
46+
}
47+
48+
/// <inheritdoc/>
49+
protected override Task ProvideCredentialsAsync(CancellationToken cancellationToken)
50+
{
51+
return Task.CompletedTask;
52+
}
53+
}
54+
}

src/Platforms/SecureFolderFS.Uno/Platforms/Desktop/ServiceImplementation/SkiaVaultCredentialsService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,24 @@ protected override async IAsyncEnumerable<AuthenticationViewModel> GetLoginAsync
6262
{
6363
yield return item switch
6464
{
65+
// Password
6566
Constants.Vault.Authentication.AUTH_PASSWORD => new PasswordLoginViewModel() { Icon = new ImageGlyph("\uE8AC") },
67+
68+
// Yubikey
6669
Constants.Vault.Authentication.AUTH_YUBIKEY => new YubiKeyLoginViewModel(vaultFolder, vaultId) { Icon = new ImageGlyph("\uEE7E") },
70+
71+
// Key File
6772
Constants.Vault.Authentication.AUTH_KEYFILE => new KeyFileLoginViewModel(vaultFolder) { Icon = new ImageGlyph("\uE8D7") },
73+
74+
// Touch ID
6875
Constants.Vault.Authentication.AUTH_APPLE_MACOS => new MacOSBiometricsLoginViewModel(vaultFolder, vaultId),
76+
77+
// Device Link
6978
Constants.Vault.Authentication.AUTH_DEVICE_LINK => new DeviceLinkLoginViewModel(vaultFolder, vaultId).WithInitAsync(cancellationToken),
79+
80+
// App Platform
81+
Constants.Vault.Authentication.AUTH_APP_PLATFORM => new AppPlatformLoginViewModel(),
82+
7083
_ => throw new NotSupportedException($"The authentication method '{item}' is not supported by the platform.")
7184
};
7285
}

src/Platforms/SecureFolderFS.Uno/Platforms/Windows/ServiceImplementation/WindowsVaultCredentialsService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ protected override async IAsyncEnumerable<AuthenticationViewModel> GetLoginAsync
7373

7474
// Device Link
7575
Constants.Vault.Authentication.AUTH_DEVICE_LINK => new DeviceLinkLoginViewModel(vaultFolder, vaultId) { Icon = new ImageGlyph("\uE8EA") },
76+
77+
// App Platform
78+
Constants.Vault.Authentication.AUTH_APP_PLATFORM => new AppPlatformLoginViewModel(),
7679

7780
_ => throw new NotSupportedException($"The authentication method '{item}' is not supported by the platform.")
7881
};

src/Platforms/SecureFolderFS.Uno/TemplateSelectors/LoginTemplateSelector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ internal sealed class LoginTemplateSelector : BaseTemplateSelector<ObservableObj
2525
public DataTemplate? TouchIDTemplate { get; set; }
2626

2727
public DataTemplate? DeviceLinkTemplate { get; set; }
28+
29+
public DataTemplate? AppPlatformTemplate { get; set; }
2830

2931
public DataTemplate? MigrationTemplate { get; set; }
3032

@@ -50,6 +52,7 @@ internal sealed class LoginTemplateSelector : BaseTemplateSelector<ObservableObj
5052
MacOSBiometricsLoginViewModel => TouchIDTemplate,
5153
#endif
5254
DeviceLinkLoginViewModel => DeviceLinkTemplate,
55+
AppPlatformLoginViewModel => AppPlatformTemplate,
5356
PersistedAuthenticationViewModel => PersistedAuthenticationTemplate,
5457
MigrationViewModel => MigrationTemplate,
5558
ErrorViewModel => ErrorTemplate,

src/Platforms/SecureFolderFS.Uno/UserControls/LoginControl.xaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@
138138
</StackPanel>
139139
</DataTemplate>
140140

141+
<DataTemplate x:Key="AppPlatformTemplate" x:DataType="vm:AppPlatformLoginViewModel">
142+
<StackPanel Spacing="24">
143+
<!-- Icon -->
144+
<FontIcon
145+
HorizontalAlignment="Center"
146+
FontSize="24"
147+
Glyph="&#xF69B;" />
148+
149+
<!-- Info -->
150+
<InfoBar
151+
HorizontalAlignment="Center"
152+
IsClosable="False"
153+
IsOpen="True"
154+
Message="Authenticating with App Platform is not supported in this version. Please update SecureFolderFS."
155+
Severity="Warning" />
156+
</StackPanel>
157+
</DataTemplate>
158+
141159
<!-- Migration Template -->
142160
<DataTemplate x:Key="MigrationTemplate" x:DataType="vm5:MigrationViewModel">
143161
<StackPanel Spacing="4">
@@ -233,6 +251,7 @@
233251
IsTabStop="False">
234252
<ContentControl.ContentTemplateSelector>
235253
<ts:LoginTemplateSelector
254+
AppPlatformTemplate="{StaticResource AppPlatformTemplate}"
236255
DeviceLinkTemplate="{StaticResource DeviceLinkTemplate}"
237256
ErrorTemplate="{StaticResource ErrorTemplate}"
238257
KeyFileTemplate="{StaticResource KeyFileTemplate}"

src/Platforms/SecureFolderFS.Uno/UserControls/LoginOptions.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<CheckBox
2020
Content="{l:ResourceString Rid=SaveCredentials}"
2121
IsChecked="{x:Bind ShouldSaveCredentials, Mode=TwoWay}"
22-
IsEnabled="False"
2322
Visibility="{x:Bind AreCredentialsSaved, Mode=OneWay, Converter={StaticResource BoolInvertConverter}}" />
2423

2524
<Button

0 commit comments

Comments
 (0)