ffcrm_authlogic_api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'fat_free_crm'
4
+
5
+ gemspec
@@ -0,0 +1,196 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ffcrm_authlogic_api (0.1.0)
5
+ authlogic
6
+ fat_free_crm
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.2)
12
+ actionpack (= 3.2.2)
13
+ mail (~> 2.4.0)
14
+ actionpack (3.2.2)
15
+ activemodel (= 3.2.2)
16
+ activesupport (= 3.2.2)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.1)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.1)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.1.2)
24
+ activemodel (3.2.2)
25
+ activesupport (= 3.2.2)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.2)
28
+ activemodel (= 3.2.2)
29
+ activesupport (= 3.2.2)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.2)
33
+ activemodel (= 3.2.2)
34
+ activesupport (= 3.2.2)
35
+ activesupport (3.2.2)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ acts-as-taggable-on (2.2.2)
39
+ rails (~> 3.0)
40
+ acts_as_commentable (3.0.1)
41
+ acts_as_list (0.1.5)
42
+ ajax-chosen-rails (0.1.5)
43
+ chosen-rails
44
+ railties (~> 3.0)
45
+ thor (~> 0.14)
46
+ arel (3.0.2)
47
+ authlogic (3.1.0)
48
+ activerecord (>= 3.0.7)
49
+ activerecord (>= 3.0.7)
50
+ builder (3.0.0)
51
+ capybara (1.1.2)
52
+ mime-types (>= 1.16)
53
+ nokogiri (>= 1.3.3)
54
+ rack (>= 1.0.0)
55
+ rack-test (>= 0.5.4)
56
+ selenium-webdriver (~> 2.0)
57
+ xpath (~> 0.1.4)
58
+ childprocess (0.3.1)
59
+ ffi (~> 1.0.6)
60
+ chosen-rails (0.9.8)
61
+ railties (~> 3.0)
62
+ thor (~> 0.14)
63
+ cocaine (0.2.1)
64
+ combustion (0.3.2)
65
+ rails (>= 3.0.0)
66
+ thor (>= 0.14.6)
67
+ diff-lcs (1.1.3)
68
+ erubis (2.7.0)
69
+ execjs (1.3.0)
70
+ multi_json (~> 1.0)
71
+ fat_free_crm (0.11.0)
72
+ acts-as-taggable-on (~> 2.2.1)
73
+ acts_as_commentable (~> 3.0.1)
74
+ acts_as_list (~> 0.1.4)
75
+ ajax-chosen-rails (>= 0.1.5)
76
+ authlogic (~> 3.1.0)
77
+ chosen-rails
78
+ ffaker (>= 1.12.0)
79
+ haml (~> 3.1.3)
80
+ jquery-rails
81
+ paper_trail
82
+ paperclip (~> 2.5.2)
83
+ prototype-rails
84
+ rails (~> 3.2.2)
85
+ ransack
86
+ sass (~> 3.1.15)
87
+ simple_form (~> 1.5.2)
88
+ uglifier
89
+ will_paginate (~> 3.0.2)
90
+ ffaker (1.13.0)
91
+ ffi (1.0.11)
92
+ haml (3.1.4)
93
+ hike (1.2.1)
94
+ i18n (0.6.0)
95
+ journey (1.0.3)
96
+ jquery-rails (2.0.1)
97
+ railties (>= 3.2.0, < 5.0)
98
+ thor (~> 0.14)
99
+ json (1.6.5)
100
+ mail (2.4.4)
101
+ i18n (>= 0.4.0)
102
+ mime-types (~> 1.16)
103
+ treetop (~> 1.4.8)
104
+ mime-types (1.18)
105
+ multi_json (1.1.0)
106
+ nokogiri (1.5.2)
107
+ paper_trail (2.6.2)
108
+ rails (~> 3)
109
+ paperclip (2.5.2)
110
+ activerecord (>= 2.3.0)
111
+ activesupport (>= 2.3.2)
112
+ cocaine (>= 0.0.2)
113
+ mime-types
114
+ polyamorous (0.5.0)
115
+ activerecord (~> 3.0)
116
+ polyglot (0.3.3)
117
+ prototype-rails (3.2.1)
118
+ rails (~> 3.2)
119
+ rack (1.4.1)
120
+ rack-cache (1.2)
121
+ rack (>= 0.4)
122
+ rack-ssl (1.3.2)
123
+ rack
124
+ rack-test (0.6.1)
125
+ rack (>= 1.0)
126
+ rails (3.2.2)
127
+ actionmailer (= 3.2.2)
128
+ actionpack (= 3.2.2)
129
+ activerecord (= 3.2.2)
130
+ activeresource (= 3.2.2)
131
+ activesupport (= 3.2.2)
132
+ bundler (~> 1.0)
133
+ railties (= 3.2.2)
134
+ railties (3.2.2)
135
+ actionpack (= 3.2.2)
136
+ activesupport (= 3.2.2)
137
+ rack-ssl (~> 1.3.2)
138
+ rake (>= 0.8.7)
139
+ rdoc (~> 3.4)
140
+ thor (~> 0.14.6)
141
+ rake (0.9.2.2)
142
+ ransack (0.6.0)
143
+ actionpack (~> 3.0)
144
+ activerecord (~> 3.0)
145
+ polyamorous (~> 0.5.0)
146
+ rdoc (3.12)
147
+ json (~> 1.4)
148
+ rspec (2.9.0)
149
+ rspec-core (~> 2.9.0)
150
+ rspec-expectations (~> 2.9.0)
151
+ rspec-mocks (~> 2.9.0)
152
+ rspec-core (2.9.0)
153
+ rspec-expectations (2.9.0)
154
+ diff-lcs (~> 1.1.3)
155
+ rspec-mocks (2.9.0)
156
+ rspec-rails (2.9.0)
157
+ actionpack (>= 3.0)
158
+ activesupport (>= 3.0)
159
+ railties (>= 3.0)
160
+ rspec (~> 2.9.0)
161
+ rubyzip (0.9.6.1)
162
+ sass (3.1.15)
163
+ selenium-webdriver (2.20.0)
164
+ childprocess (>= 0.2.5)
165
+ ffi (~> 1.0)
166
+ multi_json (~> 1.0)
167
+ rubyzip
168
+ simple_form (1.5.2)
169
+ actionpack (~> 3.0)
170
+ activemodel (~> 3.0)
171
+ sprockets (2.1.2)
172
+ hike (~> 1.2)
173
+ rack (~> 1.0)
174
+ tilt (~> 1.1, != 1.3.0)
175
+ thor (0.14.6)
176
+ tilt (1.3.3)
177
+ treetop (1.4.10)
178
+ polyglot
179
+ polyglot (>= 0.3.1)
180
+ tzinfo (0.3.32)
181
+ uglifier (1.2.3)
182
+ execjs (>= 0.3.0)
183
+ multi_json (>= 1.0.2)
184
+ will_paginate (3.0.3)
185
+ xpath (0.1.4)
186
+ nokogiri (~> 1.3)
187
+
188
+ PLATFORMS
189
+ ruby
190
+
191
+ DEPENDENCIES
192
+ capybara
193
+ combustion
194
+ fat_free_crm
195
+ ffcrm_authlogic_api!
196
+ rspec-rails (~> 2.6)
@@ -0,0 +1,41 @@
1
+ # CRM Authlogic API
2
+ ===================
3
+
4
+ This plugin enables applications to authenticate with Fat Free CRM using
5
+ the Authlogic `single_access_token` method. Credit to http://blog.smsohan.com/2010/04/using-authlogic-and-single-access-token.html for reference information whilst building this.
6
+
7
+ ## Installation
8
+
9
+ * Install this plugin into your Fat Free CRM vendor/plugins folder and run
10
+ `rake db:migrate:plugins`. This will create the application_accounts table.
11
+ * For your controller action, you need to remove the `require_user` authentication layer and add a `require_application` before_filter.
12
+
13
+ ````ruby
14
+ skip_before_filter :require_user, :only => :my_action
15
+ before_filter :require_application, :only => :my_action
16
+ ````
17
+ * Pop the following method in your application_controller
18
+
19
+ ````ruby
20
+ def require_application
21
+ @current_application_session ||= ApplicationSession.find
22
+ unless @current_application_session
23
+ redirect_to login_url
24
+ false
25
+ end
26
+ end
27
+ ````
28
+
29
+ * Start up Fat Free CRM and go to the "App API" tab in the Admin section.
30
+ * Create an application account and give it a token.
31
+ * Your external app may now connect using http://path.to/your/controller/action?app_key=your_app_token
32
+
33
+ Where `your_app_token` is the token specified in the previous step.
34
+
35
+ ## TODO
36
+
37
+ * Add `require_application` function to `ApplicationController` automagically
38
+ * Improve formatting of *App API* screen.
39
+ * Add more tests.
40
+
41
+ Copyright (c) 2011 Global Hand, released under the MIT license
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ Bundler.require :default, :development
8
+
9
+ task :environment do
10
+ Combustion.initialize!
11
+ end
12
+ Combustion::Application.load_tasks
13
+
14
+ class Combustion::Application
15
+ # Add migrations from all engines
16
+ Railties.engines.each do |engine|
17
+ config.paths['db/migrate'] += engine.paths['db/migrate'].existent
18
+ end
19
+ end
20
+
21
+ require "rspec/core/rake_task"
22
+ RSpec::Core::RakeTask.new(:spec) do |spec|
23
+ spec.pattern = Dir.glob(['spec/sitemap_generator/**/*'])
24
+ spec.rspec_opts = ['--backtrace']
25
+ end
26
+
27
+ desc 'Default: run spec tests.'
28
+ task :default => :spec
29
+
30
+ # Let Combustion handle database preparation
31
+ Rake::Task["spec"].prerequisites.clear
32
+
33
+ Bundler::GemHelper.install_tasks
34
+
@@ -0,0 +1,56 @@
1
+ class Admin::ApplicationAccountsController < Admin::ApplicationController
2
+ before_filter :require_user
3
+ before_filter "set_current_tab('admin/application_accounts')", :only => [ :index ]
4
+
5
+ # GET /admin/application_accounts
6
+ #----------------------------------------------------------------------------
7
+ def index
8
+ @application_accounts = ApplicationAccount.order(:created_at)
9
+ respond_to do |format|
10
+ format.html # index.html.haml
11
+ end
12
+ end
13
+
14
+ # POST /admin/application_accounts
15
+ #----------------------------------------------------------------------------
16
+ def create
17
+ @application_account = ApplicationAccount.new(params["application_account"])
18
+ respond_to do |format|
19
+ if @application_account.save
20
+ flash[:notice] = 'New application account created'
21
+ else
22
+ flash[:notice] = 'There was error creating the application account.'
23
+ end
24
+ format.html { redirect_to :action => :index } # go back to index.haml
25
+ end
26
+ end
27
+
28
+ # PUT /admin/application_accounts/1
29
+ #----------------------------------------------------------------------------
30
+ def update
31
+ @application_account = ApplicationAccount.find(params["id"])
32
+ @application_account.attributes = params["application_account"]
33
+ respond_to do |format|
34
+ if @application_account.save
35
+ flash[:notice] = 'New application account created'
36
+ else
37
+ flash[:notice] = 'Please fill out the name and token'
38
+ end
39
+ format.html { redirect_to :action => :index } # go back to index.haml
40
+ end
41
+ end
42
+
43
+ # DELETE /admin/application_accounts/1
44
+ #----------------------------------------------------------------------------
45
+ def destroy
46
+ @application_account = ApplicationAccount.find(params["id"])
47
+ respond_to do |format|
48
+ if @application_account.destroy
49
+ flash[:notice] = 'Application account deleted'
50
+ else
51
+ flash[:notice] = 'There was error deleting the application account.'
52
+ end
53
+ format.html { redirect_to :action => :index } # go back to index.haml
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationAccount < ActiveRecord::Base
2
+ validates :name, :presence => true
3
+ end
@@ -0,0 +1,8 @@
1
+ class ApplicationSession < Authlogic::Session::Base
2
+ authenticate_with ApplicationAccount
3
+
4
+ params_key :app_key
5
+ login_field false
6
+
7
+ single_access_allowed_request_types :any
8
+ end
@@ -0,0 +1,25 @@
1
+ .title
2
+ = t(:application_account_settings, :default => "Application Account Settings")
3
+
4
+ .list
5
+ .remote
6
+ .section
7
+ - @application_accounts.each do |account|
8
+ = form_tag admin_application_account_path(account), :method => :put do
9
+ .label.top.req Application name:
10
+ = text_field_tag 'application_account[name]', account.name, :style => "width:100px"
11
+ .label.top.req Token:
12
+ = text_field_tag 'application_account[single_access_token]', account.single_access_token, :style => "width:150px"
13
+ = submit_tag 'Update', :name => :update, :style => "width:60px"
14
+ = button_to 'Delete', admin_application_account_path(account.id), :method => "delete", :style => "width:60px"
15
+ .spacer
16
+
17
+ .section
18
+ %div
19
+ = t('.create_new_application_key', :default => "Create a new application key")
20
+ = form_tag admin_application_accounts_path, :method => :post do
21
+ .label.top.req Application name:
22
+ = text_field_tag 'application_account[name]', '', :style => "width:100px"
23
+ .label.top.req Token:
24
+ = text_field_tag 'application_account[single_access_token]', '', :style => "width:150px"
25
+ = submit_tag t('.create', :default => 'Create'), :name => :create
@@ -0,0 +1,5 @@
1
+ FatFreeCRM::Application.routes.draw do
2
+ namespace :admin do
3
+ resources :application_accounts
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ class CreateApplicationAccounts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :application_accounts do |t|
4
+ t.string :name
5
+ t.string :single_access_token, :null => false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :application_accounts
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'ffcrm_authlogic_api/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'ffcrm_authlogic_api'
7
+ s.authors = ['Ben Tillman', 'Nathan Broadbent', 'Stephen Kenworthy']
8
+ s.summary = 'Fat Free CRM - Authlogic Token API'
9
+ s.description = 'Allow authentication via an application token '
10
+ s.files = `git ls-files`.split("\n")
11
+ s.version = FatFreeCRM::AuthlogicAPI::VERSION
12
+
13
+ s.add_development_dependency 'rspec-rails', '~> 2.6'
14
+ s.add_development_dependency 'capybara'
15
+ s.add_development_dependency 'combustion'
16
+ s.add_dependency 'fat_free_crm'
17
+ s.add_dependency 'authlogic'
18
+ end
@@ -0,0 +1 @@
1
+ require 'ffcrm_authlogic_api/engine'
@@ -0,0 +1,16 @@
1
+ module FatFreeCRM
2
+ module AuthlogicAPI
3
+ class Engine < Rails::Engine
4
+ config.to_prepare do
5
+ begin
6
+ FatFreeCRM::Tabs.admin << {
7
+ :text => "Application Tokens",
8
+ :url => { :controller => "admin/application_accounts" }
9
+ }
10
+ rescue TypeError
11
+ puts "You must migrate your settings table."
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module FatFreeCRM
2
+ module AuthlogicAPI
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffcrm_authlogic_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ben Tillman
9
+ - Nathan Broadbent
10
+ - Stephen Kenworthy
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-03-29 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec-rails
18
+ requirement: &84984190 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: '2.6'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *84984190
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: &84983950 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *84983950
38
+ - !ruby/object:Gem::Dependency
39
+ name: combustion
40
+ requirement: &84983610 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *84983610
49
+ - !ruby/object:Gem::Dependency
50
+ name: fat_free_crm
51
+ requirement: &84983250 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: *84983250
60
+ - !ruby/object:Gem::Dependency
61
+ name: authlogic
62
+ requirement: &84982940 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: *84982940
71
+ description: ! 'Allow authentication via an application token '
72
+ email:
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - README.md
80
+ - Rakefile
81
+ - app/controllers/admin/application_accounts_controller.rb
82
+ - app/models/application_account.rb
83
+ - app/models/application_session.rb
84
+ - app/views/admin/application_accounts/index.html.haml
85
+ - config/routes.rb
86
+ - db/migrate/20101111031046_create_application_accounts.rb
87
+ - ffcrm_authlogic_api.gemspec
88
+ - lib/ffcrm_authlogic_api.rb
89
+ - lib/ffcrm_authlogic_api/engine.rb
90
+ - lib/ffcrm_authlogic_api/version.rb
91
+ homepage:
92
+ licenses: []
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ segments:
104
+ - 0
105
+ hash: -1058569375
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
113
+ - 0
114
+ hash: -1058569375
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.17
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Fat Free CRM - Authlogic Token API
121
+ test_files: []