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

Removed conditional request style from credential registration #19

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Sources/Passage/interfaces/PassageCurrentUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ final public class PassageCurrentUser {
let authController = PasskeyAuthenticationController()
let credential = try await authController.requestPasskeyRegistration(
registrationRequest: registrationRequest,
includeSecurityKeyOption: includeSecurityKeyOption,
autoUpgradeAccount: options?.isConditionalMediation == true
includeSecurityKeyOption: includeSecurityKeyOption
)
// Send the new Credential Handshake Response to Passage server
let finishRequest = RegisterWebAuthnFinishRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,17 @@ internal class PasskeyAuthenticationController:

internal func requestPasskeyRegistration(
registrationRequest: PasskeyRegistrationRequest,
includeSecurityKeyOption: Bool = false,
autoUpgradeAccount: Bool = false
includeSecurityKeyOption: Bool = false
) async throws -> ASAuthorizationPublicKeyCredentialRegistration {
let publicKeyCredentialProvider = ASAuthorizationPlatformPublicKeyCredentialProvider(
relyingPartyIdentifier: registrationRequest.relyingPartyIdentifier
)
var platformRegistrationRequest = publicKeyCredentialProvider
let platformRegistrationRequest = publicKeyCredentialProvider
.createCredentialRegistrationRequest(
challenge: registrationRequest.challenge,
name: registrationRequest.userName,
userID: registrationRequest.userId
)
#if os(iOS) || os(macOS) || os(visionOS)
if #available(iOS 18.0, macOS 15.0, visionOS 2.0, *) {
if autoUpgradeAccount {
platformRegistrationRequest = publicKeyCredentialProvider
.createCredentialRegistrationRequest(
challenge: registrationRequest.challenge,
name: registrationRequest.userName,
userID: registrationRequest.userId,
requestStyle: .conditional
)
}
}
#endif
// To match other webauthn "cross-platform" behaviors, we always include a Platform provider
// request, never JUST a Security Key provider request.
var requests: [ASAuthorizationRequest] = [ platformRegistrationRequest ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,8 @@ public struct PasskeyCreationOptions {
/// Set to `.crossPlatform` to provide option for user to store credential on a physical Security Key.
public let authenticatorAttachment: AuthenticatorAttachment?

/// Set to `true` to create a passkey without asking the user.
///
/// NOTE: Only available on iOS 18.0+, macOS 15.0+, and visionOS 2.0+.
public let isConditionalMediation: Bool?

public init(authenticatorAttachment: AuthenticatorAttachment?, isConditionalMediation: Bool?) {
public init(authenticatorAttachment: AuthenticatorAttachment?) {
self.authenticatorAttachment = authenticatorAttachment
if #available(iOS 18.0, macOS 15.0, visionOS 2.0, *) {
self.isConditionalMediation = isConditionalMediation
} else {
self.isConditionalMediation = false
}
}

}
Loading