Skip to content

Commit

Permalink
feat-allow-multiple-origins
Browse files Browse the repository at this point in the history
* fix origin extraction code
  • Loading branch information
obroshnij committed Nov 5, 2024
1 parent 5d0197f commit 3b58fdb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/webauthn/authenticator_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ def valid_user_verified?
end

# @return [String, nil]
# @param [String, nil] expected_origin
# @param [String, Array, nil] expected_origin
# Extract RP ID from origin in case rp_id is not provided explicitly
def rp_id_from_origin(expected_origin)
return unless expected_origin.is_a?(Array) && expected_origin.size == 1

URI.parse(expected_origin.first).host
case expected_origin
when Array
URI.parse(expected_origin.first).host if expected_origin.size == 1
when String
URI.parse(expected_origin).host
end
end

def type
Expand Down

0 comments on commit 3b58fdb

Please sign in to comment.