Skip to content

Commit

Permalink
DEV: Case insensitive check on email_verified field
Browse files Browse the repository at this point in the history
  • Loading branch information
nattsw committed Nov 30, 2023
1 parent de0831a commit a845ff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/openid_connect_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def primary_email_verified?(auth)
true
else
# Many providers violate the spec, and send this as a string rather than a boolean
supplied_verified_boolean == true || supplied_verified_boolean == "true"
supplied_verified_boolean == true ||
(supplied_verified_boolean.is_a?(String) && supplied_verified_boolean.downcase == "true")
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/lib/openid_connect_authenticator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
result = authenticator.after_authenticate(hash)
expect(result.user).to eq(user)
end

it "matches the user as a titlecase true string" do
hash[:extra][:raw_info][:email_verified] = "True"
result = authenticator.after_authenticate(hash)
expect(result.user).to eq(user)
end
end

context "when email_verified is false" do
Expand Down

0 comments on commit a845ff8

Please sign in to comment.