omniauth-restauth 0.0.4
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.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +1 -0
- data/Rakefile +7 -0
- data/lib/omniauth-restauth.rb +2 -0
- data/lib/omniauth-restauth/version.rb +5 -0
- data/lib/omniauth/strategies/restauth.rb +35 -0
- data/omniauth-restauth.gemspec +30 -0
- data/spec/omiauth/strategies/restauth_spec.rb +54 -0
- data/spec/spec_helper.rb +18 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b05ea72ff3a043611e4dd0564b0ffec460c35f3
|
4
|
+
data.tar.gz: b92cbdc85a3c7c7624e995b49757a16b7cda3d8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 627d316ca4aa6fff29f16858aaf8aa63a7179ce25f7a212f2f7a60c952795e5f3e8f883e03be10228475361cdafc1f73cc94abb99a71937b9e3c416fd684d4f7
|
7
|
+
data.tar.gz: b01759fbc1b7b83eb1cfb5b97171b290c11e6d65e3ce18938218f5c9dc7edd926fde430cf0be2dacae91330d4d04f0737af79de4935361889b6c385980f4ecee
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Shkeeper
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# omniauth-restauth
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Restauth < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :client_options, {
|
8
|
+
site: '192.168.1.5:8080',
|
9
|
+
authorize_url: '/oauth/authorize',
|
10
|
+
token_url: '/oauth/token'
|
11
|
+
}
|
12
|
+
|
13
|
+
uid { raw_info['id'].to_s }
|
14
|
+
|
15
|
+
info do
|
16
|
+
{
|
17
|
+
name: raw_info['name'],
|
18
|
+
username: raw_info['username'],
|
19
|
+
email: raw_info['email']
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
extra do
|
24
|
+
{ raw_info: raw_info }
|
25
|
+
end
|
26
|
+
|
27
|
+
def raw_info
|
28
|
+
@raw_info ||= access_token.get('/me').parsed
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
OmniAuth.config.add_camelization 'restauth', 'Restauth'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-restauth/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-restauth"
|
8
|
+
spec.version = Omniauth::Restauth::VERSION
|
9
|
+
spec.authors = ["Alex"]
|
10
|
+
spec.email = ["shkeeper@bigmir.net"]
|
11
|
+
spec.summary = %q{Testing new Strategy}
|
12
|
+
spec.description = %q{This is the testing source}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'omniauth', '~> 1.0'
|
22
|
+
spec.add_development_dependency 'omniauth-oauth2', '~> 1.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
24
|
+
spec.add_development_dependency 'rspec-its', '~> 1.0'
|
25
|
+
spec.add_development_dependency 'rack-test'
|
26
|
+
spec.add_development_dependency 'simplecov'
|
27
|
+
spec.add_development_dependency 'webmock'
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Restauth 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) { '192.168.1.5:8080' }
|
10
|
+
let(:enterprise_authorize_url) { '/oauth/authorize' }
|
11
|
+
let(:enterprise_token_url) { '/oauth/access_token' }
|
12
|
+
|
13
|
+
let(:gitlab_service) { OmniAuth::Strategies::Restauth.new({}) }
|
14
|
+
let(:enterprise) do
|
15
|
+
OmniAuth::Strategies::Restauth.new('gitlabkey', 'gitlabsecret',
|
16
|
+
client_options: {
|
17
|
+
site: enterprise_site,
|
18
|
+
authorize_url: enterprise_authorize_url,
|
19
|
+
token_url: enterprise_token_url
|
20
|
+
}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { gitlab_service }
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'client options' do
|
31
|
+
context 'with defaults' do
|
32
|
+
subject { gitlab_service.options.client_options }
|
33
|
+
|
34
|
+
its(:site) { is_expected.to eq '192.168.1.5:8080' }
|
35
|
+
its(:authorize_url) { is_expected.to eq '/oauth/authorize' }
|
36
|
+
its(:token_url) { is_expected.to eq '/oauth/token' }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with override' do
|
40
|
+
subject { enterprise.options.client_options }
|
41
|
+
|
42
|
+
its(:site) { is_expected.to eq enterprise_site }
|
43
|
+
its(:authorize_url) { is_expected.to eq enterprise_authorize_url }
|
44
|
+
its(:token_url) { is_expected.to eq enterprise_token_url }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#raw_info' do
|
49
|
+
it 'sent request to current user endpoint' do
|
50
|
+
expect(access_token).to receive(:get).with('/me').and_return(response)
|
51
|
+
expect(subject.raw_info).to eq(parsed_response)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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-restauth'
|
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,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-restauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-22 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: :development
|
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: :development
|
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
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '10.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '10.0'
|
139
|
+
description: This is the testing source
|
140
|
+
email:
|
141
|
+
- shkeeper@bigmir.net
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- Gemfile
|
147
|
+
- LICENSE
|
148
|
+
- README.md
|
149
|
+
- Rakefile
|
150
|
+
- lib/omniauth-restauth.rb
|
151
|
+
- lib/omniauth-restauth/version.rb
|
152
|
+
- lib/omniauth/strategies/restauth.rb
|
153
|
+
- omniauth-restauth.gemspec
|
154
|
+
- spec/omiauth/strategies/restauth_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
homepage: ''
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.4.6
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: Testing new Strategy
|
180
|
+
test_files:
|
181
|
+
- spec/omiauth/strategies/restauth_spec.rb
|
182
|
+
- spec/spec_helper.rb
|