omniauth-coub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c01f42ee9542eba06a7cf476c50c338d55ecca1d
4
+ data.tar.gz: ac51d7c5a81981972f4ff8324a1042beab38491d
5
+ SHA512:
6
+ metadata.gz: 4625e81a27d61f1c375056207c6fdd15880fa4b64d78c2baff77484cb7ab905264a7bd7c70f885d5e59201be54244c72c604d6119f9b0311cbf3bfcd20cb4865
7
+ data.tar.gz: e8265eb2a9dfcd53473f9555ed44aaf9e6a16c429c782b7da34af1f70d90cc0f57b90e70d48626b608bf30343fa152b4e337a28809a4f7ac368756e647f03ef0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-coub.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Coub.com
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.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Omniauth::Coub
2
+
3
+ Official OmniAuth Strategy for the Coub OAuth2 API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```bash
10
+ gem 'omniauth-coub'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install omniauth-coub
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### With Sinatra
28
+
29
+ ```ruby
30
+ use OmniAuth::Builder do
31
+ provider :coub, ENV['COUB_KEY'], ENV['COUB_SECRET'], scope: 'logged_in,channel_edit,like'
32
+ end
33
+ ```
34
+
35
+ ### With Rails
36
+
37
+ ```ruby
38
+ Rails.application.config.middleware.use OmniAuth::Builder do
39
+ provider :coub, ENV['COUB_KEY'], ENV['COUB_SECRET'], scope: 'logged_in,channel_edit,like'
40
+ end
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,40 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Coub < OmniAuth::Strategies::OAuth2
6
+ COUB_HOST = ENV['OA_COUB_HOST'] || "coub.com"
7
+
8
+ option :name, 'coub'
9
+ option :client_options, {
10
+ :site => "http://#{COUB_HOST}/api/v2",
11
+ :authorize_url => "http://#{COUB_HOST}/oauth/authorize",
12
+ :token_url => "http://#{COUB_HOST}/oauth/token.json"
13
+ }
14
+
15
+ def authorize_params
16
+ super.tap do |params|
17
+ raw_scope = params['scope']
18
+
19
+ if raw_scope
20
+ scope_list = raw_scope.split(',')
21
+ params['scope'] = scope_list.join(' ')
22
+ end
23
+ end
24
+ end
25
+
26
+ uid { raw_info['id'] }
27
+
28
+ extra do
29
+ {:raw_info => raw_info}
30
+ end
31
+
32
+ def raw_info
33
+ @raw_info ||= access_token.get("users/me").parsed
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+
40
+ OmniAuth.config.add_camelization 'coub', 'Coub'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Coub
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-coub/version"
2
+ require "omniauth/strategies/coub"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-coub/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Kirill Gorin"]
6
+ gem.email = ["me@kgor.in"]
7
+ gem.description = "Provides an OmniAuth strategy for Coub to make authentication with the Coub API simple"
8
+ gem.summary = "An OmniAuth strategy for Coub"
9
+ gem.homepage = "https://github.com/coub/omniauth-coub"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "omniauth-coub"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Omniauth::Coub::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency "rspec", "~> 2.7"
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Coub do
4
+ let(:app) {
5
+ -> { [200, {}, ["Hello."]] }
6
+ }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Coub.new(app, 'app_id', 'app_secret', @options || {})
10
+ end
11
+
12
+ before do
13
+ OmniAuth.config.test_mode = true
14
+ end
15
+
16
+ after do
17
+ OmniAuth.config.test_mode = false
18
+ end
19
+
20
+ context "general" do
21
+ it "should be called coub" do
22
+ subject.options.name.should eq('coub')
23
+ end
24
+ end
25
+
26
+ context "endpoints" do
27
+ it "has correct site" do
28
+ subject.options.client_options.site.should eq("http://coub.com/api/v2")
29
+ end
30
+
31
+ it "has correct authorize_url" do
32
+ subject.options.client_options.authorize_url.should eq("http://coub.com/oauth/authorize")
33
+ end
34
+
35
+ it "has correct token_url" do
36
+ subject.options.client_options.token_url.should eq("http://coub.com/oauth/token.json")
37
+ end
38
+ end
39
+
40
+ context "scopes" do
41
+ it 'joins scopes' do
42
+ @options = { 'scope' => 'logged_in,channel_edit' }
43
+ subject.authorize_params['scope'].should eq('logged_in channel_edit')
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-coub'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-coub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kirill Gorin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-18 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.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
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: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
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
+ description: Provides an OmniAuth strategy for Coub to make authentication with the
98
+ Coub API simple
99
+ email:
100
+ - me@kgor.in
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/omniauth-coub.rb
112
+ - lib/omniauth-coub/version.rb
113
+ - lib/omniauth/strategies/coub.rb
114
+ - omniauth-coub.gemspec
115
+ - spec/omniauth/strategies/coub_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/coub/omniauth-coub
118
+ licenses: []
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.1
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: An OmniAuth strategy for Coub
140
+ test_files:
141
+ - spec/omniauth/strategies/coub_spec.rb
142
+ - spec/spec_helper.rb