From 32b40c9a55628a6dd433f1b20ba1c30df253e4b5 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 19 Nov 2022 10:56:12 -0800 Subject: [PATCH] Add email_verified claim in user info This boolean field is a standard OpenID claim: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims --- lib/omniauth/strategies/openid_connect.rb | 1 + test/lib/omniauth/strategies/openid_connect_test.rb | 1 + test/strategy_test_case.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/omniauth/strategies/openid_connect.rb b/lib/omniauth/strategies/openid_connect.rb index 41c55322..3f9f7ada 100644 --- a/lib/omniauth/strategies/openid_connect.rb +++ b/lib/omniauth/strategies/openid_connect.rb @@ -74,6 +74,7 @@ def uid { name: user_info.name, email: user_info.email, + email_verified: user_info.email_verified, nickname: user_info.preferred_username, first_name: user_info.given_name, last_name: user_info.family_name, diff --git a/test/lib/omniauth/strategies/openid_connect_test.rb b/test/lib/omniauth/strategies/openid_connect_test.rb index c204883f..c536c357 100644 --- a/test/lib/omniauth/strategies/openid_connect_test.rb +++ b/test/lib/omniauth/strategies/openid_connect_test.rb @@ -429,6 +429,7 @@ def test_info info = strategy.info assert_equal user_info.name, info[:name] assert_equal user_info.email, info[:email] + assert_equal user_info.email_verified, info[:email_verified] assert_equal user_info.preferred_username, info[:nickname] assert_equal user_info.given_name, info[:first_name] assert_equal user_info.family_name, info[:last_name] diff --git a/test/strategy_test_case.rb b/test/strategy_test_case.rb index b3accaf8..923012df 100644 --- a/test/strategy_test_case.rb +++ b/test/strategy_test_case.rb @@ -21,6 +21,7 @@ def user_info sub: SecureRandom.hex(16), name: Faker::Name.name, email: Faker::Internet.email, + email_verified: Faker::Boolean.boolean, nickname: Faker::Name.first_name, preferred_username: Faker::Internet.user_name, given_name: Faker::Name.first_name,