vline-rails 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +177 -0
- data/README.md +90 -0
- data/Rakefile +38 -0
- data/lib/generators/vline_provider/templates/controller.rb +85 -0
- data/lib/generators/vline_provider/templates/initializer.rb +12 -0
- data/lib/generators/vline_provider/vline_provider_generator.rb +60 -0
- data/lib/vline.rb +196 -0
- data/lib/vline/version.rb +3 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +65 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +31 -0
- data/test/dummy/config/environments/production.rb +64 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +10 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_helper.rb +15 -0
- data/test/vline_test.rb +7 -0
- metadata +179 -0
data/LICENSE
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# vLineRails Plugin
|
2
|
+
|
3
|
+
vLineRails is a plugin that allows any Rails app to act as a vLine Identity Provider. Every vLine application instance
|
4
|
+
has at least one registered Identity Provider, which is responsible for authenticating users and providing access to their
|
5
|
+
contact lists and group memberships. The [Identity Provider interface](https://vline.com/developer/docs/identity_providers)
|
6
|
+
is a subset of OAuth 2.0 and OpenSocial 2.5.
|
7
|
+
|
8
|
+
Learn more about vLine applications at: https://vline.com/developer
|
9
|
+
|
10
|
+
## Before you begin
|
11
|
+
|
12
|
+
Before installing the plugin, you'll need to:
|
13
|
+
|
14
|
+
1. Sign up for a vLine account at https://vline.com
|
15
|
+
|
16
|
+
2. Login to the [Developer Console](https://vline.com/developer) and click `Create Application`
|
17
|
+
|
18
|
+
3. Choose a name for your application.
|
19
|
+
|
20
|
+
## Testing Locally
|
21
|
+
|
22
|
+
For the vLine servers to be able to make api calls to your provider, your rails app will need to be running on a
|
23
|
+
publicly accessible server. If your development server is behind a firewall, you can make it publicly accessible
|
24
|
+
with [Forward](http://forwardhq.com):
|
25
|
+
|
26
|
+
gem install forward
|
27
|
+
forward 3000
|
28
|
+
|
29
|
+
If your provider suddenly stops working, check to make sure forward is still running and
|
30
|
+
your server is accessible at the forward url.
|
31
|
+
|
32
|
+
## Installation (Rails 3.0)
|
33
|
+
|
34
|
+
1. Add the plugin to your Gemfile:
|
35
|
+
|
36
|
+
gem 'vline-rails'
|
37
|
+
|
38
|
+
1. Install it:
|
39
|
+
|
40
|
+
bundle install
|
41
|
+
|
42
|
+
1. Generate the provider by running the following command:
|
43
|
+
|
44
|
+
rails generate vline_provider --app-id=Your-App-Id --provider-secret=Your-App-Secret
|
45
|
+
|
46
|
+
Make note of the `Client Id` and `Client Secret` output by the command.
|
47
|
+
|
48
|
+
1. Review the generated VlineProviderController, making any changes necessary to work with your models, authentication
|
49
|
+
framework, and authorization framework.
|
50
|
+
|
51
|
+
vim app/controllers/vline_controller.rb
|
52
|
+
|
53
|
+
## Configure your app
|
54
|
+
|
55
|
+
1. Open up the vLine Developer Console and choose `Hosted App Settings`.
|
56
|
+
|
57
|
+
1. You'll notice there are default URLs set for images used by the app. You can leave these as-is or change them to
|
58
|
+
custom images for your app.
|
59
|
+
|
60
|
+
1. Select `Custom OAuth` in the `Authorization` dropdown:
|
61
|
+
* Add the `Client Id` and `Client Secret` from the `rails generate` command you previously ran.
|
62
|
+
* Set the `Provider URL` to : `https://your-forward-url/_vline/api/v1/`
|
63
|
+
* Set the `OAuth URL` to: `https://your-forward-url/_vline/api/v1/oauth/`
|
64
|
+
|
65
|
+
|
66
|
+
## Usage
|
67
|
+
|
68
|
+
You can now launch into your vLine application from any view.
|
69
|
+
|
70
|
+
To launch to the application home page:
|
71
|
+
|
72
|
+
<%= vline_launch 'Launch' %>
|
73
|
+
|
74
|
+
To launch to a particular user's chat page:
|
75
|
+
|
76
|
+
<%= vline_launch 'Launch', @userId %>
|
77
|
+
|
78
|
+
## Notes
|
79
|
+
|
80
|
+
* If you are using the Deflater gem to gzip content, make sure it comes before `Rack::JSONP` in the `config.ru`:
|
81
|
+
|
82
|
+
require 'rack/jsonp'
|
83
|
+
use Rack::Deflater
|
84
|
+
use Rack::JSONP
|
85
|
+
require ::File.expand_path('../config/environment', __FILE__)
|
86
|
+
run YourApp::Application
|
87
|
+
|
88
|
+
* It's common to need to test changes before rolling them out directly to your users. We suggest creating two vLine
|
89
|
+
applications, one of which you can use to test out changes before rolling them out to your users (e.g.,
|
90
|
+
`myapp` and `myapp-dev`).
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'VlineRails'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
task :default => :test
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'vline'
|
3
|
+
|
4
|
+
class VlineController < ApplicationController
|
5
|
+
# require login
|
6
|
+
<%= login_filter %>
|
7
|
+
|
8
|
+
def initialize(currentUserId = nil)
|
9
|
+
if currentUserId
|
10
|
+
@current_user ||= find_user(currentUserId)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def launch(userId=nil)
|
15
|
+
if params[:userId]
|
16
|
+
userId = params[:userId]
|
17
|
+
end
|
18
|
+
redirect_to Vline.launch_url_for(current_user.id, userId)
|
19
|
+
end
|
20
|
+
|
21
|
+
def authorize
|
22
|
+
if params[:client_id] != Vline.client_id
|
23
|
+
redirect_to Vline.auth_error_redirect_url(Vline::AuthError::ACCESS_DENIED, params[:state])
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
if params[:response_type] != 'code'
|
28
|
+
redirect_to Vline.auth_error_redirect_url(Vline::AuthError::INVALID_REQUEST, params[:state])
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
# NOTE: we ignore "scope" and "redirect_uri"
|
33
|
+
|
34
|
+
code = Vline.create_request_token(current_user.id)
|
35
|
+
|
36
|
+
url = Vline.auth_url + "?code=" + code
|
37
|
+
if params[:state]
|
38
|
+
url += "&state=" + params[:state]
|
39
|
+
end
|
40
|
+
redirect_to url
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_profile(userId)
|
44
|
+
user = find_user(userId)
|
45
|
+
profile_for(user)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_contact_profiles(userId)
|
49
|
+
users = find_contact_users(userId)
|
50
|
+
users.map { |u| profile_for(u) }
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def find_user(userId)
|
56
|
+
User.find(userId)
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_contact_users(userId)
|
60
|
+
User.all
|
61
|
+
end
|
62
|
+
|
63
|
+
def profile_for(user)
|
64
|
+
profile = {'id' => user.id, 'displayName' => user.name}
|
65
|
+
thumbnailUrl = thumbnail_url_for(user)
|
66
|
+
if thumbnailUrl
|
67
|
+
profile['thumbnailUrl'] = thumbnail_url_for(user)
|
68
|
+
end
|
69
|
+
profile
|
70
|
+
end
|
71
|
+
|
72
|
+
def thumbnail_url_for(user)
|
73
|
+
if user.respond_to?('thumbnail_url')
|
74
|
+
user.thumbnail_url
|
75
|
+
elsif user.respond_to?('email')
|
76
|
+
gravatar_url_for(user.email)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def gravatar_url_for(email)
|
81
|
+
# see http://en.gravatar.com/site/implement/images/
|
82
|
+
hash = Digest::MD5.hexdigest(email.downcase)
|
83
|
+
"https://www.gravatar.com/avatar/#{hash}?d=mm"
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'vline'
|
2
|
+
|
3
|
+
Vline.setup do |config|
|
4
|
+
|
5
|
+
config.app_id = '<%= options.app_id %>'
|
6
|
+
config.provider_id = '<%= options.app_id %>'
|
7
|
+
config.client_id = '<%= options.client_id %>'
|
8
|
+
|
9
|
+
# WARNING: Do not check these values into VCS!
|
10
|
+
config.client_secret = '<%= options.client_secret %>'
|
11
|
+
config.provider_secret = '<%= options.provider_secret %>'
|
12
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
class VlineProviderGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
argument :name, :type => :string, :default => 'Vline'
|
7
|
+
|
8
|
+
class_option :app_id, :type => :string, :required => true,
|
9
|
+
:desc => 'Your vline application id'
|
10
|
+
class_option :client_id, :type => :string, :default => SecureRandom.urlsafe_base64(32),
|
11
|
+
:desc => 'OAUTH client ID'
|
12
|
+
class_option :client_secret, :type => :string, :default => SecureRandom.urlsafe_base64(32),
|
13
|
+
:desc => 'OAUTH client secret'
|
14
|
+
class_option :provider_secret, :type => :string, :required => true,
|
15
|
+
:desc => 'Secret string for signing login and OAUTH tokens. This value comes from developer console.'
|
16
|
+
|
17
|
+
desc 'Creates a VlineProvider controller.'
|
18
|
+
|
19
|
+
def check_class_collisions
|
20
|
+
class_collisions class_path, "#{class_name}Controller"
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_controller_file
|
24
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_initializer_file
|
28
|
+
template 'initializer.rb', "config/initializers/#{file_name}.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_routes
|
32
|
+
route "match '_vline/launch' => 'vline#launch'"
|
33
|
+
route "match '_vline/api/v1/oauth/authorize' => 'vline#authorize'"
|
34
|
+
route "mount Vline::API => '_vline/api'"
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_jsonp_support
|
38
|
+
line = "# This file is used by Rack-based servers to start the application."
|
39
|
+
gsub_file 'config.ru', /(#{Regexp.escape(line)})/mi do |match|
|
40
|
+
"#{match}\nrequire 'rack/jsonp'\nuse Rack::JSONP\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def output
|
45
|
+
say_status "App ID", "#{options[:app_id]}", :blue
|
46
|
+
say_status "Client ID", "#{options[:client_id]}", :blue
|
47
|
+
say_status "Client Secret", "#{options[:client_secret]}", :blue
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
def login_filter
|
52
|
+
if File.exist? 'config/initializers/devise.rb'
|
53
|
+
"before_filter :authenticate_user!"
|
54
|
+
elsif File.exist? 'config/initializers/authlogic.rb'
|
55
|
+
"before_filter :require_user"
|
56
|
+
else
|
57
|
+
"before_filter :login_required"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|