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(config): allow rpid to be defined at execution time #234

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

james-d-elliott
Copy link
Member

@james-d-elliott james-d-elliott commented Apr 29, 2024

This allows the Relying Party ID and Name to be configured at runtime rather than at configuration time.

Closes #165

Summary by CodeRabbit

  • New Features
    • Added validation for Relying Party ID in the login and registration processes.
    • Introduced functions to set Relying Party ID and name for registration.
  • Bug Fixes
    • Adjusted error formatting for invalid URIs and configuration validation.
  • Tests
    • Added new test cases for login and registration processes focusing on Relying Party ID and name validations.

This allows the Relying Party ID and Name to be configured at runtime rather than at configuration time.
@james-d-elliott james-d-elliott requested a review from a team as a code owner April 29, 2024 12:46
Copy link

coderabbitai bot commented Apr 29, 2024

Walkthrough

The updates primarily focus on enhancing the validation and configuration of relying party IDs and names in the WebAuthn authentication process. Changes include the addition of new validation checks, the removal of redundant error constants, and the introduction of functions to customize relying party details during login and registration. Tests are added to ensure the robustness of these new features.

Changes

Files Changes
webauthn/const.go, webauthn/types.go Refactored and streamlined error handling and validation logic for URI formats and relying party configurations.
webauthn/login.go, webauthn/registration.go Enhanced validation for relying party IDs and names; added functions to set these parameters during login and registration.
webauthn/login_test.go, webauthn/registration_test.go Introduced comprehensive tests for new validation functions and configurations related to relying party IDs and names.
webauthn/types_test.go Updated testing structures and methods to better reflect changes in data handling and validation.

Poem

🐇💻✨
In the land of code and silicon dreams,
A rabbit hopped through the lines, weaving seams.
With each hop, a bug squashed, a feature born,
In the glow of the screen, from night till morn.
Oh, celebrate the code that now runs free,
For every login and ID, as secure as can be!


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f63fbc1 and 22f2620.
Files selected for processing (7)
  • webauthn/const.go (1 hunks)
  • webauthn/login.go (3 hunks)
  • webauthn/login_test.go (2 hunks)
  • webauthn/registration.go (3 hunks)
  • webauthn/registration_test.go (1 hunks)
  • webauthn/types.go (1 hunks)
  • webauthn/types_test.go (2 hunks)
Additional comments not posted (10)
webauthn/const.go (1)

5-6: Ensure the updated error constants align with the new validation logic in other parts of the system.

webauthn/types_test.go (2)

4-5: Ensure the credentials field in defaultUser struct is properly utilized in tests to reflect the new capabilities.


23-23: Confirm that the WebAuthnCredentials method correctly returns the user's credentials as intended.

webauthn/login_test.go (1)

33-110: Review the new test function TestWithLoginRelyingPartyID to ensure it adequately tests all scenarios related to relying party IDs, including error handling and correct ID retrieval.

webauthn/registration_test.go (1)

13-99: Review the new test function TestWithRegistrationRelyingPartyID to ensure it adequately tests all scenarios related to relying party ID and name configurations, including error handling and correct ID and name retrieval.

webauthn/types.go (1)

96-99: Ensure the new validation logic for the RPID field in the Config struct correctly checks for non-empty values and valid URI formats.

webauthn/registration.go (2)

73-81: Review the validation checks in the BeginRegistration function to ensure they correctly enforce the presence of a valid relying party ID and name.


190-202: Ensure the new functions WithRegistrationRelyingPartyID and WithRegistrationRelyingPartyName correctly set the relying party ID and name during registration.

webauthn/login.go (2)

74-78: Review the validation checks in the beginLogin function to ensure they correctly enforce the presence of a valid relying party ID.


157-162: Ensure the new function WithLoginRelyingPartyID correctly sets the Relying Party ID during login.


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 c673c3d into master Apr 29, 2024
3 checks passed
@james-d-elliott james-d-elliott deleted the feat-optional-rpid branch April 29, 2024 12:52
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.

RP ID should be optional
1 participant