Skip to content

Commit

Permalink
Move DEFAULT_AUTHENTICATOR_TIMEOUT into webauthn-rs.
Browse files Browse the repository at this point in the history
This fixes a documentation build breakage caused by kanidm#385, and shifts
default timeouts into our recommended interface.
  • Loading branch information
micolous committed Nov 24, 2023
1 parent a0cb1e8 commit 16fed53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 0 additions & 3 deletions webauthn-rs-core/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
use std::time::Duration;

// Can this ever change?
pub const CHALLENGE_SIZE_BYTES: usize = 32;
pub const DEFAULT_AUTHENTICATOR_TIMEOUT: Duration = Duration::from_millis(60000);
6 changes: 3 additions & 3 deletions webauthn-rs-core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::attestation::{
verify_apple_anonymous_attestation, verify_attestation_ca_chain, verify_fidou2f_attestation,
verify_packed_attestation, verify_tpm_attestation, AttestationFormat,
};
use crate::constants::{CHALLENGE_SIZE_BYTES, DEFAULT_AUTHENTICATOR_TIMEOUT};
use crate::constants::CHALLENGE_SIZE_BYTES;
use crate::crypto::compute_sha256;
use crate::error::WebauthnError;
use crate::internals::*;
Expand Down Expand Up @@ -85,7 +85,7 @@ impl WebauthnCore {
rp_name: &str,
rp_id: &str,
allowed_origins: Vec<Url>,
authenticator_timeout: Option<Duration>,
authenticator_timeout: Duration,
allow_subdomains_origin: Option<bool>,
allow_any_port: Option<bool>,
) -> Self {
Expand All @@ -95,7 +95,7 @@ impl WebauthnCore {
rp_id: rp_id.to_string(),
rp_id_hash,
allowed_origins,
authenticator_timeout: authenticator_timeout.unwrap_or(DEFAULT_AUTHENTICATOR_TIMEOUT),
authenticator_timeout,
require_valid_counter_value: true,
ignore_unsupported_attestation_formats: true,
allow_cross_origin: false,
Expand Down
11 changes: 7 additions & 4 deletions webauthn-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ pub mod prelude {
pub use webauthn_rs_core::AttestationFormat;
}

/// The default authenticator interaction timeout, if none is otherwise specified.
pub const DEFAULT_AUTHENTICATOR_TIMEOUT: Duration = Duration::from_millis(60000);

/// A constructor for a new [Webauthn] instance. This accepts and configures a number of site-wide
/// properties that apply to all webauthn operations of this service.
#[derive(Debug)]
Expand All @@ -226,7 +229,7 @@ pub struct WebauthnBuilder<'a> {
allowed_origins: Vec<Url>,
allow_subdomains: bool,
allow_any_port: bool,
timeout: Option<Duration>,
timeout: Duration,
algorithms: Vec<COSEAlgorithm>,
user_presence_only_security_keys: bool,
}
Expand Down Expand Up @@ -282,7 +285,7 @@ impl<'a> WebauthnBuilder<'a> {
allowed_origins: vec![rp_origin.to_owned()],
allow_subdomains: false,
allow_any_port: false,
timeout: None,
timeout: DEFAULT_AUTHENTICATOR_TIMEOUT,
algorithms: COSEAlgorithm::secure_algs(),
user_presence_only_security_keys: false,
})
Expand Down Expand Up @@ -320,9 +323,9 @@ impl<'a> WebauthnBuilder<'a> {

/// Set the timeout value to use for credential creation and authentication challenges.
///
/// If not set, defaults to [webauthn_rs_core::constants::DEFAULT_AUTHENTICATOR_TIMEOUT].
/// If not set, defaults to [DEFAULT_AUTHENTICATOR_TIMEOUT].
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self.timeout = timeout;
self
}

Expand Down

0 comments on commit 16fed53

Please sign in to comment.