Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

macos authenticator #337

wants to merge 1 commit into from

Conversation

devsnek
Copy link
Collaborator

@devsnek devsnek commented Aug 5, 2023

experimental hacking

  • cargo test has been run and passes
  • documentation has been updated with relevant examples (if relevant)

Copy link
Member

@yaleman yaleman left a 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.
Copy link
Member

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
Copy link
Member

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
Copy link
Collaborator

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.

Copy link
Member

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,
Copy link
Collaborator

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])
Copy link
Collaborator

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)
Copy link
Collaborator

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
Copy link
Member

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.

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

Successfully merging this pull request may close these issues.

4 participants