omniauth-freee 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: bcaae2539120a425c83a27bfbee35005164d992b
4
+ data.tar.gz: f30779e0df52a2ce9bc08bb9e7eedbd9668557db
5
+ SHA512:
6
+ metadata.gz: c7c6a342d57872fb0d6a7b811c3e4761d4df50cb9168def4b0f64beabdd8e9284350b37b07256fdf6d1974d1eb0012052caeb4daffb0c158bbff7ca25f28ebdb
7
+ data.tar.gz: 1fd9e6c6ccba5aeeb51728884aeb6d17433643112c150719c69135c4cc215f601655fb2b1a8eedab470490d4a691939da20946a5387dc405a489ee37ccf5a50a
data/.gitignore ADDED
@@ -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
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ deploy:
3
+ provider: rubygems
4
+ api_key:
5
+ secure: KRmedrg9+bmTZ3jboI1AcoGqZTJSIYP9A8H+OABOrmk2zh6WywiJKUZcpIXfltrn+Caw/LiYknN++5KSZbLRqQyKSwAiDyeTzS3mgOFV2KoHZW734vhXqhk4Q6S+n799hEtlgmE3ceXQ4fgLkM+FuauurEJuFDYnNm+2b+LteCSxmm71gLqYfSEXy4X4tnhRJEq6z3hpCc9jIq/4JMs62mjh7akvXv4EQHauq7rhjKrDLbAFX4ROgwOvcheBMn5LsSIcSvBjQNPTq6fP1X1++l7Xt/0jCu9x4QADvbdRYD/exK227dPCPZUBn0VuDT6WeNhjAsp9GufmOR3/e3e6ceEe2rA8dM0+5hSCt3n7RKW3IvYgvJQ+XLskvXyD2X8xzumkjJVNTUzHN97uotxfrYyEUpxO0NRHswqg2JphCc+p4Pqdyx5XLYVXsvF0i0N4xXYxx/mVckWEjFlZezYsLoDVos+CcP1AbP2LZgwYyw+T+u+ukYO2TAA+jA516YxssRh4rs4cbamJOOGxDkMniQPFgwgBp+Aro9fWdKqJyglt57+ptDnlzamUYXYgGeAnN5q995rfZ+4aNoyajwHEsCYPLIewDlfv4609zqnZCMkc8laHXbrsYVgN5uPf7VVuNEwSLBQST9mLDggEosBTSMcQp+Mpv+7jA6vzrG3bwuU=
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-github.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
+ gem 'rake'
13
+ end
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', cmd: "bundle exec rspec", :version => 2 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-freee.gemspec')
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,17 @@
1
+ Copyright (c) 2017 kkanazaw and Designrule, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ # omniauth-github
10
+ Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OmniAuth Freee
2
+
3
+ This is the *unofficial* OmniAuth strategy for authenticating to Freee. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Freee Applications Page](https://secure.freee.co.jp/oauth/applications).
6
+
7
+ This is a fork from [omniauth-github](https://github.com/intridea/omniauth-github)
8
+
9
+ ## Basic Usage
10
+
11
+ ```ruby
12
+ use OmniAuth::Builder do
13
+ provider :freee, ENV['FREEE_KEY'], ENV['FREEE_SECRET']
14
+ end
15
+ ```
16
+
17
+ ## License
18
+
19
+ Copyright (c) 2017 kkanazaw and Designrule, Inc.
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ ### omniauth-github
28
+ Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
29
+
30
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
33
+
34
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
+
36
+
data/Rakefile ADDED
@@ -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,2 @@
1
+ require "omniauth-freee/version"
2
+ require 'omniauth/strategies/freee'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Freee
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ require 'omniauth-oauth2'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Freee < OmniAuth::Strategies::OAuth2
7
+ option :client_options, {
8
+ :site => 'https://api.freee.co.jp',
9
+ :authorize_url => 'https://secure.freee.co.jp/oauth/authorize',
10
+ :token_url => 'https://api.freee.co.jp/oauth/token'
11
+ }
12
+
13
+ uid { raw_info['user']['email'].to_s }
14
+
15
+ info do
16
+ {
17
+ 'nickname' => raw_info['user']['display_name'],
18
+ 'email' => raw_info['user']['email'],
19
+ 'name' => raw_info['user']['display_name'],
20
+ 'first_name' => raw_info['user']['first_name'],
21
+ 'last_name' => raw_info['user']['last_name'],
22
+ }
23
+ end
24
+
25
+ extra do
26
+ {:raw_info => raw_info}
27
+ end
28
+
29
+ def raw_info
30
+ @raw_info ||= access_token.get('/api/1/users/me?companies=true').parsed
31
+ end
32
+
33
+ def callback_url
34
+ full_host + script_name + callback_path
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ OmniAuth.config.add_camelization 'freee', 'Freee'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-freee/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Keigo Kanazawa"]
6
+ gem.email = ["kkanazaw@designrule.jp"]
7
+ gem.description = %q{Unoficial OmniAuth strategy for Freee.}
8
+ gem.summary = %q{Unofficial OmniAuth strategy for Freee.}
9
+ gem.homepage = "https://github.com/kkanazaw/omniauth-freee"
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-freee"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = OmniAuth::Freee::VERSION
18
+
19
+ gem.add_dependency 'omniauth', '~> 1.5'
20
+ gem.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
21
+ gem.add_development_dependency 'rspec', '~> 3.5'
22
+ gem.add_development_dependency 'rack-test'
23
+ gem.add_development_dependency 'simplecov'
24
+ gem.add_development_dependency 'webmock'
25
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Freee do
4
+ let(:access_token) { instance_double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { instance_double('ParsedResponse') }
6
+ let(:response) { instance_double('Response', :parsed => parsed_response) }
7
+
8
+ let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
9
+ let(:enterprise_authorize_url) { 'https://some.other.site.com/oauth/authorize' }
10
+ let(:enterprise_token_url) { 'https://some.other.site.com/oauth/token' }
11
+ let(:enterprise) do
12
+ OmniAuth::Strategies::Freee.new('FREEE_KEY', 'FREEE_SECRET',
13
+ {
14
+ :client_options => {
15
+ :site => enterprise_site,
16
+ :authorize_url => enterprise_authorize_url,
17
+ :token_url => enterprise_token_url
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::Freee.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ allow(subject).to receive(:access_token).and_return(access_token)
29
+ end
30
+
31
+ context 'client options' do
32
+ it 'should have correct site' do
33
+ expect(subject.options.client_options.site).to eq('https://api.freee.co.jp')
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ expect(subject.options.client_options.authorize_url).to eq('https://secure.freee.co.jp/oauth/authorize')
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ expect(subject.options.client_options.token_url).to eq('https://api.freee.co.jp/oauth/token')
42
+ end
43
+
44
+ describe 'should be overrideable' do
45
+ it 'for site' do
46
+ expect(enterprise.options.client_options.site).to eq(enterprise_site)
47
+ end
48
+
49
+ it 'for authorize url' do
50
+ expect(enterprise.options.client_options.authorize_url).to eq(enterprise_authorize_url)
51
+ end
52
+
53
+ it 'for token url' do
54
+ expect(enterprise.options.client_options.token_url).to eq(enterprise_token_url)
55
+ end
56
+ end
57
+ end
58
+
59
+ context '#raw_info' do
60
+ it 'should use relative paths' do
61
+ expect(access_token).to receive(:get).with('/api/1/users/me?companies=true').and_return(response)
62
+ expect(subject.raw_info).to eq(parsed_response)
63
+ end
64
+ end
65
+
66
+ # describe '#callback_url' do
67
+ # it 'is a combination of host, script name, and callback path' do
68
+ # allow(subject).to receive(:full_host).and_return('https://example.com')
69
+ # allow(subject).to receive(:script_name).and_return('/sub_uri')
70
+
71
+ # expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/freee/callback')
72
+ # end
73
+ # end
74
+ end
@@ -0,0 +1,16 @@
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-freee'
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
16
+
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-freee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Keigo Kanazawa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-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.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
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.4.0
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.4.0
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.5'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.5'
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: Unoficial OmniAuth strategy for Freee.
104
+ email:
105
+ - kkanazaw@designrule.jp
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".travis.yml"
113
+ - Gemfile
114
+ - Guardfile
115
+ - LICENSE.txt
116
+ - README.md
117
+ - Rakefile
118
+ - lib/omniauth-freee.rb
119
+ - lib/omniauth-freee/version.rb
120
+ - lib/omniauth/strategies/freee.rb
121
+ - omniauth-freee.gemspec
122
+ - spec/omniauth/strategies/freee_spec.rb
123
+ - spec/spec_helper.rb
124
+ homepage: https://github.com/kkanazaw/omniauth-freee
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.5.1
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Unofficial OmniAuth strategy for Freee.
148
+ test_files:
149
+ - spec/omniauth/strategies/freee_spec.rb
150
+ - spec/spec_helper.rb