flutter-institute / webauthn

A plugin to handle webauthn login
BSD 3-Clause "New" or "Revised" License
15 stars 7 forks source link

Unable to Run Example: MissingPluginException #1

Closed AkanshDivker closed 1 year ago

AkanshDivker commented 1 year ago

I'm trying to get started with this package but I'm unable to get the example running. After cloning the repository, I ran the tests and they all passed. However, when I try and run the example project I get a MissingPluginException when trying to register. I have tried running flutter clean before running the example but the issue still persists. I hope I'm not missing any steps or instructions, I believe all compatibility requirements are being met.

Platform: Windows 11 Error: MissingPluginException (MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite))

Would appreciate any help, thanks!

Console Log

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
<asynchronous suspension>
#1      wrapDatabaseException (package:sqflite/src/exception_impl.dart:7:20)
<asynchronous suspension>
#2      SqfliteDatabaseFactoryMixin.getDatabasesPath (package:sqflite_common/src/factory_mixin.dart:151:20)
<asynchronous suspension>
#3      DB._getDirectory (package:webauthn/src/db/db.dart:64:29)
<asynchronous suspension>
#4      DB._getDbPath (package:webauthn/src/db/db.dart:60:17)
<asynchronous suspension>
#5      DB.open (package:webauthn/src/db/db.dart:44:12)
<asynchronous suspension>
#6      DBSchema.execute (package:webauthn/src/db/schema.dart:38:20)
<asynchronous suspension>
#7      CredentialSchema._getOne (package:webauthn/src/db/credential.dart:194:21)
<asynchronous suspension>
#8      Authenticator.makeCredential (package:webauthn/src/authenticator.dart:115:13)
<asynchronous suspension>
#9      _MyHomePageState._createCredential.<anonymous closure> (package:webauthnexample/main.dart:128:29)
<asynchronous suspension>
#10     _MyHomePageState._lockAndExecute (package:webauthnexample/main.dart:98:18)
<asynchronous suspension>
#11     _MyHomePageState._createCredential (package:webauthnexample/main.dart:117:26)
<asynchronous suspension>
killermonk commented 1 year ago

Hey @AkanshDivker, this is an issue with the sqflite plugin being used (https://pub.dev/packages/sqflite). Sqflite only supports iOS, Android, and MacOS.

For Windows/Linux/DartVM support, you'd need to convert things over to use Sqflite Common FFI (https://pub.dev/packages/sqflite_common_ffi)

Since I was targeting this at iOS/Android and developing on a Mac, I didn't notice this shortcoming.

To be honest, sqlite is a temporary solution for the needs of the authenticator. It is being used to store the keypairs that are generated for each request, and this isn't as secure as things should be. The real fix for this is to get a plugin working that allows the app to use the device's keychain/keystore as the datastore for the keypairs. I just haven't had time.

Can you try to update your local version to use the Common FFI plugin listed above and let me know if that works for your needs?

AkanshDivker commented 1 year ago

Thanks for the information! I did some more digging and found out that for Linux and Windows some extra initialization code is necessary in the main method. I've created a pull request which includes a fix, hope it's all fine and good!

But yes I do agree that storing credentials in the device keychain/keystore is a more optimal solution. Hopefully that can come around soon.

2

killermonk commented 1 year ago

Have merged PR #2. Thank you so much!