Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Add support for Touch ID as an authentication method in macOS #53

Closed
jviotti opened this issue Jul 10, 2017 · 10 comments
Closed

Add support for Touch ID as an authentication method in macOS #53

jviotti opened this issue Jul 10, 2017 · 10 comments

Comments

@jviotti
Copy link
Contributor

jviotti commented Jul 10, 2017

From balena-io/etcher#1579.

Not sure what's needed for this, but it'd indeed be very cool if sudo-prompt can support Touch ID authentication on newest MacBooks.

@jorangreef jorangreef changed the title Support Touch ID as an authentication method in macOS Add support for Touch ID as an authentication method in macOS Jul 14, 2017
@jorangreef
Copy link
Owner

Thanks @jviotti I will look into it. Any ideas from your side?

@jviotti
Copy link
Contributor Author

jviotti commented Jul 14, 2017

I have very little macOS programming knowledge, and my MacBook Pro doesn't have Touch ID, but I'll see if I can find something :)

@ryankon
Copy link

ryankon commented Mar 21, 2018

I've been using Etcher a lot, so I tried to take a closer look at this, and I had a quick question. If I execute the AppleScript directly or if I do the following, I get the Touch ID prompt.

osascript -e 'do shell script "echo foo" with administrator privileges'

Perhaps it has something to do with the applet binary? What is it actually doing?

Thanks!

@jorangreef
Copy link
Owner

Thanks @ryankon

The applet is just an AppleScript packaged as an app by Xcode.

We moved away from copying the osascript binary since this applet technique lets us set the prompt's icon by changing the applet's icon dynamically.

You can inspect the applet in Xcode: decode the applet base64, unzip, then open Contents/Resources/Scripts in Xcode, which looks like this:

do shell script "./sudo-prompt-script" with administrator privileges

MacOS/sudo-prompt-script then looks like this:

#!/bin/bash
# Set sudo timestamp for subsequent sudo calls if tty_tickets are disabled:
/bin/mkdir -p /var/db/sudo/$USER > /dev/null 2>&1
/usr/bin/touch /var/db/sudo/$USER > /dev/null 2>&1
# AppleScript's "do shell script" may alter stdout line-endings.
# It may also set stdout to stderr if there was a non-zero return code and no stderr.
# We therefore prefer to redirect output streams and capture return code manually:
/bin/bash sudo-prompt-command 1>stdout 2>stderr
/bin/echo $? > code
# Correct ownership of stdout, stderr and code so that user can delete them:
/usr/sbin/chown $USER stdout stderr code
# Always return 0 so that AppleScript does not show error dialog:
exit 0

sudo-prompt-command is written out dynamically.

This might be a red herring but I think I recall that with administrator privileges works slightly differently when executing a native shell command vs executing a compound shell script but I'm not sure if this is accurate.

Perhaps osascript is wired up to show the Touch ID prompt when it sees with administrator privileges but Xcode AppleScript applets are not? Perhaps the applet just needs to be rebuilt on a newer macOS? Could you look into this on your Mac?

@jorangreef
Copy link
Owner

jorangreef commented Mar 22, 2018

Perhaps the applet just needs to be rebuilt on a newer macOS? Could you look into this on your Mac?

This might just do the trick.

@ryankon
Copy link

ryankon commented Mar 22, 2018

Thanks for the detailed response @jorangreef

Unfortunately, I attempted to rebuild the AppleScript app using the latest Xcode (9.2) on MacOS 10.3.3, and it still prompts for a password instead of using Touch ID.

If we want to preserve the prompt customizability, we may have to use the Local Authentication framework instead. I can try to carve out some time in the coming weeks to take a closer look. Thoughts?

@jorangreef
Copy link
Owner

Sure, thanks @ryankon for trying the rebuild.

It would be great to look into using the Local Authentication framework, especially if we can interact with it from C/C++ with a minimum of anything else. I have tried to keep sudo-prompt free from being a native add-on for convenience. Please let me know what ideas you have or what might work.

@jorangreef
Copy link
Owner

@ryankon , would you like to try rebuild the AppleScript app again to see if Xcode now prompts with Touch ID?

@jorangreef
Copy link
Owner

Closing for now, let me know if anything changes with this please.

@Fndroid
Copy link

Fndroid commented Jan 16, 2021

any update for this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants