diff --git a/plugins/oauth_client/Gemfile b/plugins/oauth_client/Gemfile new file mode 100644 index 0000000..f12771b --- /dev/null +++ b/plugins/oauth_client/Gemfile @@ -0,0 +1,3 @@ +gem 'omniauth', '~> 1.2.2' +gem 'omniauth-facebook', '~> 2.0.0' +gem "omniauth-google-oauth2", '~> 0.2.6' diff --git a/plugins/oauth_client/README.md b/plugins/oauth_client/README.md new file mode 100644 index 0000000..955acb6 --- /dev/null +++ b/plugins/oauth_client/README.md @@ -0,0 +1,72 @@ +README - Oauth Client Plugin +================================ + +OauthClient is a plugin which allow users to login/signup to noosfero with some oauth providers (for now, google, facebook and noosfero itself). + +Install +======= + +Enable Plugin +------------- + +cd +./script/noosfero-plugins enable oauth_client + +Active Plugin +------------- + +As a Noosfero administrator user, go to administrator panel: + +- Click on "Enable/disable plugins" option +- Click on "Oauth Client Plugin" check-box + +Provider Settings +================= + +Goggle +------ + +[Create Google+ application](https://developers.google.com/+/web/signin/javascript-flow) + +Facebook +-------- + +[Create Facebook application](https://developers.facebook.com/docs/facebook-login/v2.1) + +Varnish Settings +================ +If varnish has been used in your stack, you've to bypass the cache for signup page and prevent cookies to be removed when calling the oauth_client plugin callback. E.g.: + +``` +if (req.url !~ "^/account/*" && req.url !~ "^/plugin/oauth_provider/*" && req.url !~ "^/plugin/oauth_client/*" && req.http.cookie !~ "_noosfero_.*") { + unset req.http.cookie; + return(lookup); +} +``` + +Using Oauth Provider Plugin +=========================== +The oauth_provider plugin may be used as a provider in the same noosfero installation that hosts your oauth_client plugin (this is usefull in a multi environment setup). + +However, you've to use a distinct set of thin processes to handle the authorization requests (to avoid deadlock). + +Apache settings example: +``` +RewriteRule ^/oauth_provider/oauth/(authorize|token).*$ balancer://noosfero-oauth-provider%{REQUEST_URI} [P,QSA,L] +``` + + +Development +=========== + +Running OauthClient tests +-------------------- + +$ rake test:noosfero_plugins:oauth_client + +License +======= + +Copyright (c) The Author developers. + +See Noosfero license. diff --git a/plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.rb b/plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.rb new file mode 100644 index 0000000..5b8f535 --- /dev/null +++ b/plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.rb @@ -0,0 +1,27 @@ +class OauthClientPluginAdminController < AdminController + + def index + end + + def new + @provider = environment.oauth_providers.new + render :file => 'oauth_client_plugin_admin/edit' + end + + def remove + environment.oauth_providers.find(params[:id]).destroy + redirect_to :action => 'index' + end + + def edit + @provider = params[:id] ? environment.oauth_providers.find(params[:id]) : environment.oauth_providers.new + if request.post? + if @provider.update_attributes(params['oauth_client_plugin_provider']) + session[:notice] = _('Saved!') + else + session[:notice] = _('Error!') + end + end + end + +end diff --git a/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb b/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb new file mode 100644 index 0000000..af11fc7 --- /dev/null +++ b/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb @@ -0,0 +1,46 @@ +class OauthClientPluginPublicController < PublicController + + skip_before_filter :login_required + + def callback + auth = request.env["omniauth.auth"] + user = environment.users.find_by_email(auth.info.email) + user ? login(user) : signup(auth) + end + + def failure + session[:notice] = _('Failed to login') + redirect_to root_url + end + + def destroy + session[:user] = nil + redirect_to root_url + end + + protected + + def login(user) + provider = OauthClientPlugin::Provider.find(session[:provider_id]) + user_provider = user.oauth_user_providers.find_by_provider_id(provider.id) + unless user_provider + user_provider = user.oauth_user_providers.create(:user => user, :provider => provider, :enabled => true) + end + if user_provider.enabled? && provider.enabled? + session[:user] = user.id + else + session[:notice] = _("Can't login with #{provider.name}") + end + + redirect_to :controller => :account, :action => :login + end + + def signup(auth) + login = auth.info.email.split('@').first + session[:oauth_data] = auth + name = auth.info.name + name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' + redirect_to :controller => :account, :action => :signup, :user => {:login => login, :email => auth.info.email}, :profile_data => {:name => name} + end + +end diff --git a/plugins/oauth_client/db/migrate/20141010135314_create_oauth_client_plugin_provider.rb b/plugins/oauth_client/db/migrate/20141010135314_create_oauth_client_plugin_provider.rb new file mode 100644 index 0000000..ca156d6 --- /dev/null +++ b/plugins/oauth_client/db/migrate/20141010135314_create_oauth_client_plugin_provider.rb @@ -0,0 +1,19 @@ +class CreateOauthClientPluginProvider < ActiveRecord::Migration + + def self.up + create_table :oauth_client_plugin_providers do |t| + t.integer :environment_id + t.string :strategy + t.string :name + t.text :options + t.boolean :enabled + t.integer :image_id + + t.timestamps + end + end + + def self.down + drop_table :oauth_client_plugin_providers + end +end diff --git a/plugins/oauth_client/db/migrate/20141014162710_create_oauth_client_user_providers.rb b/plugins/oauth_client/db/migrate/20141014162710_create_oauth_client_user_providers.rb new file mode 100644 index 0000000..f1223f7 --- /dev/null +++ b/plugins/oauth_client/db/migrate/20141014162710_create_oauth_client_user_providers.rb @@ -0,0 +1,14 @@ +class CreateOauthClientUserProviders < ActiveRecord::Migration + def self.up + create_table :oauth_client_plugin_user_providers do |t| + t.references :user + t.references :provider + t.boolean :enabled + t.timestamps + end + end + + def self.down + drop_table :oauth_client_plugin_user_providers + end +end diff --git a/plugins/oauth_client/lib/ext/environment.rb b/plugins/oauth_client/lib/ext/environment.rb new file mode 100644 index 0000000..725221e --- /dev/null +++ b/plugins/oauth_client/lib/ext/environment.rb @@ -0,0 +1,7 @@ +require_dependency 'environment' + +class Environment + + has_many :oauth_providers, :class_name => 'OauthClientPlugin::Provider' + +end diff --git a/plugins/oauth_client/lib/ext/user.rb b/plugins/oauth_client/lib/ext/user.rb new file mode 100644 index 0000000..f2972a4 --- /dev/null +++ b/plugins/oauth_client/lib/ext/user.rb @@ -0,0 +1,31 @@ +require_dependency 'user' + +class User + + has_many :oauth_user_providers, :class_name => 'OauthClientPlugin::UserProvider' + has_many :oauth_providers, :through => :oauth_user_providers, :source => :provider + + def password_required_with_oauth? + password_required_without_oauth? && oauth_providers.empty? + end + + alias_method_chain :password_required?, :oauth + + after_create :activate_oauth_user + + def activate_oauth_user + unless oauth_providers.empty? + activate + oauth_providers.each do |provider| + OauthClientPlugin::UserProvider.create!(:user => self, :provider => provider, :enabled => true) + end + end + end + + def make_activation_code_with_oauth + oauth_providers.blank? ? make_activation_code_without_oauth : nil + end + + alias_method_chain :make_activation_code, :oauth + +end diff --git a/plugins/oauth_client/lib/oauth_client_plugin.rb b/plugins/oauth_client/lib/oauth_client_plugin.rb new file mode 100644 index 0000000..2b86e62 --- /dev/null +++ b/plugins/oauth_client/lib/oauth_client_plugin.rb @@ -0,0 +1,95 @@ +require 'omniauth/strategies/noosfero_oauth2' + +class OauthClientPlugin < Noosfero::Plugin + + def self.plugin_name + "Oauth Client Plugin" + end + + def self.plugin_description + _("Login with Oauth.") + end + + def login_extra_contents + plugin = self + proc do + render :partial => 'auth/oauth_login', :locals => {:providers => environment.oauth_providers.enabled} + end + end + + def signup_extra_contents + plugin = self + + proc do + if plugin.context.session[:oauth_data].present? + render :partial => 'account/oauth_signup' + else + '' + end + end + end + + PROVIDERS = { + :facebook => { + :name => 'Facebook' + }, + :google_oauth2 => { + :name => 'Google' + }, + :noosfero_oauth2 => { + :name => 'Noosfero' + } + } + + def stylesheet? + true + end + + OmniAuth.config.on_failure = OauthClientPluginPublicController.action(:failure) + + Rails.application.config.middleware.use OmniAuth::Builder do + PROVIDERS.each do |provider, options| + setup = lambda { |env| + request = Rack::Request.new(env) + strategy = env['omniauth.strategy'] + + Noosfero::MultiTenancy.setup!(request.host) + domain = Domain.find_by_name(request.host) + environment = domain.environment rescue Environment.default + + provider_id = request.params['id'] + provider_id ||= request.session['omniauth.params']['id'] if request.session['omniauth.params'] + provider = environment.oauth_providers.find(provider_id) + strategy.options.merge!(provider.options.symbolize_keys) + + request.session[:provider_id] = provider_id + } + + provider provider, :setup => setup, + :path_prefix => '/plugin/oauth_client', + :callback_path => "/plugin/oauth_client/public/callback/#{provider}", + :client_options => { :connection_opts => { :proxy => ENV["OAUTH_HTTP_PROXY"] } } + end + + unless Rails.env.production? + provider :developer, :path_prefix => "/plugin/oauth_client", :callback_path => "/plugin/oauth_client/public/callback/developer" + end + end + + def account_controller_filters + { + :type => 'before_filter', :method_name => 'signup', + :block => proc { + auth = session[:oauth_data] + + if auth.present? && params[:user].present? + params[:user][:oauth_providers] = [OauthClientPlugin::Provider.find(session[:provider_id])] + if request.post? && auth.info.email != params[:user][:email] + raise "Wrong email for oauth signup" + end + end + } + } + end + +end diff --git a/plugins/oauth_client/lib/oauth_client_plugin/provider.rb b/plugins/oauth_client/lib/oauth_client_plugin/provider.rb new file mode 100644 index 0000000..70a9892 --- /dev/null +++ b/plugins/oauth_client/lib/oauth_client_plugin/provider.rb @@ -0,0 +1,20 @@ +class OauthClientPlugin::Provider < Noosfero::Plugin::ActiveRecord + + belongs_to :environment + + validates_presence_of :name, :strategy + + acts_as_having_image + acts_as_having_settings :field => :options + + settings_items :client_id, :type => :string + settings_items :client_secret, :type => :string + settings_items :client_options, :type => Hash + + attr_accessible :name, :environment, :strategy, :client_id, :client_secret, :enabled, :client_options, :image_builder + + scope :enabled, :conditions => {:enabled => true} + + acts_as_having_image + +end diff --git a/plugins/oauth_client/lib/oauth_client_plugin/user_provider.rb b/plugins/oauth_client/lib/oauth_client_plugin/user_provider.rb new file mode 100644 index 0000000..77b2bda --- /dev/null +++ b/plugins/oauth_client/lib/oauth_client_plugin/user_provider.rb @@ -0,0 +1,10 @@ +class OauthClientPlugin::UserProvider < Noosfero::Plugin::ActiveRecord + + belongs_to :user, :class_name => 'User' + belongs_to :provider, :class_name => 'OauthClientPlugin::Provider' + + set_table_name :oauth_client_plugin_user_providers + + attr_accessible :user, :provider, :enabled + +end diff --git a/plugins/oauth_client/lib/omniauth/strategies/noosfero_oauth2.rb b/plugins/oauth_client/lib/omniauth/strategies/noosfero_oauth2.rb new file mode 100644 index 0000000..b223e53 --- /dev/null +++ b/plugins/oauth_client/lib/omniauth/strategies/noosfero_oauth2.rb @@ -0,0 +1,26 @@ +require 'omniauth/strategies/oauth2' + +module OmniAuth + module Strategies + class NoosferoOauth2 < OmniAuth::Strategies::OAuth2 + option :name, :noosfero_oauth2 + option :client_options, { + :authorize_url => '/oauth_provider/oauth/authorize', + :token_url => '/oauth_provider/oauth/token' + } + + uid { raw_info["id"] } + + info do + { + :email => raw_info["email"] + } + end + + def raw_info + #FIXME access the noosfero api (coming soon) + @raw_info ||= access_token.get('/plugin/oauth_provider/public/me').parsed + end + end + end +end diff --git a/plugins/oauth_client/public/style.css b/plugins/oauth_client/public/style.css new file mode 100644 index 0000000..ae24d04 --- /dev/null +++ b/plugins/oauth_client/public/style.css @@ -0,0 +1,18 @@ +.oauth-login .provider a { + min-width: 20px; + min-height: 20px; + background-size: 20px; + display: inline-block; + text-decoration: none; + background-repeat: no-repeat; + line-height: 20px; +} +.oauth-login .provider a img { + max-width: 40px; +} +.oauth-login .provider a:hover { + opacity: 0.7; +} +.oauth-login .provider .developer { + display: none; +} diff --git a/plugins/oauth_client/test/functional/oauth_client_plugin_public_controller_test.rb b/plugins/oauth_client/test/functional/oauth_client_plugin_public_controller_test.rb new file mode 100644 index 0000000..3f81251 --- /dev/null +++ b/plugins/oauth_client/test/functional/oauth_client_plugin_public_controller_test.rb @@ -0,0 +1,80 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class OauthClientPluginPublicControllerTest < ActionController::TestCase + + def setup + @auth = mock + @auth.stubs(:info).returns(mock) + request.env["omniauth.auth"] = @auth + @environment = Environment.default + @provider = OauthClientPlugin::Provider.create!(:name => 'provider', :strategy => 'provider', :enabled => true) + end + attr_reader :auth, :environment, :provider + + should 'redirect to signup when user is not found' do + auth.info.stubs(:email).returns("xyz123@noosfero.org") + auth.info.stubs(:name).returns('xyz123') + session[:provider_id] = provider.id + + get :callback + assert_match /.*\/account\/signup/, @response.redirect_url + end + + should 'redirect to login when user is found' do + user = fast_create(User, :environment_id => environment.id) + auth.info.stubs(:email).returns(user.email) + auth.info.stubs(:name).returns(user.name) + session[:provider_id] = provider.id + + get :callback + assert_redirected_to :controller => :account, :action => :login + assert_equal user.id, session[:user] + end + + should 'do not login when the provider is disabled' do + user = fast_create(User, :environment_id => environment.id) + auth.info.stubs(:email).returns(user.email) + auth.info.stubs(:name).returns(user.name) + session[:provider_id] = provider.id + provider.update_attribute(:enabled, false) + + get :callback + assert_redirected_to :controller => :account, :action => :login + assert_equal nil, session[:user] + end + + should 'do not login when the provider is disabled for a user' do + user = fast_create(User, :environment_id => environment.id) + auth.info.stubs(:email).returns(user.email) + auth.info.stubs(:name).returns(user.name) + session[:provider_id] = provider.id + user.oauth_user_providers.create(:user => user, :provider => provider, :enabled => false) + + get :callback + assert_redirected_to :controller => :account, :action => :login + assert_equal nil, session[:user] + end + + should 'save provider when an user login with it' do + user = fast_create(User, :environment_id => environment.id) + auth.info.stubs(:email).returns(user.email) + auth.info.stubs(:name).returns(user.name) + session[:provider_id] = provider.id + + get :callback + assert_equal [provider], user.oauth_providers + end + + should 'do not duplicate relations between an user and a provider when the same provider was used again in a login' do + user = fast_create(User, :environment_id => environment.id) + auth.info.stubs(:email).returns(user.email) + auth.info.stubs(:name).returns(user.name) + session[:provider_id] = provider.id + + get :callback + assert_no_difference 'user.oauth_user_providers.count' do + 3.times { get :callback } + end + end + +end diff --git a/plugins/oauth_client/test/test_helper.rb b/plugins/oauth_client/test/test_helper.rb new file mode 100644 index 0000000..cca1fd3 --- /dev/null +++ b/plugins/oauth_client/test/test_helper.rb @@ -0,0 +1 @@ +require File.dirname(__FILE__) + '/../../../test/test_helper' diff --git a/plugins/oauth_client/test/unit/environment_test.rb b/plugins/oauth_client/test/unit/environment_test.rb new file mode 100644 index 0000000..f47f5e3 --- /dev/null +++ b/plugins/oauth_client/test/unit/environment_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class UserTest < ActiveSupport::TestCase + + should 'be able to add oauth providers in a environment' do + env = fast_create(Environment) + env.oauth_providers << OauthClientPlugin::Provider.new(:name => 'test', :strategy => 'test') + end + +end diff --git a/plugins/oauth_client/test/unit/oauth_client_plugin_test.rb b/plugins/oauth_client/test/unit/oauth_client_plugin_test.rb new file mode 100644 index 0000000..58eaa55 --- /dev/null +++ b/plugins/oauth_client/test/unit/oauth_client_plugin_test.rb @@ -0,0 +1,86 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class OauthClientPluginTest < ActiveSupport::TestCase + + def setup + @plugin = OauthClientPlugin.new(self) + @params = {} + @plugin.stubs(:context).returns(self) + @environment = Environment.default + @session = {} + @request = mock + @provider = OauthClientPlugin::Provider.create!(:name => 'name', :strategy => 'strategy') + end + + attr_reader :params, :plugin, :environment, :session, :request, :provider + + should 'has extra contents for login' do + assert plugin.login_extra_contents + end + + should 'has no signup extra contents if no provider was enabled' do + assert_equal '', instance_eval(&plugin.signup_extra_contents) + end + + should 'has signup extra contents if oauth_data exists in session' do + session[:oauth_data] = {:oauth => 'test'} + expects(:render).with(:partial => 'account/oauth_signup').once + instance_eval(&plugin.signup_extra_contents) + end + + should 'define before filter for account controller' do + assert plugin.account_controller_filters + end + + should 'raise error if oauth email was changed' do + request.expects(:post?).returns(true) + + oauth_data = mock + info = mock + oauth_data.stubs(:info).returns(info) + oauth_data.stubs(:uid).returns('uid') + oauth_data.stubs(:provider).returns('provider') + info.stubs(:email).returns('test@example.com') + session[:oauth_data] = oauth_data + session[:provider_id] = provider.id + + params[:user] = {:email => 'test2@example.com'} + assert_raises RuntimeError do + instance_eval(&plugin.account_controller_filters[:block]) + end + end + + should 'do not raise error if oauth email was not changed' do + request.expects(:post?).returns(true) + + oauth_data = mock + info = mock + oauth_data.stubs(:info).returns(info) + oauth_data.stubs(:uid).returns('uid') + oauth_data.stubs(:provider).returns('provider') + info.stubs(:email).returns('test@example.com') + session[:oauth_data] = oauth_data + session[:provider_id] = provider.id + + params[:user] = {:email => 'test@example.com'} + instance_eval(&plugin.account_controller_filters[:block]) + end + + should 'do not raise error if oauth session is not set' do + instance_eval(&plugin.account_controller_filters[:block]) + end + + should 'do not raise error if it is not a post' do + request.expects(:post?).returns(false) + params[:user] = {:email => 'test2@example.com'} + + oauth_data = mock + oauth_data.stubs(:uid).returns('uid') + oauth_data.stubs(:provider).returns('provider') + session[:provider_id] = provider.id + + session[:oauth_data] = oauth_data + instance_eval(&plugin.account_controller_filters[:block]) + end + +end diff --git a/plugins/oauth_client/test/unit/user_test.rb b/plugins/oauth_client/test/unit/user_test.rb new file mode 100644 index 0000000..f4bda17 --- /dev/null +++ b/plugins/oauth_client/test/unit/user_test.rb @@ -0,0 +1,40 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class UserTest < ActiveSupport::TestCase + + def setup + @provider = OauthClientPlugin::Provider.create!(:name => 'name', :strategy => 'strategy') + end + attr_reader :provider + + should 'password is not required if there is a oauth provider' do + User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [provider]) + end + + should 'password is required if there is a oauth provider' do + user = User.new(:email => 'testoauth@example.com', :login => 'testoauth') + user.save + assert user.errors[:password].present? + end + + should 'activate user when created with oauth' do + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [provider]) + assert user.activated? + end + + should 'not activate user when created without oauth' do + user = fast_create(User) + assert !user.activated? + end + + should 'not make activation code when created with oauth' do + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [provider]) + assert !user.activation_code + end + + should 'make activation code when created without oauth' do + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :password => 'test', :password_confirmation => 'test') + assert user.activation_code + end + +end diff --git a/plugins/oauth_client/views/account/_oauth_signup.html.erb b/plugins/oauth_client/views/account/_oauth_signup.html.erb new file mode 100644 index 0000000..346c0dd --- /dev/null +++ b/plugins/oauth_client/views/account/_oauth_signup.html.erb @@ -0,0 +1,11 @@ +<%= hidden_field_tag 'return_to', '/' %> + + + +
+ <%= labelled_form_field(_('Email'), text_field(:user, :email, :class => "disabled", :readonly => true)) %> +
diff --git a/plugins/oauth_client/views/auth/_oauth_login.html.erb b/plugins/oauth_client/views/auth/_oauth_login.html.erb new file mode 100644 index 0000000..209b21a --- /dev/null +++ b/plugins/oauth_client/views/auth/_oauth_login.html.erb @@ -0,0 +1,16 @@ +
+ <% unless providers.empty? %> + <%= _('Login with:') %> + <% end %> + <% providers.each do |provider| %> + + <%= link_to provider.image ? image_tag(provider.image.public_filename) : provider.name, "/plugin/oauth_client/#{provider.strategy}?id=#{provider.id}", :class => provider.strategy, :title => provider.name %> + + <% end %> + + + <% unless Rails.env.production? %> + <%= link_to _('Developer Login'), "/plugin/oauth_client/developer", :class => 'developer' %> + <% end %> + +
diff --git a/plugins/oauth_client/views/oauth_client_plugin_admin/_noosfero_oauth2.html.erb b/plugins/oauth_client/views/oauth_client_plugin_admin/_noosfero_oauth2.html.erb new file mode 100644 index 0000000..6928d7a --- /dev/null +++ b/plugins/oauth_client/views/oauth_client_plugin_admin/_noosfero_oauth2.html.erb @@ -0,0 +1,5 @@ +<%= f.fields_for :client_options, OpenStruct.new(provider.options[:client_options]) do |c| %> +
+ <%= labelled_form_field _('Client Url'), c.text_field(:site) %> +
+<% end %> diff --git a/plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb b/plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb new file mode 100644 index 0000000..0848bf9 --- /dev/null +++ b/plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb @@ -0,0 +1,39 @@ +

<%= _('Oauth Client Settings') %>

+

<%= _('Edit Provider') %>

+ +<%= form_for @provider, :url => {:action => 'edit'}, :method => 'post' do |f| %> + +
+ <%= labelled_form_field f.check_box(:enabled) + _('Enabled'), '' %> +
+ +
+ <%= labelled_form_field _('Name'), f.text_field(:name) %> +
+ +
+ <%= labelled_form_field _('Strategy'), f.select(:strategy, OauthClientPlugin::PROVIDERS) %> +
+ +
+ <%= labelled_form_field _('Client Id'), f.text_field(:client_id) %> +
+ +
+ <%= labelled_form_field _('Client Secret'), f.text_field(:client_secret) %> +
+ + <% if File.exists?(File.join(File.dirname(__FILE__), "_#{@provider.strategy}.html.erb")) %> + <%= render :partial => "#{@provider.strategy}", :locals => {:f => f, :provider => @provider} %> + <% end %> + +
+ <%= f.fields_for :image_builder, @provider.image do |i| %> + <%= file_field_or_thumbnail(_('Image:'), @provider.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %> + <% end %> +
+ + <% button_bar do %> + <%= submit_button(:save, _('Save'), :cancel => {:action => 'index'}) %> + <% end %> +<% end %> diff --git a/plugins/oauth_client/views/oauth_client_plugin_admin/index.html.erb b/plugins/oauth_client/views/oauth_client_plugin_admin/index.html.erb new file mode 100644 index 0000000..98b3ce1 --- /dev/null +++ b/plugins/oauth_client/views/oauth_client_plugin_admin/index.html.erb @@ -0,0 +1,24 @@ +

<%= _('Oauth Client Settings') %>

+

<%= _('Providers') %>

+<%= button :add, _('New'), {:action => 'new'} %> + + + + + + + + <% environment.oauth_providers.each do |provider| %> + + + + + + <% end %> +
<%= _('Name') %><%= _('Strategy') %><%= _('Actions') %>
<%= provider.name %><%= provider.strategy %> + <%= link_to _('Edit'), {:action => 'edit', :id => provider.id} %> + <%= link_to _('Remove'), {:action => 'remove', :id => provider.id} %> +
+
+ <%= button(:back, _('Go back'), {:controller => 'plugins', :action => 'index'}) %> +
-- libgit2 0.21.2