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: allow multiple origins set per RelyingParty #431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

obroshnij
Copy link

As described in the issue #428
when building a Relying Party that is supposed to be used by iOS and Android native clients, we need to be able to specify multiple allowed origins per RP (https://developer.android.com/identity/sign-in/credential-manager#verify-origin)
This is yet not supported by this library though is also part of standard specification https://w3c.github.io/webauthn/#sctn-validating-origin

Current workaround is to fallback to creating multiple RP abstractions per expected client platform (Android, iOS, etc) and select one of them based on User-Agent header (for example). That is of course troublesome and can actually be avoided.

This PR allows a relying party to specify either string for origin or array of strings like in the example:

# config/initializers/webauthn.rb

WebAuthn.configure do |config|
  # This value needs to match `window.location.origin` evaluated by
  # the User Agent during registration and authentication ceremonies.
  # config.origin = "https://auth.example.com/"
  config.origin = [
    "https://auth.example.com/",
    "android:apk-key-hash:blablablablablalblalla"
  ]

  # Relying Party name for display purposes
  config.rp_name = "Example Inc."
  config.rp_id  = "example.com"
end

The only drawback of this approach is that in case an array is used for config.origin, - it's impossssible to "guess" relying party by origin (which maybe we should not even do?) thus having array there and no explicitly set config.rp_id would result in RpIdVerificationError which imo should be expected.

Hope this PR makes sense. Please let me know should there be any change requests/questions

Copy link
Contributor

@santiagorodriguez96 santiagorodriguez96 left a comment

Choose a reason for hiding this comment

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

Hey @obroshnij 👋 thank you so much for your time and effort!

I like where this is going!

I will try to give a proper test to this in the next week to see how it works in a real app. I'll let you know once I've done it 🙂

Then again, thanks!

lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
spec/webauthn/authenticator_attestation_response_spec.rb Outdated Show resolved Hide resolved
spec/webauthn/authenticator_attestation_response_spec.rb Outdated Show resolved Hide resolved
spec/webauthn/authenticator_attestation_response_spec.rb Outdated Show resolved Hide resolved
@obroshnij
Copy link
Author

@santiagorodriguez96 thanks a lot for a review and feedback. I have address the points that you brought earlier. Please let me know if there is still anything I should improve

@obroshnij
Copy link
Author

@santiagorodriguez96 I know you guys are pretty busy, but just so that I can also manage my expectations, is there a chance to get this patch merged any time soon?

Copy link
Contributor

@santiagorodriguez96 santiagorodriguez96 left a comment

Choose a reason for hiding this comment

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

Hey @obroshnij! Thank you for taking the time and the patience for addressing the comments. Sorry that it took me some time to get back to you again.

I've left a couple more comments in order to keep this moving forward 🙂

Then again thank you!

lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
lib/webauthn/relying_party.rb Outdated Show resolved Hide resolved
spec/webauthn/authenticator_attestation_response_spec.rb Outdated Show resolved Hide resolved
lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/webauthn/relying_party.rb Outdated Show resolved Hide resolved
lib/webauthn/version.rb Outdated Show resolved Hide resolved
lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
lib/webauthn/relying_party.rb Outdated Show resolved Hide resolved
lib/webauthn/relying_party.rb Outdated Show resolved Hide resolved
lib/webauthn/authenticator_response.rb Outdated Show resolved Hide resolved
@obroshnij
Copy link
Author

hey @santiagorodriguez96 thanks a lot for another review. I have addressed the points you brought up and I think it should be ready for the next review

@obroshnij obroshnij force-pushed the feat-allow-multiple-origins branch 2 times, most recently from 3b58fdb to 3f85603 Compare November 5, 2024 20:55
* add a possibility to set `allowed_origins` configuration option that would be an alternative to `origin`

* update Readme

* add deprecation warning

* adjust test suite

* overwrite writer to consistently trigger deprecation warnings

* fix origin extraction code
@obroshnij
Copy link
Author

hi @santiagorodriguez96 thanks for running the CI here. I have fixed the rubocop issues now

@santiagorodriguez96
Copy link
Contributor

Hi @obroshnij! The PR looks good to me!

I'd want to hold off for merging as my plan was to release this as part of v3.3 as we have a lot of features coming in v3.2 too and this one is already a pretty big one 😕

I'll try to release v3.2 and v3.3 in the following days 🙂

@obroshnij
Copy link
Author

Hi @obroshnij! The PR looks good to me!

I'd want to hold off for merging as my plan was to release this as part of v3.3 as we have a lot of features coming in v3.2 too and this one is already a pretty big one 😕

I'll try to release v3.2 and v3.3 in the following days 🙂

awesome, I'm looking forward to that 🚀

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.

2 participants