gitlab-omniauth-openid-connect 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/config/rubocop_linter_action.yml +59 -0
- data/.github/stale.yml +17 -0
- data/.github/workflows/rubocop.yml +22 -0
- data/.gitignore +20 -0
- data/.gitlab-ci.yml +27 -0
- data/.rubocop.yml +58 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +53 -0
- data/Gemfile +4 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +130 -0
- data/Rakefile +10 -0
- data/gitlab-omniauth-openid-connect.gemspec +35 -0
- data/lib/omniauth/openid_connect.rb +5 -0
- data/lib/omniauth/openid_connect/errors.rb +9 -0
- data/lib/omniauth/openid_connect/version.rb +7 -0
- data/lib/omniauth/strategies/openid_connect.rb +406 -0
- data/lib/omniauth_openid_connect.rb +3 -0
- data/test/fixtures/id_token.txt +1 -0
- data/test/fixtures/jwks.json +8 -0
- data/test/fixtures/test.crt +19 -0
- data/test/lib/omniauth/strategies/openid_connect_test.rb +684 -0
- data/test/strategy_test_case.rb +64 -0
- data/test/test_helper.rb +16 -0
- metadata +258 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
class StrategyTestCase < MiniTest::Test
|
2
|
+
class DummyApp
|
3
|
+
def call(env); end
|
4
|
+
end
|
5
|
+
|
6
|
+
attr_accessor :identifier, :secret, :issuer, :nonce
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@identifier = '1234'
|
10
|
+
@secret = '1234asdgat3'
|
11
|
+
@issuer = "https://server.example.com"
|
12
|
+
@nonce = SecureRandom.hex(16)
|
13
|
+
end
|
14
|
+
|
15
|
+
def client
|
16
|
+
strategy.client
|
17
|
+
end
|
18
|
+
|
19
|
+
def payload
|
20
|
+
{
|
21
|
+
"iss": issuer,
|
22
|
+
"aud": identifier,
|
23
|
+
"sub": "248289761001",
|
24
|
+
"nonce": nonce,
|
25
|
+
"exp": Time.now.to_i + 1000,
|
26
|
+
"iat": Time.now.to_i + 1000
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def user_info
|
31
|
+
@user_info ||= OpenIDConnect::ResponseObject::UserInfo.new(
|
32
|
+
sub: SecureRandom.hex(16),
|
33
|
+
name: Faker::Name.name,
|
34
|
+
email: Faker::Internet.email,
|
35
|
+
nickname: Faker::Name.first_name,
|
36
|
+
preferred_username: Faker::Internet.user_name,
|
37
|
+
given_name: Faker::Name.first_name,
|
38
|
+
family_name: Faker::Name.last_name,
|
39
|
+
gender: 'female',
|
40
|
+
picture: Faker::Internet.url + '.png',
|
41
|
+
phone_number: Faker::PhoneNumber.phone_number,
|
42
|
+
website: Faker::Internet.url,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def request
|
47
|
+
@request ||= stub('Request').tap do |request|
|
48
|
+
request.stubs(:params).returns({})
|
49
|
+
request.stubs(:cookies).returns({})
|
50
|
+
request.stubs(:env).returns({})
|
51
|
+
request.stubs(:scheme).returns({})
|
52
|
+
request.stubs(:ssl?).returns(false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def strategy
|
57
|
+
@strategy ||= OmniAuth::Strategies::OpenIDConnect.new(DummyApp.new).tap do |strategy|
|
58
|
+
strategy.options.client_options.identifier = @identifier
|
59
|
+
strategy.options.client_options.secret = @secret
|
60
|
+
strategy.stubs(:request).returns(request)
|
61
|
+
strategy.stubs(:user_info).returns(user_info)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'mocha/minitest'
|
8
|
+
require 'faker'
|
9
|
+
require 'active_support'
|
10
|
+
require 'omniauth_openid_connect'
|
11
|
+
require_relative 'strategy_test_case'
|
12
|
+
|
13
|
+
SimpleCov.command_name 'test'
|
14
|
+
SimpleCov.start
|
15
|
+
Coveralls.wear!
|
16
|
+
OmniAuth.config.test_mode = true
|
metadata
ADDED
@@ -0,0 +1,258 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitlab-omniauth-openid-connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Bohn
|
8
|
+
- Ilya Shcherbinin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: addressable
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.7'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: omniauth
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.9'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: openid_connect
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.2'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.2'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: coveralls
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.8'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.8'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: faker
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.17'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.17'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: guard
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.14'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.14'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: guard-bundler
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: guard-minitest
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2.4'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2.4'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: minitest
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '5.14'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '5.14'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: mocha
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.12'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '1.12'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: rake
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '13.0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '13.0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: rubocop
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '1.12'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '1.12'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: simplecov
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0.16'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0.16'
|
196
|
+
description: OpenID Connect Strategy for OmniAuth.
|
197
|
+
email:
|
198
|
+
- jjbohn@gmail.com
|
199
|
+
- m0n9oose@gmail.com
|
200
|
+
executables: []
|
201
|
+
extensions: []
|
202
|
+
extra_rdoc_files: []
|
203
|
+
files:
|
204
|
+
- ".github/config/rubocop_linter_action.yml"
|
205
|
+
- ".github/stale.yml"
|
206
|
+
- ".github/workflows/rubocop.yml"
|
207
|
+
- ".gitignore"
|
208
|
+
- ".gitlab-ci.yml"
|
209
|
+
- ".rubocop.yml"
|
210
|
+
- ".travis.yml"
|
211
|
+
- CHANGELOG.md
|
212
|
+
- Gemfile
|
213
|
+
- Guardfile
|
214
|
+
- LICENSE.txt
|
215
|
+
- README.md
|
216
|
+
- Rakefile
|
217
|
+
- gitlab-omniauth-openid-connect.gemspec
|
218
|
+
- lib/omniauth/openid_connect.rb
|
219
|
+
- lib/omniauth/openid_connect/errors.rb
|
220
|
+
- lib/omniauth/openid_connect/version.rb
|
221
|
+
- lib/omniauth/strategies/openid_connect.rb
|
222
|
+
- lib/omniauth_openid_connect.rb
|
223
|
+
- test/fixtures/id_token.txt
|
224
|
+
- test/fixtures/jwks.json
|
225
|
+
- test/fixtures/test.crt
|
226
|
+
- test/lib/omniauth/strategies/openid_connect_test.rb
|
227
|
+
- test/strategy_test_case.rb
|
228
|
+
- test/test_helper.rb
|
229
|
+
homepage: https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect
|
230
|
+
licenses:
|
231
|
+
- MIT
|
232
|
+
metadata: {}
|
233
|
+
post_install_message:
|
234
|
+
rdoc_options: []
|
235
|
+
require_paths:
|
236
|
+
- lib
|
237
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: '0'
|
242
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '0'
|
247
|
+
requirements: []
|
248
|
+
rubygems_version: 3.1.4
|
249
|
+
signing_key:
|
250
|
+
specification_version: 4
|
251
|
+
summary: OpenID Connect Strategy for OmniAuth
|
252
|
+
test_files:
|
253
|
+
- test/fixtures/id_token.txt
|
254
|
+
- test/fixtures/jwks.json
|
255
|
+
- test/fixtures/test.crt
|
256
|
+
- test/lib/omniauth/strategies/openid_connect_test.rb
|
257
|
+
- test/strategy_test_case.rb
|
258
|
+
- test/test_helper.rb
|