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

feat: support hints and attestation formats #216

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

james-d-elliott
Copy link
Member

@james-d-elliott james-d-elliott commented Feb 8, 2024

This adds support to the hints and attestation format options, both of which are new elements from Level 3 which are effectively optional. This allows users who wish to leverage this option to do so with no negative effects for those who do not.

Closes #208

Summary by CodeRabbit

  • New Features

    • Enhanced attestation format registration to improve security and consistency across various devices.
    • Introduced new options in the WebAuthn login and registration processes to allow users to specify preferences for credential hints and attestation formats.
  • Refactor

    • Updated internal handling of attestation formats to use enums instead of strings, enhancing code maintainability and type safety.
  • Documentation

    • Updated function signatures and added new options in public API documentation to reflect changes in attestation handling and user preferences.
  • Deprecations

    • Deprecated older methods of specifying conveyance preferences in favor of new, more flexible options.

@james-d-elliott james-d-elliott requested a review from a team as a code owner February 8, 2024 11:01
@james-d-elliott james-d-elliott changed the title feat(protocl): misc level 3 support items feat: support hints and attestation formats Feb 8, 2024
This adds support to the hints and attestation format options, both of which are new elements from Level 3 which are effectively optional. This allows users who wish to leverage this option to do so with no negative effects for those who do not.
Copy link

coderabbitai bot commented Apr 26, 2024

Walkthrough

The changes primarily focus on refactoring the attestation format registration across various modules in a WebAuthn implementation, replacing string literals with enums to enhance type safety and maintainability. Additionally, new fields and functions are introduced to support hints and attestation format preferences in credential options.

Changes

File Path Change Summary
protocol/attestation*.go Updated attestation format registration to use AttestationFormat enum across multiple files.
protocol/options.go Added new fields and types to support hints and attestation formats in credential options.
webauthn/login.go Introduced functions to adjust login parameters related to attestation.
webauthn/registration.go Added functions for registration options customization and deprecated old conveyance preference.

Assessment against linked issues

Objective Addressed Explanation
Support Hints (#208)
Add optional fields to AuthenticatorAttestationResponse struct (#221) The PR does not modify AuthenticatorAttestationResponse or its handling of unknown JSON fields.

Possibly related issues

  • Issue Add additional fields to AuthenticatorAttestationResponse #221: Although this PR does not address the enhancement request directly, the focus on attestation formats and credential options suggests a groundwork that could be extended to include AuthenticatorAttestationResponse enhancements in future updates.

🐰✨
Changes abound, code refines,
Enums in place, where once were lines.
Safer, cleaner, onward we hop,
In the fields of code, we do not stop.
Celebrate each commit, each merge,
For in our code, we always surge. 🌟
🐰✨


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4bb5779 and ad27228.
Files selected for processing (10)
  • protocol/attestation.go (2 hunks)
  • protocol/attestation_androidkey.go (1 hunks)
  • protocol/attestation_apple.go (1 hunks)
  • protocol/attestation_packed.go (2 hunks)
  • protocol/attestation_safetynet.go (1 hunks)
  • protocol/attestation_tpm.go (1 hunks)
  • protocol/attestation_u2f.go (1 hunks)
  • protocol/options.go (2 hunks)
  • webauthn/login.go (1 hunks)
  • webauthn/registration.go (1 hunks)
Additional comments not posted (23)
protocol/attestation_apple.go (2)

18-18: Registration of Apple attestation format using enum improves type safety.


18-18: The verifyAppleFormat function correctly implements the Apple attestation statement verification as per WebAuthn specifications.

protocol/attestation_u2f.go (2)

15-15: Registration of FIDO U2F attestation format using enum improves type safety.


15-15: The verifyU2FFormat function correctly implements the FIDO U2F attestation statement verification as per WebAuthn specifications.

protocol/attestation_safetynet.go (2)

18-18: Registration of Android SafetyNet attestation format using enum improves type safety.


18-18: The verifySafetyNetFormat function correctly implements the Android SafetyNet attestation statement verification as per WebAuthn specifications.

protocol/attestation.go (2)

73-73: Change to use AttestationFormat enum as keys in the attestation registry improves type safety.


77-77: The RegisterAttestationFormat function correctly uses the AttestationFormat enum for registering attestation formats.

webauthn/registration.go (3)

104-107: The WithHints function correctly adds hints to the PublicKeyCredentialCreationOptions.


125-127: The WithRegistrationConveyancePreference function correctly adjusts the attestation conveyance preference in the PublicKeyCredentialCreationOptions.


133-138: The WithRegistrationAttestationFormats function correctly adjusts the preferred attestation formats in the PublicKeyCredentialCreationOptions.

protocol/attestation_packed.go (2)

16-16: Registration of Packed attestation format using enum improves type safety.


16-16: The verifyPackedFormat function correctly implements the Packed attestation statement verification as per WebAuthn specifications.

protocol/attestation_androidkey.go (2)

14-14: Registration of Android Key attestation format using enum improves type safety.


14-14: The verifyAndroidKeyFormat function correctly implements the Android Key attestation statement verification as per WebAuthn specifications.

protocol/attestation_tpm.go (2)

19-19: Registration of TPM attestation format now uses the enum type AttestationFormat, enhancing type safety and clarity.

Ensure that all related changes in other files are consistent with this update.


Line range hint 21-135: The verifyTPMFormat function is well-structured and adheres to the WebAuthn specification for TPM attestation. Error handling is robust, with detailed messages that aid in debugging.

Consider adding comprehensive unit tests for this function to ensure all edge cases and error conditions are handled correctly.

webauthn/login.go (2)

118-124: LGTM! The conveyance preference setting function is correctly implemented.


126-132: LGTM! The attestation formats setting function is correctly implemented.

protocol/options.go (4)

29-31: LGTM! The new fields for hints and attestation formats in PublicKeyCredentialCreationOptions are correctly implemented.


45-46: LGTM! The new fields for attestation preferences and formats in PublicKeyCredentialRequestOptions are correctly implemented.


128-157: LGTM! The new PublicKeyCredentialHint type and constants are correctly defined.


159-189: LGTM! The new AttestationFormat type and constants are correctly defined.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@james-d-elliott james-d-elliott merged commit 824017d into master Apr 26, 2024
3 checks passed
@james-d-elliott james-d-elliott deleted the feat-level-3-misc branch April 26, 2024 13:56
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 Hints
1 participant