[pbs-devel] [PATCH proxmox-backup 3/3] config/tfa: webauthn: disallow registering a token twice

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Feb 22 15:08:45 CET 2021


On 22.02.21 10:43, Dominik Csapak wrote:
> by adding the existing credential id to the 'excludeCredentials' list

But the webauthn does not cares about this, meaning its intended to
work.

> this prevents the browser from registering a token twice, which
> lets authentication fail on some browser/token combinations
> (e.g. onlykey+chromium)

isn't that a FW bug there and should be fixed there?

Would like to avoid such special handling for buggy FW/HW/.. especially
if the workaround is as simple as "just don't register it twice"
(outside of testing I never came to the idea of registering a token
more than once in those accounts I use a fido/u2f token)

> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/config/tfa.rs         | 15 +++++++++++++--
>  www/window/AddWebauthn.js |  7 +++++++
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/src/config/tfa.rs b/src/config/tfa.rs
> index 29e0fb48..7c656d20 100644
> --- a/src/config/tfa.rs
> +++ b/src/config/tfa.rs
> @@ -803,9 +803,20 @@ impl TfaUserData {
>          userid: &Userid,
>          description: String,
>      ) -> Result<String, Error> {
> +        let cred_ids: Vec<_> = self
> +            .enabled_webauthn_entries()
> +            .map(|cred| cred.cred_id.clone())
> +            .collect();
> +
>          let userid_str = userid.to_string();
> -        let (challenge, state) = webauthn
> -            .generate_challenge_register(&userid_str, Some(UserVerificationPolicy::Discouraged))?;
> +        let (challenge, state) = webauthn.generate_challenge_register_options(
> +            userid_str.as_bytes().to_vec(),
> +            userid_str.clone(),
> +            userid_str.clone(),
> +            Some(cred_ids),
> +            Some(UserVerificationPolicy::Discouraged),
> +        )?;
> +
>          let challenge_string = challenge.public_key.challenge.to_string();
>          let challenge = serde_json::to_string(&challenge)?;
>  
> diff --git a/www/window/AddWebauthn.js b/www/window/AddWebauthn.js
> index 16731a63..a3888206 100644
> --- a/www/window/AddWebauthn.js
> +++ b/www/window/AddWebauthn.js
> @@ -82,6 +82,13 @@ Ext.define('PBS.window.AddWebauthn', {
>  		challenge_obj.publicKey.user.id =
>  		    PBS.Utils.base64url_to_bytes(challenge_obj.publicKey.user.id);
>  
> +		// convert existing authenticators structure
> +		challenge_obj.publicKey.excludeCredentials =
> +		    (challenge_obj.publicKey.excludeCredentials || []).map((cred) => ({
> +			id: PBS.Utils.base64url_to_bytes(cred.id),
> +			type: cred.type,
> +		    }));
> +
>  		let msg = Ext.Msg.show({
>  		    title: `Webauthn: ${gettext('Setup')}`,
>  		    message: gettext('Please press the button on your Webauthn Device'),
> 






More information about the pbs-devel mailing list