mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-25 12:05:59 +01:00
PM-5154 Added Fido2AuthenticationService to provide us a wrapper for the actual implementation
This commit is contained in:
parent
1eb9e5f8ea
commit
dfb7a0621f
9
src/Core/Abstractions/IFido2AuthenticationService.cs
Normal file
9
src/Core/Abstractions/IFido2AuthenticationService.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Bit.Core.Utilities.Fido2;
|
||||
|
||||
namespace Bit.Core.Abstractions
|
||||
{
|
||||
public interface IFido2AuthenticationService
|
||||
{
|
||||
Task<Fido2AuthenticatorGetAssertionResult> GetAssertionAsync(Fido2AuthenticatorGetAssertionParams assertionParams);
|
||||
}
|
||||
}
|
@ -73,6 +73,7 @@
|
||||
<Folder Include="Utilities\Automation\" />
|
||||
<Folder Include="Utilities\Prompts\" />
|
||||
<Folder Include="Resources\Localization\" />
|
||||
<Folder Include="Utilities\Fido2\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MauiImage Include="Resources\Images\dotnet_bot.svg">
|
||||
@ -100,4 +101,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Utilities\Fido2\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
18
src/Core/Services/Fido2AuthenticationService.cs
Normal file
18
src/Core/Services/Fido2AuthenticationService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities.Fido2;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public class Fido2AuthenticationService : IFido2AuthenticationService
|
||||
{
|
||||
public Task<Fido2AuthenticatorGetAssertionResult> GetAssertionAsync(Fido2AuthenticatorGetAssertionParams assertionParams)
|
||||
{
|
||||
// TODO: IMPLEMENT this
|
||||
return Task.FromResult(new Fido2AuthenticatorGetAssertionResult
|
||||
{
|
||||
AuthenticatorData = new byte[32],
|
||||
Signature = new byte[8]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Bit.Core.Utilities.Fido2
|
||||
{
|
||||
public class Fido2AuthenticatorGetAssertionParams
|
||||
{
|
||||
public string RpId { get; set; }
|
||||
|
||||
public string CredentialId { get; set; }
|
||||
|
||||
public string Counter { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
namespace Bit.Core.Utilities.Fido2
|
||||
{
|
||||
public class Fido2AuthenticatorGetAssertionResult
|
||||
{
|
||||
public byte[] AuthenticatorData { get; set; }
|
||||
|
||||
public byte[] Signature { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Services;
|
||||
|
||||
@ -118,6 +115,7 @@ namespace Bit.Core.Utilities
|
||||
Register<IUsernameGenerationService>(usernameGenerationService);
|
||||
Register<IDeviceTrustCryptoService>(deviceTrustCryptoService);
|
||||
Register<IPasswordResetEnrollmentService>(passwordResetEnrollmentService);
|
||||
Register<IFido2AuthenticationService>(new Fido2AuthenticationService());
|
||||
}
|
||||
|
||||
public static void Register<T>(string serviceName, T obj)
|
||||
|
@ -25,7 +25,7 @@ namespace Bit.iOS.Autofill
|
||||
await ProvideCredentialAsync(false);
|
||||
}
|
||||
|
||||
public void CompleteAssertionRequest(CipherView cipherView)
|
||||
public async Task CompleteAssertionRequestAsync(CipherView cipherView)
|
||||
{
|
||||
if (!UIDevice.CurrentDevice.CheckSystemVersion(17, 0))
|
||||
{
|
||||
@ -34,12 +34,19 @@ namespace Bit.iOS.Autofill
|
||||
}
|
||||
|
||||
// TODO: Generate the credential Signature and Auth data accordingly
|
||||
var fido2AssertionResult = await _fido2AuthService.Value.GetAssertionAsync(new Bit.Core.Utilities.Fido2.Fido2AuthenticatorGetAssertionParams
|
||||
{
|
||||
RpId = cipherView.Login.MainFido2Credential.RpId,
|
||||
Counter = cipherView.Login.MainFido2Credential.Counter,
|
||||
CredentialId = cipherView.Login.MainFido2Credential.CredentialId
|
||||
});
|
||||
|
||||
CompleteAssertionRequest(new ASPasskeyAssertionCredential(
|
||||
cipherView.Login.MainFido2Credential.UserHandle,
|
||||
cipherView.Login.MainFido2Credential.RpId,
|
||||
"TODO: Generate Signature",
|
||||
NSData.FromArray(fido2AssertionResult.Signature),
|
||||
_context.PasskeyCredentialRequest?.ClientDataHash,
|
||||
"TODO: Generate Authenticator Data",
|
||||
NSData.FromArray(fido2AssertionResult.AuthenticatorData),
|
||||
cipherView.Login.MainFido2Credential.CredentialId
|
||||
));
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace Bit.iOS.Autofill
|
||||
private IAccountsManager _accountsManager;
|
||||
|
||||
private readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>();
|
||||
private readonly LazyResolve<IFido2AuthenticationService> _fido2AuthService = new LazyResolve<IFido2AuthenticationService>();
|
||||
|
||||
public CredentialProviderViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
@ -411,7 +412,7 @@ namespace Bit.iOS.Autofill
|
||||
|
||||
if (_context.IsPasskey)
|
||||
{
|
||||
CompleteAssertionRequest(decCipher);
|
||||
await CompleteAssertionRequestAsync(decCipher);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user