-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[local_auth] Implemented plugin to support local auth in macOS #5766
[local_auth] Implemented plugin to support local auth in macOS #5766
Conversation
Per the comment in flutter/flutter#140685, the first step here would need to be a package rename; we wouldn't accept this as-is since it duplicates a significant amount of code. Marking this as a draft pending a prequel PR to rename the package. |
@OutdatedGuy thanks for contributing to this! An example of what @stuartmorgan is asking for (sharing between the platforms instead of copying) was done for path_provider and shared_preferences, as he mentioned in flutter/flutter#140685 (comment) Examples: |
Aahhh, now I get it. @jmagman so what should I rename it to? |
|
Note that those are a single PR for each plugin because we were merging existing implementations for two platforms, which is not the case for |
I guess |
@jmagman Questions while renaming:
|
No; there is no reason to expect that strings would be the same. The default message "Biometric authentication is not set up on your device. Please either enable Touch ID or Face ID on your phone.", for instance, would make no sense on macOS.
Yes.
No. Pigeon communication in internal to the plugin, and should be largely, if not entirely, identical.
It's not clear to me what this is referring to. I would not expect there to need to be two of anything in the
It's not a new package, it's a renaming of an existing package. The authorship of all the existing code you would be moving has not changed. You're welcome to add yourself, as with any PR to a package. |
@stuartmorgan can you tell me what is exactly failing and how to solve it. Also can you add the |
The project's unit tests appear to be configured incorrectly; I'll take a look in Xcode.
Which of the linked exemptions do you believe that this falls under? And why would you not want people to be able to use the macOS implementation? |
The unit test file had not been added to the macOS project, so it couldn't build anything. I've pushed a fix. |
@@ -156,6 +156,28 @@ - (void)showAlertWithMessage:(NSString *)message | |||
dismissButtonTitle:(NSString *)dismissButtonTitle | |||
openSettingsButtonTitle:(NSString *)openSettingsButtonTitle | |||
completion:(FLAAuthCompletion)completion { | |||
#if TARGET_OS_OSX | |||
NSAlert *alert = [[NSAlert alloc] init]; | |||
[alert setMessageText:@""]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this line actually do anything? What's the default value?
if (openSettingsButtonTitle != nil) { | ||
[alert addButtonWithTitle:openSettingsButtonTitle]; | ||
[alert setShowsHelp:YES]; | ||
[alert setHelpAnchor:@"OpenSettings"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this magic string come from; is there a default system help anchor with this name? This needs a code comment explaining it.
} | ||
[alert addButtonWithTitle:dismissButtonTitle]; | ||
|
||
NSModalResponse response = [alert runModal]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use beginSheetModalForWindow:completionHandler:
with the window obtained from the registrar
, and handleSucceeded:
should be called from the completion.
You'll nee do adjust the plugin's init
methods to take the registrar from registerWithRegistrar:
and keep a reference to it.
@@ -260,7 +283,12 @@ - (void)handleError:(NSError *)authError | |||
|
|||
#pragma mark - AppDelegate | |||
|
|||
- (void)applicationDidBecomeActive:(UIApplication *)application { | |||
#if TARGET_OS_OSX | |||
- (void)applicationDidBecomeActive:(NSNotification *)notification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does macOS need this flow at all?
s.ios.dependency 'Flutter' | ||
s.osx.dependency 'FlutterMacOS' | ||
s.ios.deployment_target = '12.0' | ||
s.osx.deployment_target = '10.15' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 10.15 rather than 10.14?
/// Class wrapping all authentication messages needed on macOS. | ||
/// Provides default values for all messages. | ||
@immutable | ||
class MacOSAuthMessages extends AuthMessages { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be identical to iOS currently, which means there should be a base class (I guess DarwinAuthMessages
) that has all of this, and the two platform versions should just inherit from it with (currently) no additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(At which point the code for populating the Pigeon AuthStrings
will become much simpler.)
FYI, you'll need to resolve a raft of conflicts with #6108 once that lands. The easiest way to do it will most likely be to make the same changes in your code and then just take your copy of everything. |
|
The implementation of this pr seems to be outdated with the current local_auth_darwin approach. I made a new pr #6267 |
Since this is marked as a draft and hasn't been updated in several months I'm going to close it to clean out our review queue. Please don't hesitate to submit a new PR if you decide to revisit this. Thanks! |
Created plugin
local_auth_macos
to support macOS platform for biometric and password authentication for the local_auth plugin.The Objective-C code for macOS is built upon the implementation of iOS with necessary changes to work on macOS.
Working Demo:
Screen.Recording.2023-12-28.at.8.24.51.AM.mov
resolves flutter/flutter#140685
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.