mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Authenticate with Discourse via OAuth2
See https://github.com/michaelkirk/discourse_oauth2_example for an example of how you might integrate your existing oauth2 provider's authentication via a Discourse plugin.
This commit is contained in:
parent
a67b1ba32c
commit
4af8a9102e
9 changed files with 121 additions and 0 deletions
|
@ -164,4 +164,25 @@ describe Users::OmniauthCallbacksController do
|
|||
|
||||
end
|
||||
|
||||
describe 'oauth2' do
|
||||
before do
|
||||
Discourse.stubs(:auth_providers).returns([stub(name: 'my_oauth2_provider', type: :oauth2)])
|
||||
request.env["omniauth.auth"] = { uid: 'my-uid', provider: 'my-oauth-provider-domain.net', info: {email: 'eviltrout@made.up.email', name: 'Chatanooga'}}
|
||||
end
|
||||
|
||||
describe "#create_or_sign_on_user_using_oauth2" do
|
||||
context "User already exists" do
|
||||
before do
|
||||
User.stubs(:find_by_email).returns(Fabricate(:user))
|
||||
end
|
||||
|
||||
it "should create an OauthUserInfo" do
|
||||
expect {
|
||||
post :complete, provider: 'my_oauth2_provider'
|
||||
}.to change { Oauth2UserInfo.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue