mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: Allow users to sign in using LinkedIn OpenID Connect (#26281)
LinkedIn has grandfathered its old OAuth2 provider. This can only be used by existing apps. New apps have to use the new OIDC provider. This PR adds a linkedin_oidc provider to core. This will exist alongside the discourse-linkedin-auth plugin, which will be kept for those still using the deprecated provider.
This commit is contained in:
43
spec/lib/auth/linkedin_oidc_authenticator_spec.rb
Normal file
43
spec/lib/auth/linkedin_oidc_authenticator_spec.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Auth::LinkedInOidcAuthenticator do
|
||||
let(:hash) do
|
||||
OmniAuth::AuthHash.new(
|
||||
provider: "linkedin_oidc",
|
||||
extra: {
|
||||
raw_info: {
|
||||
email: "100",
|
||||
email_verified: true,
|
||||
given_name: "Coding",
|
||||
family_name: "Horror",
|
||||
picture:
|
||||
"https://media.licdn.com/dms/image/C5603AQH7UYSA0m_DNw/profile-displayphoto-shrink_100_100/0/1516350954443?e=1718841600&v=beta&t=1DdwKTzW2QdVuPtnk1C20oaYSkqeEa4ffuI6_NlXbB",
|
||||
locale: {
|
||||
country: "US",
|
||||
language: "en",
|
||||
},
|
||||
},
|
||||
},
|
||||
info: {
|
||||
email: "coding@horror.com",
|
||||
first_name: "Coding",
|
||||
last_name: "Horror",
|
||||
image:
|
||||
"https://media.licdn.com/dms/image/C5603AQH7UYSA0m_DNw/profile-displayphoto-shrink_100_100/0/1516350954443?e=1718841600&v=beta&t=1DdwKTzW2QdVuPtnk1C20oaYSkqeEa4ffuI6_NlXbB",
|
||||
},
|
||||
uid: "100",
|
||||
)
|
||||
end
|
||||
|
||||
let(:authenticator) { described_class.new }
|
||||
|
||||
describe "after_authenticate" do
|
||||
it "works normally" do
|
||||
result = authenticator.after_authenticate(hash)
|
||||
expect(result.user).to eq(nil)
|
||||
expect(result.failed).to eq(false)
|
||||
expect(result.name).to eq("Coding Horror")
|
||||
expect(result.email).to eq("coding@horror.com")
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user