-
Notifications
You must be signed in to change notification settings - Fork 84
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
macos authenticator #337
base: master
Are you sure you want to change the base?
macos authenticator #337
Conversation
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 is so very cool, thanks for working it out @devsnek ❤️ Just some minor changes from a project perspective so far.
@@ -0,0 +1,3 @@ | |||
# MacAuthn | |||
|
|||
A description of this package. |
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.
I know it requires a fully bundled app with entitlements, can you please note the specifics since you've done it previously? It'd save some research for future-folks.
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
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.
A nested .gitignore is a dark pattern here, can you move the things up to the root one please.
if options.authenticatorSelection.requireResidentKey == true { | ||
securityKeyRequest.residentKeyPreference = .required | ||
} else { | ||
securityKeyRequest.residentKeyPreference = .preferred |
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 the value of AuthenticatorSelectionCriteria.resident_key
; and default to discouraged
if require_resident_key = false
: https://www.w3.org/TR/webauthn-2/#dom-authenticatorselectioncriteria-residentkey
At the moment, this will always try to use resident keys if a key supports them, potentially filling the authenticator's limited storage with useless RKs.
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.
Agreed, this needs to default to discouraged. Because the current code here effectively is forcing "true" on all code paths.
/// Perform a registration action using the ASAuthorization API. | ||
fn perform_register( | ||
&mut self, | ||
_origin: Url, |
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.
Because macOS is using the RP ID for both the origin
field of the Client Data JSON and MakeCredentialRequest.(RelyingParty)rp.id
, and doesn't have a way to pass other RelyingParty
fields, I feel there should be an explicit check here.
Windows passes them as two separate fields, and I think our native CTAP2 implementation doesn't actually check it.
// Setting allowedCredentials can hang for some reason: https://developer.apple.com/forums/thread/727267 | ||
securityKeyRequest.allowedCredentials = [] | ||
|
||
let authController = ASAuthorizationController(authorizationRequests: [platformKeyRequest, securityKeyRequest]) |
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.
Given that ASAuthorizationSecurityKeyPublicKeyCredentialProvider
is extremely limited (compared to Windows), I feel like this should be optional (ie: default to both, but use authenticator_attachment
to select which backends it tries to use).
window.center() | ||
window.makeKeyAndOrderFront(window) | ||
|
||
let applicationDelegate = ApplicationDelegate(window: window, authController: authController) |
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.
Could this section cause conflicts if there's already a running NSApplication
for the process?
if options.authenticatorSelection.requireResidentKey == true { | ||
securityKeyRequest.residentKeyPreference = .required | ||
} else { | ||
securityKeyRequest.residentKeyPreference = .preferred |
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.
Agreed, this needs to default to discouraged. Because the current code here effectively is forcing "true" on all code paths.
experimental hacking