omniauth-tanmer 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/lib/omniauth-tanmer.rb +2 -0
- data/lib/omniauth-tanmer/version.rb +5 -0
- data/lib/omniauth/strategies/tanmer.rb +42 -0
- data/omniauth-tanmer.gemspec +27 -0
- data/spec/omniauth/strategies/tanmer_spec.rb +67 -0
- data/spec/spec_helper.rb +18 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b95efc0fa304337376d38ea8e1d86717f28edd65
|
4
|
+
data.tar.gz: 33bc6db336be0c1941ce041f8ba0907886bf447b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 960980a16606b64faa462b76d83b95e4ca66098b8c02350bee3f3fbd534a3868812da80233412e6197240eaff7c218db6428ac013869799b4a60022da3cbd61c
|
7
|
+
data.tar.gz: 9f21bbf2a2045076c19e592de9a7eb8a165b8f38b6eafb6e97b0f9898f7023f831eff98c228eaaabf18251e03db366b771c38023f1ef77bb16d6a24ff89c992f
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 ssein
|
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,33 @@
|
|
1
|
+
# Omniauth::Tanmer
|
2
|
+
|
3
|
+
This is the OAuth2 strategy for authenticating to your Tanmer service.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'omniauth-tanmer'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-tanmer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
use OmniAuth::Builder do
|
24
|
+
provider :tanmer, ENV['TANMER_KEY'], ENV['TANMER_SECRET']
|
25
|
+
end
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Tanmer < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :client_options, {
|
8
|
+
site: 'https://login.tanmer.com',
|
9
|
+
authorize_url: '/oauth/authorize',
|
10
|
+
token_url: '/oauth/token'
|
11
|
+
}
|
12
|
+
|
13
|
+
option :redirect_url
|
14
|
+
|
15
|
+
uid { raw_info['uid'] }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
name: raw_info['name'],
|
20
|
+
email: raw_info['email'],
|
21
|
+
image: raw_info['image']
|
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/v1/user').parsed
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def callback_url
|
36
|
+
options.redirect_url || (full_host + script_name + callback_path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
OmniAuth.config.add_camelization 'tanmer', 'Tanmer'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-tanmer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'omniauth-tanmer'
|
8
|
+
gem.version = Omniauth::Tanmer::VERSION
|
9
|
+
gem.authors = ['xiaohui']
|
10
|
+
gem.email = ['xiaohui@tanmer.com']
|
11
|
+
gem.description = %q{This is the strategy for authenticating to your Tanmer service}
|
12
|
+
gem.summary = %q{This is the strategy for authenticating to your Tanmer service}
|
13
|
+
gem.homepage = 'https://gitlab.tanmer.com/tanmer/omniauth-tanmer'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
21
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.1'
|
23
|
+
gem.add_development_dependency 'rspec-its', '~> 1.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,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Tanmer do
|
4
|
+
|
5
|
+
let(:access_token) { double('AccessToken') }
|
6
|
+
let(:parsed_response) { double('ParsedResponse') }
|
7
|
+
let(:response) { double('Response', parsed: parsed_response) }
|
8
|
+
|
9
|
+
let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
|
10
|
+
let(:enterprise_authorize_url) { '/oauth/authorize' }
|
11
|
+
let(:enterprise_token_url) { '/oauth/access_token' }
|
12
|
+
|
13
|
+
let(:tanmer_service) { OmniAuth::Strategies::Tanmer.new({}) }
|
14
|
+
let(:enterprise) do
|
15
|
+
OmniAuth::Strategies::Tanmer.new('TANMER_KEY', 'TANMER_SECRET',
|
16
|
+
client_options: {
|
17
|
+
site: enterprise_site,
|
18
|
+
authorize_url: enterprise_authorize_url,
|
19
|
+
token_url: enterprise_token_url
|
20
|
+
},
|
21
|
+
redirect_url: 'http://localhost:9292/callback_url'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
subject { tanmer_service }
|
26
|
+
|
27
|
+
before(:each) do
|
28
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'client options' do
|
32
|
+
context 'with defaults' do
|
33
|
+
subject { tanmer_service.options.client_options }
|
34
|
+
|
35
|
+
its(:site) { is_expected.to eq 'https://login.tanmer.com' }
|
36
|
+
its(:authorize_url) { is_expected.to eq '/oauth/authorize' }
|
37
|
+
its(:token_url) { is_expected.to eq '/oauth/token' }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with override' do
|
41
|
+
subject { enterprise.options.client_options }
|
42
|
+
|
43
|
+
its(:site) { is_expected.to eq enterprise_site }
|
44
|
+
its(:authorize_url) { is_expected.to eq enterprise_authorize_url }
|
45
|
+
its(:token_url) { is_expected.to eq enterprise_token_url }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'redirect_url' do
|
50
|
+
context 'with defaults' do
|
51
|
+
subject { tanmer_service.options }
|
52
|
+
its(:redirect_url) { is_expected.to be_nil }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with customs' do
|
56
|
+
subject { enterprise.options }
|
57
|
+
its(:redirect_url) { is_expected.to eq 'http://localhost:9292/callback_url' }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#raw_info' do
|
62
|
+
it 'sent request to current user endpoint' do
|
63
|
+
expect(access_token).to receive(:get).with('/api/v1/user').and_return(response)
|
64
|
+
expect(subject.raw_info).to eq(parsed_response)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/its'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
require 'omniauth'
|
10
|
+
require 'omniauth-tanmer'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include WebMock::API
|
14
|
+
config.include Rack::Test::Methods
|
15
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
16
|
+
end
|
17
|
+
|
18
|
+
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-tanmer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- xiaohui
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-06 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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
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: simplecov
|
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: webmock
|
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
|
+
description: This is the strategy for authenticating to your Tanmer service
|
112
|
+
email:
|
113
|
+
- xiaohui@tanmer.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/omniauth-tanmer.rb
|
125
|
+
- lib/omniauth-tanmer/version.rb
|
126
|
+
- lib/omniauth/strategies/tanmer.rb
|
127
|
+
- omniauth-tanmer.gemspec
|
128
|
+
- spec/omniauth/strategies/tanmer_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
homepage: https://gitlab.tanmer.com/tanmer/omniauth-tanmer
|
131
|
+
licenses: []
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.5.2
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: This is the strategy for authenticating to your Tanmer service
|
153
|
+
test_files:
|
154
|
+
- spec/omniauth/strategies/tanmer_spec.rb
|
155
|
+
- spec/spec_helper.rb
|