Skip to content
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

Add credential protection policy and large blob support #128

Conversation

jeriox
Copy link

@jeriox jeriox commented Apr 3, 2022

We needed support for large blobs and credential protection policy in our project, which py_webauthn didn't provide. We added the appropriate structs and options to genereate_registration_options which worked fine for us.

closes #127

felix-gohla and others added 2 commits March 31, 2022 15:16
Co-authored-by: j-hellenberg <janeric.hellenberg@gmail.com>
Co-authored-by: j-hellenberg <janeric.hellenberg@gmail.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jeriox jeriox mentioned this pull request Apr 3, 2022
read: Optional[bool] = None
write: Optional[bytes] = None

class AuthenticationExtensionClientInputs(WebAuthnBaseModel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename this to AuthenticationExtensionsClientInputs (with "Extensions" plural) to better match the spec here? https://www.w3.org/TR/webauthn-2/#iface-authentication-extensions-client-inputs

Comment on lines +509 to +522
class CredentialProtectionPolicy(str, Enum):
"""Various registered values indicating whether a credential shall be protected (influences how discoverable credentials are handled).

Members:
`USER_VERIFICATION_OPTIONAL`
`USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST`
`USER_VERIFICATION_REQUIRED`

https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-credProtect-extension
"""
USER_VERIFICATION_OPTIONAL = 'userVerificationOptional'
USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST = 'userVerificationOptionalWithCredentialIDList'
USER_VERIFICATION_REQUIRED = 'userVerificationRequired'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the value of this extension, but my goal is for this library to support only the functionality defined in the WebAuthn spec itself. Since this extension isn't formally defined in https://www.w3.org/TR/webauthn-2/#sctn-defined-extensions then I'm inclined to request that it not be included in this diff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some conversation going on in an issue in the spec repo that's educating me on how my position in which extensions to support may not be reasonable: w3c/webauthn#1703 (comment)

I'm going to revisit this PR next week when I get back in the office, your credProtect contribution will likely make it through in one way or another.

Comment on lines +58 to +61
if large_blob_extension is not None:
options.extensions = AuthenticationExtensionClientInputs(
large_blob=large_blob_extension
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please write some tests for this new logic?

Comment on lines +138 to +142
options.extensions = AuthenticationExtensionClientInputs(
large_blob=large_blob_extension,
credential_protection_policy=credential_protection_policy,
enforce_credential_protection_policy=enforce_credential_protection_policy,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write some tests for this new logic please to ensure the extensions are set when specified? And I'm curious, what would extensions out of this method serialize to JSON as if none of the arguments are provided? An empty {}? Would they be omitted? I'd like to see extensions not get serialized at all if no extensions are specified.

@MasterKale
Copy link
Collaborator

MasterKale commented Apr 6, 2022

I neglected to thank you for submitting this PR: thank you! I've been meaning to sit down and think about extension support with a bit more abstract API that wouldn't require you to know all of the values for a given extension.

For example, why not have an optional require_large_blob_support: bool argument to generate_registration_options(), since the only option in AuthenticationExtensionsLargeBlobInputs that's valid for registration is support? Technically require_large_blob_support=False would do the same thing as setting support: "preferred" because the spec itself states:

Otherwise (i.e. support is absent or has the value preferred):

So there's no need to even include the value if you're not going to set it to "required".

And for authentication you can specify either read or write, but not both. Therefore I could see adding a write_large_blob: Optional[bytes] = None and read_large_blog: bool = False to generate_authentication_options(), and error out when both are set, so that the developer using the method doesn't need to be aware of the intricacies of the spec - we can remove most of the footguns for them.

These are the angles from which I was going to approach adding support for extensions like largeBlob. Since you're interested in the feature, though, I'm curious to hear what you think about this approach.

@MasterKale
Copy link
Collaborator

Closing for now due to inactivity

@MasterKale MasterKale closed this Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CredentialProtectionPolicy
4 participants