Skip to content

Commit a6f74fa

Browse files
committed
Add Origin type
1 parent 4d8699e commit a6f74fa

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

credentialsd/src/webauthn.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,28 @@ pub fn format_client_data_json(
690690
};
691691
let cross_origin_str = if is_cross_origin { "true" } else { "false" };
692692
format!("{{\"type\":\"{op_str}\",\"challenge\":\"{challenge}\",\"origin\":\"{origin}\",\"crossOrigin\":{cross_origin_str}}}")
693+
694+
#[derive(Debug)]
695+
pub(crate) enum Origin {
696+
AppId(String),
697+
SameOrigin(String),
698+
CrossOrigin((String, String)),
699+
}
700+
701+
impl Origin {
702+
pub(crate) fn origin(&self) -> &str {
703+
&match self {
704+
Origin::AppId(app_id) => app_id,
705+
Origin::SameOrigin(origin) => origin,
706+
Origin::CrossOrigin((origin, _)) => origin,
707+
}
708+
}
709+
710+
pub(crate) fn top_origin(&self) -> Option<&str> {
711+
Origin::AppId(_) => None,
712+
Origin::SameOrigin(_) => None,
713+
Origin::CrossOrigin((_, ref top_origin)) => Some(top_origin),
714+
}
715+
}
716+
}
693717
}

0 commit comments

Comments
 (0)