omniauth-gitbook 0.0.2

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: 72d24d6216474bc75afc23d1d8ebeadf3cf80be5
4
+ data.tar.gz: 8d1b8cbd4639a87c229efdf44d630ad927b85d57
5
+ SHA512:
6
+ metadata.gz: b6ddd75587264a98ccaba4f0665682d7ce9ba8d6915ee67aa5acbe4a94d8d4f8d82749162f6543fc9ccf79131a6da7214e937d6e6c5aeb00fc14255f0c0c8cbb
7
+ data.tar.gz: 411fa523e04d122fce167dd85b235a0257a600ce459c7ae2361fa15ddddfcd9592d342c8edbf03ccd7bb6ab52f3c020a9022700ae2f128494acfd2b8637ebc3f
@@ -0,0 +1,18 @@
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
18
+ .idea
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-gitbook.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
@@ -0,0 +1,10 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-gitbook.gemspec')
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Calvin Huang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # omniauth-gitbook
2
+ Gitbook Oauth2 strategy for Omniauth.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module GitBook
3
+ VERSION = '0.0.2'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require('omniauth/strategies/gitbook')
2
+ require('gitbook/version')
@@ -0,0 +1,48 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class GitBook < OmniAuth::Strategies::OAuth2
6
+ base_url = 'https://api.gitbook.com'
7
+
8
+ option :name, 'GitBook'
9
+ option :client_options, {
10
+ site: base_url,
11
+ authorize_url: "#{base_url}/oauth/authorize",
12
+ token_url: "#{base_url}/oauth/access_token",
13
+ }
14
+
15
+ uid { raw_info['id'].to_s }
16
+
17
+ info do
18
+ {
19
+ 'name' => raw_info['name'],
20
+ 'website' => raw_info['website']
21
+ }
22
+ end
23
+
24
+ extra do
25
+ { raw_info: raw_info }
26
+ end
27
+
28
+ def raw_info
29
+ access_token.options[:mode] = :query
30
+ @raw_info ||= access_token
31
+ end
32
+
33
+ def authorize_params
34
+ super.tap do |params|
35
+ %w[response_type].each do |v|
36
+ params[v.to_sym] = 'code'
37
+ end
38
+ end
39
+ end
40
+
41
+ def request_phase
42
+ super
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ OmniAuth.config.add_camelization 'gitbook', 'GitBook'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/gitbook/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Calvin Huang"]
6
+ gem.email = ["calvin.peak@capslock.tw"]
7
+ gem.description = %q{Gitbook Oauth2 strategy for Omniauth.}
8
+ gem.summary = %q{Gitbook Oauth2 strategy for Omniauth.}
9
+ gem.homepage = "https://github.com/Calvin-Huang/omniauth-gitbook"
10
+ gem.license = "MIT"
11
+
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.name = "omniauth-gitbook"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = OmniAuth::GitBook::VERSION
18
+
19
+ gem.add_dependency 'omniauth', '~> 1.0'
20
+ # Nothing lower than omniauth-oauth2 1.1.1
21
+ # http://www.rubysec.com/advisories/CVE-2012-6134/
22
+ gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
23
+ gem.add_development_dependency 'rspec', '~> 3.0'
24
+ gem.add_development_dependency 'rack-test'
25
+ gem.add_development_dependency 'simplecov'
26
+ gem.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GitBook do
4
+
5
+ subject do
6
+ OmniAuth::Strategies::GitBook.new({})
7
+ end
8
+
9
+ context 'client options' do
10
+ it 'should have correct site' do
11
+ subject.options.client_options.site.should eq('https://api.gitbook.com')
12
+ end
13
+
14
+ it 'should have correct authorize url' do
15
+ subject.options.client_options.authorize_url.should eq('https://api.gitbook.com/oauth/authorize')
16
+ end
17
+
18
+ it 'should have correct request access token target' do
19
+ subject.options.client_options.token_url.should eq('https://api.gitbook.com/oauth/access_token')
20
+ end
21
+ end
22
+
23
+ # context 'request access params' do
24
+ # it 'should have response_type whether user set in config' do
25
+ # subject.options.authorize_params['request_type'].should eq('code')
26
+ # end
27
+ # end
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'rspec'
2
+ require 'rack/test'
3
+ require 'webmock/rspec'
4
+ require 'omniauth'
5
+ require 'omni-gitbook'
6
+
7
+ RSpec.configure do |config|
8
+ config.include WebMock::API
9
+ config.include Rack::Test::Methods
10
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
11
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-gitbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Calvin Huang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-02 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.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rack-test
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: Gitbook Oauth2 strategy for Omniauth.
104
+ email:
105
+ - calvin.peak@capslock.tw
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - Gemfile
113
+ - Guardfile
114
+ - LICENSE
115
+ - README.md
116
+ - Rakefile
117
+ - lib/gitbook/version.rb
118
+ - lib/omni-gitbook.rb
119
+ - lib/omniauth/strategies/gitbook.rb
120
+ - omniauth-gitbook.gemspec
121
+ - spec/omniauth/strategies/gitbook_spec.rb
122
+ - spec/spec_helper.rb
123
+ homepage: https://github.com/Calvin-Huang/omniauth-gitbook
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.6.6
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Gitbook Oauth2 strategy for Omniauth.
147
+ test_files:
148
+ - spec/omniauth/strategies/gitbook_spec.rb
149
+ - spec/spec_helper.rb