-
-
Notifications
You must be signed in to change notification settings - Fork 34
Add support for optional AuthenticatorSelection #120
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
Merged
dimitribouniol
merged 5 commits into
brokenhandsio:main
from
edgewoodsailing:authenticatorSelection-upstream
Nov 25, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ccb6de2
Add authenticator selection criteria to registration options
samalone 9e0fe96
Refactor authenticator selection handling in registration process
samalone 91e1acf
Enhance AuthenticatorSelection struct for improved decoding and encoding
samalone 12a09aa
Refactor AuthenticatorSelection struct to streamline Codable conformance
samalone 31ce9fd
Merge branch 'main' into authenticatorSelection-upstream
samalone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Sources/WebAuthn/Ceremonies/Registration/AuthenticatorSelection.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift WebAuthn open source project | ||
| // | ||
| // Copyright (c) 2022 the Swift WebAuthn project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| import Foundation | ||
|
|
||
| /// A dictionary describing the Relying Party's requirements regarding authenticator attributes. | ||
| /// | ||
| /// - SeeAlso: https://www.w3.org/TR/webauthn-2/#dictdef-authenticatorselectioncriteria | ||
| public struct AuthenticatorSelection: Codable, Sendable { | ||
samalone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// If present, indicates the Relying Party's preference for authenticator attachment. | ||
| public var authenticatorAttachment: AuthenticatorAttachment? | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Describes the Relying Party's requirements regarding whether the authenticator should create a client-side-resident public key credential source. | ||
| public var residentKey: ResidentKeyRequirement? | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Describes the Relying Party's requirements regarding user verification. | ||
| public var userVerification: UserVerificationRequirement? | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public init( | ||
| authenticatorAttachment: AuthenticatorAttachment? = nil, | ||
| residentKey: ResidentKeyRequirement? = nil, | ||
| userVerification: UserVerificationRequirement? = nil | ||
| ) { | ||
| self.authenticatorAttachment = authenticatorAttachment | ||
| self.residentKey = residentKey | ||
| self.userVerification = userVerification | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Sources/WebAuthn/Ceremonies/Registration/ResidentKeyRequirement.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift WebAuthn open source project | ||
| // | ||
| // Copyright (c) 2022 the Swift WebAuthn project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| import Foundation | ||
|
|
||
| /// The Relying Party's requirements regarding whether the authenticator should create a client-side-resident public key credential source. | ||
| /// | ||
| /// - SeeAlso: https://www.w3.org/TR/webauthn-2/#enumdef-residentkeyrequirement | ||
samalone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public struct ResidentKeyRequirement: UnreferencedStringEnumeration, Sendable { | ||
| public var rawValue: String | ||
|
|
||
| public init(_ rawValue: String) { | ||
| self.rawValue = rawValue | ||
| } | ||
|
|
||
| /// This value indicates the Relying Party requires a client-side-resident credential (i.e., a discoverable credential). | ||
| /// If the authenticator cannot create a client-side-resident credential, it will return an error. | ||
| public static let required: Self = "required" | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// This value indicates the Relying Party strongly prefers a client-side-resident credential, but will accept a server-side credential. | ||
| public static let preferred: Self = "preferred" | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// This value indicates the Relying Party strongly prefers a server-side credential, but will accept a client-side-resident credential. | ||
| public static let discouraged: Self = "discouraged" | ||
samalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.