Commit 7c0e23cb0fbef49c0c4960ddf2029bc48d105530
Exists in
staging
and in
20 other branches
Merge remote-tracking branch 'origin/master'
Showing
7 changed files
with
79 additions
and
2 deletions
Show diff stats
plugins/oauth_client/Gemfile
plugins/oauth_client/README.md
... | ... | @@ -33,6 +33,20 @@ Facebook |
33 | 33 | |
34 | 34 | [Create Facebook application](https://developers.facebook.com/docs/facebook-login/v2.1) |
35 | 35 | |
36 | +Github | |
37 | +-------- | |
38 | + | |
39 | +[Create Github application](https://github.com/settings/developers) | |
40 | + | |
41 | ||
42 | +-------- | |
43 | + | |
44 | +- Specially on twitter you need to request user's email address, see more | |
45 | +in https://dev.twitter.com/rest/reference/get/account/verify_credentials | |
46 | + | |
47 | +[Create Twitter application](https://apps.twitter.com/) | |
48 | + | |
49 | + | |
36 | 50 | Callback |
37 | 51 | ======== |
38 | 52 | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +Feature: Create Twitter provider | |
2 | + As a environment admin | |
3 | + I want to be able to create a new twitter provider | |
4 | + So that users can login wth different strategies | |
5 | + | |
6 | +Background: | |
7 | + Given "OauthProvider" plugin is enabled | |
8 | + And I am logged in as admin | |
9 | + And I go to /admin/plugins | |
10 | + And I check "Oauth Client Plugin" | |
11 | + And I press "Save changes" | |
12 | + | |
13 | +Scenario: Create a twitter provider | |
14 | + Given I go to /admin/plugin/oauth_client/new | |
15 | + And I fill in "oauth_client_plugin_provider_name" with "myid" | |
16 | + And I fill in "oauth_client_plugin_provider[name]" with "google" | |
17 | + And I fill in "oauth_client_plugin_provider_client_secret" with "mysecret" | |
18 | + And I check "oauth_client_plugin_provider[enabled]" | |
19 | + And I select "twitter" from "oauth_client_plugin_provider_strategy" | |
20 | + Then I should see "To use this provider you need to request the user email in your app" | ... | ... |
plugins/oauth_client/lib/oauth_client_plugin.rb
... | ... | @@ -31,13 +31,20 @@ class OauthClientPlugin < Noosfero::Plugin |
31 | 31 | |
32 | 32 | PROVIDERS = { |
33 | 33 | :facebook => { |
34 | - :name => 'Facebook' | |
34 | + :name => 'Facebook', | |
35 | + :info_fields => 'name,email' | |
35 | 36 | }, |
36 | 37 | :google_oauth2 => { |
37 | 38 | :name => 'Google' |
38 | 39 | }, |
39 | 40 | :noosfero_oauth2 => { |
40 | 41 | :name => 'Noosfero' |
42 | + }, | |
43 | + :github => { | |
44 | + :name => 'Github' | |
45 | + }, | |
46 | + :twitter => { | |
47 | + :name => 'Twitter' | |
41 | 48 | } |
42 | 49 | } |
43 | 50 | |
... | ... | @@ -62,8 +69,9 @@ class OauthClientPlugin < Noosfero::Plugin |
62 | 69 | provider_id = request.params['id'] |
63 | 70 | provider_id ||= request.session['omniauth.params']['id'] if request.session['omniauth.params'] |
64 | 71 | provider = environment.oauth_providers.find(provider_id) |
72 | + strategy.options.merge! consumer_key: provider.client_id, consumer_secret: provider.client_secret | |
65 | 73 | strategy.options.merge! client_id: provider.client_id, client_secret: provider.client_secret |
66 | - strategy.options.merge! provider.options.symbolize_keys | |
74 | + strategy.options.merge! options | |
67 | 75 | |
68 | 76 | request.session[:provider_id] = provider_id |
69 | 77 | } |
... | ... | @@ -95,4 +103,8 @@ class OauthClientPlugin < Noosfero::Plugin |
95 | 103 | } |
96 | 104 | end |
97 | 105 | |
106 | + def js_files | |
107 | + ["script.js"] | |
108 | + end | |
109 | + | |
98 | 110 | end | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +$(document).ready(function(){ | |
2 | + select_box_event(); | |
3 | +}); | |
4 | + | |
5 | +var toggle_info_message = function(){ | |
6 | + var selected_option = $("#oauth_client_plugin_provider_strategy option:selected"); | |
7 | + if (selected_option.length){ | |
8 | + if (selected_option.val() === "twitter"){ | |
9 | + $(".remember-enable-email").removeClass("hidden"); | |
10 | + } else { | |
11 | + $(".remember-enable-email").addClass("hidden"); | |
12 | + } | |
13 | + } | |
14 | +}; | |
15 | + | |
16 | +var select_box_event = function(){ | |
17 | + var select_box = $("#oauth_client_plugin_provider_strategy"); | |
18 | + select_box.on("change",function(){ | |
19 | + toggle_info_message(); | |
20 | + }); | |
21 | +}; | ... | ... |
plugins/oauth_client/public/style.css
plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb
... | ... | @@ -15,6 +15,10 @@ |
15 | 15 | <%= labelled_form_field _('Strategy'), f.select(:strategy, OauthClientPlugin::PROVIDERS) %> |
16 | 16 | </div> |
17 | 17 | |
18 | + <div class="remember-enable-email hidden"> | |
19 | + <span class="error"><%=_('To use this provider you need to request the user email in your app')%></span> | |
20 | + </div> | |
21 | + | |
18 | 22 | <div class="client-id"> |
19 | 23 | <%= labelled_form_field _('Client Id'), f.text_field(:client_id) %> |
20 | 24 | </div> | ... | ... |