omniauth-tapjoy 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/README.md +67 -0
- data/lib/omniauth/strategies/tapjoy.rb +31 -4
- data/lib/omniauth/tapjoy.rb +0 -1
- data/omniauth-tapjoy.gemspec +1 -2
- data/spec/omniauth/strategies/tapjoy_spec.rb +32 -2
- metadata +4 -4
- data/lib/omniauth/tapjoy/version.rb +0 -5
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm 1.9.
|
1
|
+
rvm 1.9.3@tapjoy
|
data/README.md
CHANGED
@@ -4,6 +4,47 @@ Status](https://secure.travis-ci.org/Tapjoy/omniauth-tapjoy.png)](http://travis-
|
|
4
4
|
|
5
5
|
This is an omniauth plugin that can be used to connect to Tapjoy.
|
6
6
|
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth-tapjoy'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Create `config/initializers/omniauth.rb`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
|
+
provider :tapjoy, TAPJOY_KEY, TAPJOY_SECRET
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Now when you hit the `/auth/tapjoy` on your server, it will redirect to `oauth.tapjoy.com` then back to `/auth/tapjoy/callback` with credentials.
|
28
|
+
We will now setup this callback route
|
29
|
+
|
30
|
+
Add this line to `config/routes.rb`:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
match '/auth/tapjoy/callback' => 'user_sessions#create'
|
34
|
+
```
|
35
|
+
|
36
|
+
Create the `app/controllers/user_sessions_controller.rb`
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
class UserSessionsController < ApplicationController
|
40
|
+
def create
|
41
|
+
# This likely needs more logic to do things such as creating new users
|
42
|
+
user = User.find(request.env['omniauth.auth']['uid'])
|
43
|
+
session[:user_id] = user.id # or however you log a user in
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
7
48
|
## Installation with Devise
|
8
49
|
|
9
50
|
If you are using Devise, this is how you can use Tapjoy as your OAUTH provider.
|
@@ -18,6 +59,7 @@ And then execute:
|
|
18
59
|
|
19
60
|
$ bundle
|
20
61
|
|
62
|
+
|
21
63
|
Add this line to `config/intializers/devise.rb`:
|
22
64
|
|
23
65
|
```ruby
|
@@ -48,9 +90,34 @@ Set the route to use the callback you just created:
|
|
48
90
|
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
49
91
|
```
|
50
92
|
|
93
|
+
Environment settings passed in at application start will always be respected, but if you wish to automatically use the staging environment in development, you may add the following lines to your `config/environments/development.rb`
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
|
97
|
+
ENV['TAPJOY_AUTH_ENV'] ||= "staging"
|
98
|
+
OmniAuth::Strategies::Tapjoy.reconfigure
|
99
|
+
|
100
|
+
```
|
101
|
+
|
51
102
|
If you aren't using Devise, you can either connect to the oauth server directly,
|
52
103
|
or directly use omniauth: [https://github.com/intridea/omniauth](https://github.com/intridea/omniauth)
|
53
104
|
|
105
|
+
## Information available
|
106
|
+
|
107
|
+
```json
|
108
|
+
{
|
109
|
+
"id": "63be812b-706d-44c9-9e47-742511c6f939",
|
110
|
+
"email": "jeff@tapjoy.com",
|
111
|
+
"first_name": "Jeff",
|
112
|
+
"last_name": "Dickey",
|
113
|
+
"created_at": "2012-02-08T05:36:09Z",
|
114
|
+
"facebook_id": "42004440",
|
115
|
+
"country": "United States",
|
116
|
+
"time_zone": "Pacific Time (US & Canada)",
|
117
|
+
"is_employee": true
|
118
|
+
}
|
119
|
+
```
|
120
|
+
|
54
121
|
## Example
|
55
122
|
|
56
123
|
For an example of this in use, check the wheeler board: [https://github.com/Tapjoy/wheeler_board](https://github.com/Tapjoy/wheeler_board)
|
@@ -5,10 +5,37 @@ module OmniAuth
|
|
5
5
|
class Tapjoy < OmniAuth::Strategies::OAuth2
|
6
6
|
option :name, :tapjoy
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
# If you overwrite ENV settings in your application, for example in a rails environment setup, you
|
9
|
+
# will have to call OmniAuth::Strategies::Tapjoy.reconfigure to propagate your changes.
|
10
|
+
def self.reconfigure
|
11
|
+
option :client_options, {
|
12
|
+
:site => site,
|
13
|
+
:authorize_path => authorize_path
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.site
|
18
|
+
if ENV['TAPJOY_AUTH_SITE']
|
19
|
+
ENV['TAPJOY_AUTH_SITE']
|
20
|
+
elsif ENV['TAPJOY_AUTH_ENV'] == 'staging'
|
21
|
+
'https://mystique-staging.herokuapp.com'
|
22
|
+
else
|
23
|
+
"https://oauth.tapjoy.com"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.authorize_path
|
28
|
+
if ENV['TAPJOY_AUTH_PATH']
|
29
|
+
ENV['TAPJOY_AUTH_PATH']
|
30
|
+
elsif ENV['TAPJOY_AUTH_ENV'] == 'staging'
|
31
|
+
# Staging path is currently the same as production
|
32
|
+
"/oauth/authorize"
|
33
|
+
else
|
34
|
+
"/oauth/authorize"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
reconfigure
|
12
39
|
|
13
40
|
uid { raw_info["id"] }
|
14
41
|
|
data/lib/omniauth/tapjoy.rb
CHANGED
data/omniauth-tapjoy.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "omniauth/tapjoy"
|
4
3
|
|
5
4
|
Gem::Specification.new do |gem|
|
6
5
|
gem.authors = ["Jeff Dickey"]
|
@@ -14,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
14
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
14
|
gem.name = "omniauth-tapjoy"
|
16
15
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version =
|
16
|
+
gem.version = '1.4.3'
|
18
17
|
|
19
18
|
gem.add_dependency 'omniauth', '~> 1.0'
|
20
19
|
gem.add_runtime_dependency 'omniauth-oauth2'
|
@@ -10,12 +10,42 @@ describe OmniAuth::Strategies::Tapjoy do
|
|
10
10
|
subject.options.name.should eq(:tapjoy)
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'should have correct site' do
|
13
|
+
it 'should have the correct default production site' do
|
14
14
|
subject.options.client_options.site.should eq('https://oauth.tapjoy.com')
|
15
|
+
OmniAuth::Strategies::Tapjoy.site.should eq('https://oauth.tapjoy.com')
|
15
16
|
end
|
16
17
|
|
17
|
-
it 'should
|
18
|
+
it 'should use the correct environment site override' do
|
19
|
+
stub_const("ENV", { 'TAPJOY_AUTH_SITE' => 'https://test.tapjoy.com' })
|
20
|
+
# Can't test the subject directly here as the site was set on class load, but you could still overwrite
|
21
|
+
# it via an options hash if you wanted to
|
22
|
+
OmniAuth::Strategies::Tapjoy.site.should eq('https://test.tapjoy.com')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should use the correct staging site' do
|
26
|
+
stub_const("ENV", { 'TAPJOY_AUTH_ENV' => 'staging' })
|
27
|
+
# Can't test the subject directly here as the site was set on class load, but you could still overwrite
|
28
|
+
# it via an options hash if you wanted to
|
29
|
+
OmniAuth::Strategies::Tapjoy.site.should eq('https://mystique-staging.herokuapp.com')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have the correct default authorize url' do
|
18
33
|
subject.options.client_options.authorize_path.should eq('/oauth/authorize')
|
34
|
+
OmniAuth::Strategies::Tapjoy.authorize_path.should eq('/oauth/authorize')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should use the correct authorize url override' do
|
38
|
+
stub_const("ENV", { 'TAPJOY_AUTH_PATH' => '/a/different/path' })
|
39
|
+
# Can't test the subject directly here as the url was set on class load, but you could still overwrite
|
40
|
+
# it via an options hash if you wanted to
|
41
|
+
OmniAuth::Strategies::Tapjoy.authorize_path.should eq('/a/different/path')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should use the correct staging authorize url' do
|
45
|
+
stub_const("ENV", { 'TAPJOY_AUTH_ENV' => 'staging' })
|
46
|
+
# Can't test the subject directly here as the url was set on class load, but you could still overwrite
|
47
|
+
# it via an options hash if you wanted to
|
48
|
+
OmniAuth::Strategies::Tapjoy.authorize_path.should eq('/oauth/authorize')
|
19
49
|
end
|
20
50
|
end
|
21
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-tapjoy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
@@ -139,7 +139,6 @@ files:
|
|
139
139
|
- Rakefile
|
140
140
|
- lib/omniauth/strategies/tapjoy.rb
|
141
141
|
- lib/omniauth/tapjoy.rb
|
142
|
-
- lib/omniauth/tapjoy/version.rb
|
143
142
|
- omniauth-tapjoy.gemspec
|
144
143
|
- spec/omniauth/strategies/tapjoy_spec.rb
|
145
144
|
- spec/spec_helper.rb
|
@@ -163,10 +162,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
162
|
version: '0'
|
164
163
|
requirements: []
|
165
164
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.8.
|
165
|
+
rubygems_version: 1.8.23
|
167
166
|
signing_key:
|
168
167
|
specification_version: 3
|
169
168
|
summary: An omniauth provider to connect to Tapjoy
|
170
169
|
test_files:
|
171
170
|
- spec/omniauth/strategies/tapjoy_spec.rb
|
172
171
|
- spec/spec_helper.rb
|
172
|
+
has_rdoc:
|