omniauth-twitcasting 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f0ec63313c4986f02132982b73e787ac652f563
4
+ data.tar.gz: 9c694c4632f45a225ebe2ea831295a44243dc264
5
+ SHA512:
6
+ metadata.gz: 1c0979605a2fe543d8386717f8df0f9c2d0e0633566982076bb651277e982e8287d27d38bb698a6cf968229c899b20e71213bcb2e403493858a106da266c9026
7
+ data.tar.gz: 0bc989f017712a0efaf26a447e33be418c4d3dbd7000cb7a6e38613387e7dc6e49d0ee039c18eaa0e67e859d02d90f72ac090c996d89406a07498e04db42865b
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-twitcasting (0.0.1)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.0)
12
+ public_suffix (~> 2.0, >= 2.0.2)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.2.5)
16
+ docile (1.1.5)
17
+ faraday (0.9.2)
18
+ multipart-post (>= 1.2, < 3)
19
+ hashdiff (0.3.1)
20
+ hashie (3.4.6)
21
+ json (2.0.2)
22
+ jwt (1.5.6)
23
+ multi_json (1.12.1)
24
+ multi_xml (0.5.5)
25
+ multipart-post (2.0.0)
26
+ oauth2 (1.2.0)
27
+ faraday (>= 0.8, < 0.10)
28
+ jwt (~> 1.0)
29
+ multi_json (~> 1.3)
30
+ multi_xml (~> 0.5)
31
+ rack (>= 1.2, < 3)
32
+ omniauth (1.3.1)
33
+ hashie (>= 1.2, < 4)
34
+ rack (>= 1.0, < 3)
35
+ omniauth-oauth2 (1.4.0)
36
+ oauth2 (~> 1.0)
37
+ omniauth (~> 1.2)
38
+ public_suffix (2.0.4)
39
+ rack (2.0.1)
40
+ rack-test (0.6.3)
41
+ rack (>= 1.0)
42
+ rake (11.3.0)
43
+ rspec (2.99.0)
44
+ rspec-core (~> 2.99.0)
45
+ rspec-expectations (~> 2.99.0)
46
+ rspec-mocks (~> 2.99.0)
47
+ rspec-core (2.99.2)
48
+ rspec-expectations (2.99.2)
49
+ diff-lcs (>= 1.1.3, < 2.0)
50
+ rspec-mocks (2.99.4)
51
+ safe_yaml (1.0.4)
52
+ simplecov (0.12.0)
53
+ docile (~> 1.1.0)
54
+ json (>= 1.8, < 3)
55
+ simplecov-html (~> 0.10.0)
56
+ simplecov-html (0.10.0)
57
+ webmock (2.1.0)
58
+ addressable (>= 2.3.6)
59
+ crack (>= 0.3.2)
60
+ hashdiff
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 1.5)
67
+ omniauth-twitcasting!
68
+ rack-test
69
+ rake
70
+ rspec (~> 2.7)
71
+ simplecov
72
+ webmock
73
+
74
+ BUNDLED WITH
75
+ 1.13.6
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Nobu Funaki
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ # TwitCasting's Omniauth strategy
2
+
3
+ This is the official Ruby OmniAuth strategy for authenticating to [TwitCasting](http://twitcasting.tv/). Create an application and get the client id and secret at [the Developer page](http://twitcasting.tv/indexapiv2.php).
4
+
5
+ A lot of code comes from [omniauth-digitalocean](https://github.com/digitalocean/omniauth-digitalocean). Thanks!
6
+
7
+ ## Installation
8
+
9
+ ```ruby
10
+ gem 'omniauth-twitcasting'
11
+ ```
12
+
13
+ ## Test
14
+
15
+ ```shell
16
+ bundle exec rspec
17
+ ```
18
+
19
+ ## License
20
+
21
+ omniauth-twitcasting is released under the MIT License.
@@ -0,0 +1,2 @@
1
+ require "omniauth-twitcasting/version"
2
+ require "omniauth/strategies/twitcasting"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Twitcasting
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,69 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ #
7
+ # Authenticate to TwitCasting via OAuth and retrieve basic user information.
8
+ # Usage:
9
+ # use OmniAuth::Strategies::Twitcasting, 'consumerkey', 'consumersecret'
10
+ #
11
+ class Twitcasting < OmniAuth::Strategies::OAuth2
12
+ AUTHENTICATION_PARAMETERS = %w(state)
13
+ BASE_URL = 'https://apiv2.twitcasting.tv'
14
+
15
+ option :name, 'twitcasting'
16
+
17
+ option :client_options, {
18
+ :authorize_url => '/oauth2/authorize',
19
+ :token_url => '/oauth2/access_token',
20
+ :site => BASE_URL
21
+ }
22
+
23
+ option :authorize_options, AUTHENTICATION_PARAMETERS
24
+
25
+ uid do
26
+ raw_info['user']['id']
27
+ end
28
+
29
+ info do
30
+ {
31
+ :name => raw_info['user']['name'],
32
+ :image => raw_info['user']['image']
33
+ }
34
+ end
35
+
36
+ def raw_info
37
+ @raw_info ||= access_token.get(BASE_URL + '/verify_credentials').parsed
38
+ end
39
+
40
+ # Over-ride callback_url definition to maintain
41
+ # compatability with omniauth-oauth2 >= 1.4.0
42
+ #
43
+ # See: https://github.com/intridea/omniauth-oauth2/issues/81
44
+ def callback_url
45
+ full_host + script_name + callback_path
46
+ end
47
+
48
+ # Hook useful for appending parameters into the auth url before sending
49
+ # to provider.
50
+ def request_phase
51
+ super
52
+ end
53
+
54
+ # Hook used after response with code from provider. Used to prep token
55
+ # request from provider.
56
+ def callback_phase
57
+ super
58
+ end
59
+
60
+ def authorize_params
61
+ super.tap do |params|
62
+ AUTHENTICATION_PARAMETERS.each do |v|
63
+ params[v.to_sym] = request.params[v] if request.params[v]
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'omniauth-twitcasting/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "omniauth-twitcasting"
7
+ spec.version = Omniauth::Twitcasting::VERSION
8
+ spec.authors = ["Nobu Funaki"]
9
+ spec.email = ["nobu@sidefeed.com"]
10
+ spec.summary = %q{Official OmniAuth strategy for TwitCasting}
11
+ spec.description = %q{Official OmniAuth strategy for TwitCasting}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "omniauth", "~> 1.0"
21
+ spec.add_dependency "omniauth-oauth2", "~> 1.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.7"
26
+ spec.add_development_dependency "rack-test"
27
+ spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "webmock"
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Twitcasting do
4
+ subject do
5
+ described_class.new({})
6
+ end
7
+
8
+ describe "production client options" do
9
+ it { expect(subject.options.name).to eq('twitcasting') }
10
+
11
+ it { expect(subject.options.client_options.site).to eq('https://apiv2.twitcasting.tv') }
12
+ it { expect(subject.options.client_options.authorize_url).to eq('/oauth2/authorize') }
13
+ it { expect(subject.options.client_options.token_url).to eq('/oauth2/access_token') }
14
+ end
15
+
16
+ describe "callback phase instance methods" do
17
+ let(:uuid) { 123 }
18
+ let(:raw_info) {
19
+ {
20
+ 'user' => {
21
+ 'id' => uuid
22
+ }
23
+ }
24
+ }
25
+
26
+ before do
27
+ allow(subject).to receive(:raw_info).and_return(raw_info)
28
+ end
29
+
30
+ describe "#uid" do
31
+ it "returns user.id from the info hash" do
32
+ expect(subject.uid).to eq(uuid)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'rack/test'
3
+ require 'webmock/rspec'
4
+ require 'omniauth'
5
+ require 'omniauth-twitcasting'
6
+
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ config.include WebMock::API
14
+ config.include Rack::Test::Methods
15
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-twitcasting
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nobu Funaki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Official OmniAuth strategy for TwitCasting
126
+ email:
127
+ - nobu@sidefeed.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - Gemfile
133
+ - Gemfile.lock
134
+ - LICENSE.txt
135
+ - README.md
136
+ - lib/omniauth-twitcasting.rb
137
+ - lib/omniauth-twitcasting/version.rb
138
+ - lib/omniauth/strategies/twitcasting.rb
139
+ - omniauth-twitcasting.gemspec
140
+ - spec/omniauth/strategies/twitcasting_spec.rb
141
+ - spec/spec_helper.rb
142
+ homepage: ''
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.0.14.1
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Official OmniAuth strategy for TwitCasting
166
+ test_files:
167
+ - spec/omniauth/strategies/twitcasting_spec.rb
168
+ - spec/spec_helper.rb