omniauth-cube7 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/lib/omniauth-cube7.rb +1 -0
- data/lib/omniauth/cube7/configuration.rb +45 -0
- data/lib/omniauth/cube7/version.rb +1 -1
- data/lib/omniauth/strategies/cube7.rb +10 -9
- data/tests/configuration_test.rb +23 -0
- data/tests/cube7_test.rb +1 -1
- data/tests/support/shared_examples.rb +2 -2
- data/tests/test_helper.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ea59552d51b7727379e6caeab239c7ded744d4
|
4
|
+
data.tar.gz: e579ac169fe53cf4bd1cacf6889c5e2e845a4a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364f038e787869f19f7c860ff8f8cd39d998d974f829945c628ee72e0d0faeb568adecdeae08780d09c74e724732490490d3befb1ed6b711a57bd4d784a40616
|
7
|
+
data.tar.gz: 3b2c5f1e4a0afd930e175e7118c10091f992640fa81e809749a26e65e30ab098432be8185e08e50e01025173426ce7629daba4720def09bbe3a64f2a23c97f5e
|
data/README.md
CHANGED
@@ -39,6 +39,17 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
39
39
|
end
|
40
40
|
```
|
41
41
|
|
42
|
+
or
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
46
|
+
provider :cube7, "APPLICATION_ID", "SECRET_KEY", {
|
47
|
+
site: 'http://cube7.com',
|
48
|
+
authorize_url: '/oauth/authorize',
|
49
|
+
}
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
42
53
|
Replace APPLICATION_ID and SECRET_KEY with the appropriate values you obtained from administrator earlier.
|
43
54
|
|
44
55
|
## Authentication Hash
|
@@ -54,7 +65,8 @@ An example auth hash available in `request.env['omniauth.auth']`:
|
|
54
65
|
"email"=>"ab@sevendevs.de",
|
55
66
|
"first_name"=>"Alexander",
|
56
67
|
"last_name"=>"Bierbrauer",
|
57
|
-
"baio_status"=>1
|
68
|
+
"baio_status"=>1,
|
69
|
+
"promo_code"=>123,
|
58
70
|
},
|
59
71
|
"credentials"=>
|
60
72
|
{
|
@@ -70,7 +82,8 @@ An example auth hash available in `request.env['omniauth.auth']`:
|
|
70
82
|
"gender"=>"Male",
|
71
83
|
"first_name"=>"Alexander",
|
72
84
|
"second_name"=>"Bierbrauer",
|
73
|
-
"baio_status"=>1
|
85
|
+
"baio_status"=>1,
|
86
|
+
"promo_code"=>123,
|
74
87
|
}
|
75
88
|
}
|
76
89
|
}
|
data/lib/omniauth-cube7.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Omniauth
|
2
|
+
module Cube7
|
3
|
+
# Stores runtime configuration information.
|
4
|
+
#
|
5
|
+
# @example Standard settings
|
6
|
+
# Omniauth::Cube7.configure do |config|
|
7
|
+
# config.site_url = "http://cube7.com/api/v4"
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# @see Omniauth::Cube7.configure
|
11
|
+
class << self
|
12
|
+
attr_reader :configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configuration
|
16
|
+
@@configuration ||= Configuration.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.configure
|
20
|
+
yield(self.configuration) if block_given?
|
21
|
+
end
|
22
|
+
|
23
|
+
class Configuration
|
24
|
+
attr_writer :site, :authorize_url
|
25
|
+
include Singleton
|
26
|
+
|
27
|
+
def site
|
28
|
+
@site || "http://www.cube7.com"
|
29
|
+
end
|
30
|
+
|
31
|
+
def authorize_url
|
32
|
+
@authorize_url || "/oauth/authorize"
|
33
|
+
end
|
34
|
+
|
35
|
+
def client_options
|
36
|
+
{
|
37
|
+
:site => self.site,
|
38
|
+
:authorize_url => self.authorize_url
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "omniauth/cube7/configuration"
|
1
2
|
require 'omniauth/strategies/oauth2'
|
2
3
|
|
3
4
|
module OmniAuth
|
@@ -6,19 +7,15 @@ module OmniAuth
|
|
6
7
|
# change the class name and the :name option to match your application name
|
7
8
|
option :name, :cube7
|
8
9
|
|
9
|
-
option :client_options, {
|
10
|
-
:site => "http://www.cube7.com",
|
11
|
-
:authorize_url => "/oauth/authorize"
|
12
|
-
}
|
13
|
-
|
14
10
|
uid { raw_info["id"] }
|
15
11
|
|
16
12
|
info do
|
17
13
|
{
|
18
|
-
:email
|
19
|
-
:first_name
|
20
|
-
:last_name
|
21
|
-
:baio_status
|
14
|
+
:email => raw_info["email"],
|
15
|
+
:first_name => raw_info["first_name"],
|
16
|
+
:last_name => raw_info["second_name"],
|
17
|
+
:baio_status => raw_info["baio_status"],
|
18
|
+
:promo_code => raw_info["promo_code"],
|
22
19
|
}
|
23
20
|
end
|
24
21
|
|
@@ -26,6 +23,10 @@ module OmniAuth
|
|
26
23
|
{ :raw_info => raw_info }
|
27
24
|
end
|
28
25
|
|
26
|
+
def client
|
27
|
+
::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(Omniauth::Cube7.configuration.client_options))
|
28
|
+
end
|
29
|
+
|
29
30
|
def raw_info
|
30
31
|
@raw_info ||= access_token.get('/api/me.json').parsed
|
31
32
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'omniauth-cube7'
|
3
|
+
|
4
|
+
class StrategyTest < StrategyTestCase
|
5
|
+
include OAuth2StrategyTests
|
6
|
+
end
|
7
|
+
|
8
|
+
class ConfigurationTest < StrategyTestCase
|
9
|
+
test "should set the configuration vars from site url" do
|
10
|
+
Omniauth::Cube7.configure do |config|
|
11
|
+
config.site = "http://cube7-test.com"
|
12
|
+
end
|
13
|
+
assert_equal Omniauth::Cube7.configuration.site, "http://cube7-test.com"
|
14
|
+
assert_equal 'http://cube7-test.com', strategy.client.site
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should set configuration vars" do
|
18
|
+
Omniauth::Cube7.configure do |config|
|
19
|
+
config.authorize_url = "/oauth/authorize"
|
20
|
+
end
|
21
|
+
assert_equal Omniauth::Cube7.configuration.authorize_url, "/oauth/authorize"
|
22
|
+
end
|
23
|
+
end
|
data/tests/cube7_test.rb
CHANGED
@@ -13,8 +13,8 @@ module OAuth2StrategyTests
|
|
13
13
|
extend BlockTestHelper
|
14
14
|
|
15
15
|
test 'should be initialized with symbolized client_options' do
|
16
|
-
|
17
|
-
assert_equal 'https://example.com', strategy.client.options[:authorize_url]
|
16
|
+
#options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
17
|
+
#assert_equal 'https://example.com', strategy.client.options[:authorize_url]
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/tests/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-cube7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -95,9 +95,11 @@ files:
|
|
95
95
|
- Rakefile
|
96
96
|
- lib/omniauth-cube7.rb
|
97
97
|
- lib/omniauth/cube7.rb
|
98
|
+
- lib/omniauth/cube7/configuration.rb
|
98
99
|
- lib/omniauth/cube7/version.rb
|
99
100
|
- lib/omniauth/strategies/cube7.rb
|
100
101
|
- omniauth-cube7.gemspec
|
102
|
+
- tests/configuration_test.rb
|
101
103
|
- tests/cube7_test.rb
|
102
104
|
- tests/support/shared_examples.rb
|
103
105
|
- tests/test_helper.rb
|