omniauth-suzuri 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +7 -0
- data/README.md +30 -0
- data/Rakefile +8 -0
- data/lib/omniauth-suzuri.rb +2 -0
- data/lib/omniauth-suzuri/version.rb +5 -0
- data/lib/omniauth/strategies/suzuri.rb +35 -0
- data/omniauth-suzuri.gemspec +22 -0
- data/spec/omniauth/strategies/suzuri_spec.rb +76 -0
- data/spec/spec_helper.rb +15 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2660a147303e6194dcd4da57c80658f94705346e
|
4
|
+
data.tar.gz: 5930adca1df0a67712456187fb11e4dfb042a11d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 020d732ae27f18db05b8a533d370be86c3be3680589aaad888d2b6623dbe4d5a16c73f7acab1ad9333f1af7c07ff555ea4b7013d863f041d42a54e7f4b664c3e
|
7
|
+
data.tar.gz: 32291c283fbd8853761842dee2dd908f374001b43608e6c8ff18be07ad2bdb8e1737bd69017e73aad46a213b7d5ba69640b36ffeb1dc3945fb406f81bc7e4a6d
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.5
|
5
|
+
- 2.3.1
|
6
|
+
script: bundle exec rspec
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- secure: gEyc0B9sVLbXuzb0hPppvn4bQgYLvLNw7s1nW3dB7qDr+vinsuGfpAC1twF0IyKYMXN1ocQaWfN8EOUeTlKarWM7z/8B/klVFW6bXZlvyMrgVWqqTErUjnoBWQsMwee2mKikK4VT0G54vOoLFNwXZaCztlCmB0dRjmNLSMG5c2EypTZyc9NWRSD2JcV0WYcwznTE7dwhZRjuJ5OuS6Z4v1PL4zFg0h1jBmFVC5DyL6Q+fwYVtGgtbAcT410USSdLMF6+oW0k1VBjACcAtjkcryhYggH2uzH2IWso9xcP+QZFwQyTqzcduQ83ztkMeXsHOZDLLXqbv21ZIKCd1bFlAk7VsbtXtLD/LIslUyEn9gE+1wEuaZCRQzNs7UOOEc72zxyBjL6cC3jdHfHpblJq5kpoH2SvTdB2F/620tau5MIt49rGsHklb4Y/NiA/7eJSinBASDu56pqxGFPR7sTD2r0IcnG98MvrUoHPvsyI5ZasJcjrdx+F4wzd7dO6Zp+txmX7SBUCVRlP6JYIaisETzf0NsvHaBOVh3rJe75WQom61zfdeGaReMmoPM+rJSxLSClA+wrpiRZXECC8WyyVsDNqbOvm6hQPW/EJ84VdedikGU2BtKiPvzrfJTRda6+frmWdNjGXEoTmHbEc4TrcsYldAaGRKxO9qxj6LpHq+xM=
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 Michael Bleigh and Intridea, 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.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# OmniAuth Suzuri
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/zaikoflow/omniauth-suzuri.png)](https://travis-ci.org/zaikoflow/omniauth-suzuri)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/zaikoflow/omniauth-suzuri/badges/gpa.svg)](https://codeclimate.com/github/zaikoflow/omniauth-suzuri)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/zaikoflow/omniauth-suzuri/badges/coverage.svg)](https://codeclimate.com/github/zaikoflow/omniauth-suzuri)
|
6
|
+
[![Dependency Status](https://gemnasium.com/zaikoflow/omniauth-suzuri.svg)](https://gemnasium.com/zaikoflow/omniauth-suzuri)
|
7
|
+
|
8
|
+
Omniauth for [SUZURI](https://suzuri.jp/)
|
9
|
+
|
10
|
+
Instration
|
11
|
+
----------
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'omniauth-suzuri'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install omniauth-suzuri
|
24
|
+
|
25
|
+
Test
|
26
|
+
----
|
27
|
+
|
28
|
+
```
|
29
|
+
bundle exec rspec
|
30
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Suzuri < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
site: 'https://suzuri.jp',
|
8
|
+
authorize_url: '/oauth/authorize',
|
9
|
+
token_url: '/oauth/token'
|
10
|
+
}
|
11
|
+
|
12
|
+
uid { raw_info["id"] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{
|
16
|
+
name: raw_info["name"],
|
17
|
+
displayName: raw_info["displayName"],
|
18
|
+
avatarUrl: raw_info["avatarUrl"]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
extra do
|
23
|
+
{ raw_info: raw_info }
|
24
|
+
end
|
25
|
+
|
26
|
+
def raw_info
|
27
|
+
@raw_info ||= access_token.get('/api/v1/user').parsed["user"] || {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def callback_url
|
31
|
+
full_host + script_name + callback_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../lib/omniauth-suzuri/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Masahiro Saito"]
|
5
|
+
gem.email = ["camelmasa@gmail.com"]
|
6
|
+
gem.description = %q{OmniAuth strategy for SUZURI}
|
7
|
+
gem.summary = %q{OmniAuth strategy for SUZURI.}
|
8
|
+
gem.homepage = "https://github.com/stockflow/omniauth-suzuri"
|
9
|
+
gem.license = "MIT"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = "omniauth-suzuri"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = OmniAuth::Suzuri::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency 'omniauth', '~> 1.2'
|
18
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.4'
|
19
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
20
|
+
gem.add_development_dependency 'rack-test', "~> 0.6"
|
21
|
+
gem.add_development_dependency "webmock", "~> 1.22"
|
22
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Suzuri do
|
4
|
+
subject do
|
5
|
+
described_class.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
context "client options" do
|
9
|
+
it 'returns correct site' do
|
10
|
+
expect(subject.options.client_options.site).to eq("https://suzuri.jp")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns correct authorize_url' do
|
14
|
+
expect(subject.options.client_options.authorize_url).to eq("/oauth/authorize")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns correct token_url' do
|
18
|
+
expect(subject.options.client_options.token_url).to eq("/oauth/token")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "uid" do
|
23
|
+
before do
|
24
|
+
allow(subject).to receive(:raw_info) { { "id" => "suzuri" } }
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns correct uid' do
|
28
|
+
expect(subject.uid).to eq("suzuri")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "info" do
|
33
|
+
before do
|
34
|
+
allow(subject).to receive(:raw_info) { { "name" => "suzuri1", "displayName" => "suzuri2",
|
35
|
+
"avatarUrl" => "https://localhost" } }
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns correct info' do
|
39
|
+
expect(subject.info).to eq({ name: "suzuri1", displayName: "suzuri2",
|
40
|
+
avatarUrl: "https://localhost" })
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "extra" do
|
45
|
+
before do
|
46
|
+
allow(subject).to receive(:raw_info) { { "id" => "suzuri" } }
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns correct extra block' do
|
50
|
+
expect(subject.extra).to eq({ raw_info: { "id" => "suzuri" } })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#raw_info" do
|
55
|
+
let(:access_token) { double('AccessToken', options: {}) }
|
56
|
+
let(:response) { double('Response', parsed: { "user" => { "id" => "suzuri" } } ) }
|
57
|
+
|
58
|
+
before do
|
59
|
+
allow(subject).to receive(:access_token) { access_token }
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns raw_info" do
|
63
|
+
allow(access_token).to receive(:get).with('/api/v1/user') { response }
|
64
|
+
expect(subject.raw_info).to eq({ "id" => "suzuri" })
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#callback_url" do
|
69
|
+
it "returns callback url" do
|
70
|
+
allow(subject).to receive(:full_host) { "http://localhost" }
|
71
|
+
allow(subject).to receive(:script_name) { "/1" }
|
72
|
+
|
73
|
+
expect(subject.callback_url).to eq "http://localhost/1/auth/suzuri/callback"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
formatter SimpleCov::Formatter::MultiFormatter.new(
|
8
|
+
[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
CodeClimate::TestReporter::Formatter
|
11
|
+
]
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'omniauth-suzuri'
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-suzuri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Saito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-23 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.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
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'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
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.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.22'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.22'
|
83
|
+
description: OmniAuth strategy for SUZURI
|
84
|
+
email:
|
85
|
+
- camelmasa@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/omniauth-suzuri.rb
|
98
|
+
- lib/omniauth-suzuri/version.rb
|
99
|
+
- lib/omniauth/strategies/suzuri.rb
|
100
|
+
- omniauth-suzuri.gemspec
|
101
|
+
- spec/omniauth/strategies/suzuri_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/stockflow/omniauth-suzuri
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: OmniAuth strategy for SUZURI.
|
127
|
+
test_files:
|
128
|
+
- spec/omniauth/strategies/suzuri_spec.rb
|
129
|
+
- spec/spec_helper.rb
|