Skip to content

Commit 8e7965c

Browse files
Added unsafe setters for changing the challenge returned by the manager
Closes #72
1 parent d52e940 commit 8e7965c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Sources/WebAuthn/Ceremonies/Authentication/PublicKeyCredentialRequestOptions.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ import Foundation
2121
public struct PublicKeyCredentialRequestOptions: Sendable {
2222
/// A challenge that the authenticator signs, along with other data, when producing an authentication assertion
2323
///
24-
/// When encoding using `Encodable` this is encoded as base64url.
25-
public var challenge: [UInt8]
24+
/// The Relying Party should store the challenge temporarily until the authentication flow is complete. When encoding using `Encodable` this is encoded as base64url.
25+
///
26+
/// - Warning: Although the challenge can be changed, doing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol. See ``setUnsafeChallenge(_:)``.
27+
public private(set) var challenge: [UInt8]
28+
29+
/// Unsafely change the challenge that will be delivered to the client.
30+
///
31+
/// - Warning: Although the challenge can be changed, doing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol.
32+
public mutating func setUnsafeChallenge(_ newValue: [UInt8]) {
33+
challenge = newValue
34+
}
2635

2736
/// A time, in seconds, that the caller is willing to wait for the call to complete. This is treated as a
2837
/// hint, and may be overridden by the client.

Sources/WebAuthn/Ceremonies/Registration/PublicKeyCredentialCreationOptions.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ public struct PublicKeyCredentialCreationOptions: Sendable {
2525
///
2626
/// The Relying Party should store the challenge temporarily until the registration flow is complete. When
2727
/// encoding using `Encodable`, the challenge is base64url encoded.
28-
public let challenge: [UInt8]
28+
///
29+
/// - Warning: Although the challenge can be changed, dooing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol. See ``setUnsafeChallenge(_:)``.
30+
public private(set) var challenge: [UInt8]
31+
32+
/// Unsafely change the challenge that will be delivered to the client.
33+
///
34+
/// - Warning: Although the challenge can be changed, doing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol.
35+
public mutating func setUnsafeChallenge(_ newValue: [UInt8]) {
36+
challenge = newValue
37+
}
2938

3039
/// Contains names and an identifier for the user account performing the registration
3140
public var user: PublicKeyCredentialUserEntity

0 commit comments

Comments
 (0)