oidc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/.rubocop.yml +28 -0
  4. data/CHANGELOG.md +4 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +46 -0
  8. data/Rakefile +12 -0
  9. data/lib/oidc/access_token/mtls.rb +9 -0
  10. data/lib/oidc/access_token.rb +45 -0
  11. data/lib/oidc/client/registrar.rb +186 -0
  12. data/lib/oidc/client.rb +43 -0
  13. data/lib/oidc/connect_object.rb +52 -0
  14. data/lib/oidc/discovery/provider/config/resource.rb +39 -0
  15. data/lib/oidc/discovery/provider/config/response.rb +112 -0
  16. data/lib/oidc/discovery/provider/config.rb +20 -0
  17. data/lib/oidc/discovery/provider.rb +34 -0
  18. data/lib/oidc/discovery.rb +8 -0
  19. data/lib/oidc/exception.rb +39 -0
  20. data/lib/oidc/jwtnizable.rb +14 -0
  21. data/lib/oidc/request_object/claimable.rb +54 -0
  22. data/lib/oidc/request_object/id_token.rb +8 -0
  23. data/lib/oidc/request_object/user_info.rb +7 -0
  24. data/lib/oidc/request_object.rb +37 -0
  25. data/lib/oidc/response_object/id_token.rb +99 -0
  26. data/lib/oidc/response_object/user_info/address.rb +10 -0
  27. data/lib/oidc/response_object/user_info.rb +65 -0
  28. data/lib/oidc/response_object.rb +8 -0
  29. data/lib/oidc/version.rb +5 -0
  30. data/lib/oidc.rb +98 -0
  31. data/lib/rack/oauth2/server/authorize/error_with_connect_ext.rb +34 -0
  32. data/lib/rack/oauth2/server/authorize/extension/code_and_id_token.rb +40 -0
  33. data/lib/rack/oauth2/server/authorize/extension/code_and_id_token_and_token.rb +36 -0
  34. data/lib/rack/oauth2/server/authorize/extension/id_token.rb +40 -0
  35. data/lib/rack/oauth2/server/authorize/extension/id_token_and_token.rb +36 -0
  36. data/lib/rack/oauth2/server/authorize/request_with_connect_params.rb +26 -0
  37. data/lib/rack/oauth2/server/id_token_response.rb +24 -0
  38. data/oidc.gemspec +46 -0
  39. data/sig/omniauth_oidc.rbs +4 -0
  40. metadata +252 -0
@@ -0,0 +1,40 @@
1
+ module Rack
2
+ module OAuth2
3
+ module Server
4
+ class Authorize
5
+ module Extension
6
+ class CodeAndIdToken < Abstract::Handler
7
+ class << self
8
+ def response_type_for?(response_type)
9
+ response_type.split.sort == ['code', 'id_token']
10
+ end
11
+ end
12
+
13
+ def _call(env)
14
+ @request = Request.new env
15
+ @response = Response.new request
16
+ super
17
+ end
18
+
19
+ class Request < Authorize::Code::Request
20
+ def initialize(env)
21
+ super
22
+ @response_type = [:code, :id_token]
23
+ attr_missing!
24
+ end
25
+
26
+ def error_params_location
27
+ :fragment
28
+ end
29
+ end
30
+
31
+ class Response < Authorize::Code::Response
32
+ include IdTokenResponse
33
+ attr_required :id_token
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,36 @@
1
+ module Rack
2
+ module OAuth2
3
+ module Server
4
+ class Authorize
5
+ module Extension
6
+ class CodeAndIdTokenAndToken < Abstract::Handler
7
+ class << self
8
+ def response_type_for?(response_type)
9
+ response_type.split.sort == ['code', 'id_token', 'token']
10
+ end
11
+ end
12
+
13
+ def _call(env)
14
+ @request = Request.new env
15
+ @response = Response.new request
16
+ super
17
+ end
18
+
19
+ class Request < Authorize::Extension::CodeAndToken::Request
20
+ def initialize(env)
21
+ super
22
+ @response_type = [:code, :id_token, :token]
23
+ attr_missing!
24
+ end
25
+ end
26
+
27
+ class Response < Authorize::Extension::CodeAndToken::Response
28
+ include IdTokenResponse
29
+ attr_required :id_token
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ module Rack
2
+ module OAuth2
3
+ module Server
4
+ class Authorize
5
+ module Extension
6
+ class IdToken < Abstract::Handler
7
+ class << self
8
+ def response_type_for?(response_type)
9
+ response_type == 'id_token'
10
+ end
11
+ end
12
+
13
+ def _call(env)
14
+ @request = Request.new env
15
+ @response = Response.new request
16
+ super
17
+ end
18
+
19
+ class Request < Authorize::Request
20
+ def initialize(env)
21
+ super
22
+ @response_type = :id_token
23
+ attr_missing!
24
+ end
25
+
26
+ def error_params_location
27
+ :fragment
28
+ end
29
+ end
30
+
31
+ class Response < Authorize::Response
32
+ include IdTokenResponse
33
+ attr_required :id_token
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,36 @@
1
+ module Rack
2
+ module OAuth2
3
+ module Server
4
+ class Authorize
5
+ module Extension
6
+ class IdTokenAndToken < Abstract::Handler
7
+ class << self
8
+ def response_type_for?(response_type)
9
+ response_type.split.sort == ['id_token', 'token']
10
+ end
11
+ end
12
+
13
+ def _call(env)
14
+ @request = Request.new env
15
+ @response = Response.new request
16
+ super
17
+ end
18
+
19
+ class Request < Authorize::Token::Request
20
+ def initialize(env)
21
+ super
22
+ @response_type = [:id_token, :token]
23
+ attr_missing!
24
+ end
25
+ end
26
+
27
+ class Response < Authorize::Token::Response
28
+ include IdTokenResponse
29
+ attr_required :id_token
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ class Rack::OAuth2::Server::Authorize
2
+ module RequestWithConnectParams
3
+ CONNECT_EXT_PARAMS = [
4
+ :nonce, :display, :prompt, :max_age, :ui_locales, :claims_locales,
5
+ :id_token_hint, :login_hint, :acr_values, :claims, :request, :request_uri
6
+ ]
7
+
8
+ def self.prepended(klass)
9
+ klass.send :attr_optional, *CONNECT_EXT_PARAMS
10
+ end
11
+
12
+ def initialize(env)
13
+ super
14
+ CONNECT_EXT_PARAMS.each do |attribute|
15
+ self.send :"#{attribute}=", params[attribute.to_s]
16
+ end
17
+ self.prompt = Array(prompt.to_s.split(' '))
18
+ self.max_age = max_age.try(:to_i)
19
+ end
20
+
21
+ def oidc_request?
22
+ scope.include?('openid')
23
+ end
24
+ end
25
+ Request.send :prepend, RequestWithConnectParams
26
+ end
@@ -0,0 +1,24 @@
1
+ module Rack::OAuth2::Server
2
+ module IdTokenResponse
3
+ def self.prepended(klass)
4
+ klass.send :attr_optional, :id_token
5
+ end
6
+
7
+ def protocol_params_location
8
+ :fragment
9
+ end
10
+
11
+ def protocol_params
12
+ super.merge(
13
+ id_token: id_token
14
+ )
15
+ end
16
+ end
17
+ Token::Response.send :prepend, IdTokenResponse
18
+ end
19
+
20
+ require 'rack/oauth2/server/authorize/extension/code_and_id_token'
21
+ require 'rack/oauth2/server/authorize/extension/code_and_token'
22
+ require 'rack/oauth2/server/authorize/extension/code_and_id_token_and_token'
23
+ require 'rack/oauth2/server/authorize/extension/id_token'
24
+ require 'rack/oauth2/server/authorize/extension/id_token_and_token'
data/oidc.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/oidc/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "oidc"
7
+ spec.version = Oidc::VERSION
8
+ spec.authors = ["Suleyman Musayev"]
9
+ spec.email = ["slmusayev@gmail.com"]
10
+
11
+ spec.summary = "OpenID Connect (OIDC) Server & Client Library"
12
+ spec.description = "OpenID Connect (OIDC) Server & Client Library"
13
+ spec.homepage = "https://github.com/msuliq/oidc"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/msuliq/oidc"
19
+ spec.metadata["changelog_uri"] = "https://github.com/msuliq/oidc/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ spec.add_dependency "tzinfo"
35
+ spec.add_dependency "attr_required"
36
+ spec.add_dependency "activemodel"
37
+ spec.add_dependency "validate_url"
38
+ spec.add_dependency "email_validator"
39
+ spec.add_dependency "mail"
40
+ spec.add_dependency 'faraday'
41
+ spec.add_dependency 'faraday-follow_redirects'
42
+ spec.add_dependency "json-jwt"
43
+ spec.add_dependency "swd"
44
+ spec.add_dependency "webfinger"
45
+ spec.add_dependency "rack-oauth2"
46
+ end
@@ -0,0 +1,4 @@
1
+ module OmniauthOidc
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,252 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oidc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Suleyman Musayev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tzinfo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: attr_required
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: validate_url
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: email_validator
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: mail
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
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: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
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: faraday-follow_redirects
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json-jwt
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: swd
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webfinger
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rack-oauth2
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: OpenID Connect (OIDC) Server & Client Library
182
+ email:
183
+ - slmusayev@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".rspec"
189
+ - ".rubocop.yml"
190
+ - CHANGELOG.md
191
+ - CODE_OF_CONDUCT.md
192
+ - LICENSE.txt
193
+ - README.md
194
+ - Rakefile
195
+ - lib/oidc.rb
196
+ - lib/oidc/access_token.rb
197
+ - lib/oidc/access_token/mtls.rb
198
+ - lib/oidc/client.rb
199
+ - lib/oidc/client/registrar.rb
200
+ - lib/oidc/connect_object.rb
201
+ - lib/oidc/discovery.rb
202
+ - lib/oidc/discovery/provider.rb
203
+ - lib/oidc/discovery/provider/config.rb
204
+ - lib/oidc/discovery/provider/config/resource.rb
205
+ - lib/oidc/discovery/provider/config/response.rb
206
+ - lib/oidc/exception.rb
207
+ - lib/oidc/jwtnizable.rb
208
+ - lib/oidc/request_object.rb
209
+ - lib/oidc/request_object/claimable.rb
210
+ - lib/oidc/request_object/id_token.rb
211
+ - lib/oidc/request_object/user_info.rb
212
+ - lib/oidc/response_object.rb
213
+ - lib/oidc/response_object/id_token.rb
214
+ - lib/oidc/response_object/user_info.rb
215
+ - lib/oidc/response_object/user_info/address.rb
216
+ - lib/oidc/version.rb
217
+ - lib/rack/oauth2/server/authorize/error_with_connect_ext.rb
218
+ - lib/rack/oauth2/server/authorize/extension/code_and_id_token.rb
219
+ - lib/rack/oauth2/server/authorize/extension/code_and_id_token_and_token.rb
220
+ - lib/rack/oauth2/server/authorize/extension/id_token.rb
221
+ - lib/rack/oauth2/server/authorize/extension/id_token_and_token.rb
222
+ - lib/rack/oauth2/server/authorize/request_with_connect_params.rb
223
+ - lib/rack/oauth2/server/id_token_response.rb
224
+ - oidc.gemspec
225
+ - sig/omniauth_oidc.rbs
226
+ homepage: https://github.com/msuliq/oidc
227
+ licenses:
228
+ - MIT
229
+ metadata:
230
+ homepage_uri: https://github.com/msuliq/oidc
231
+ source_code_uri: https://github.com/msuliq/oidc
232
+ changelog_uri: https://github.com/msuliq/oidc/blob/main/CHANGELOG.md
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: 2.7.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.6
249
+ signing_key:
250
+ specification_version: 4
251
+ summary: OpenID Connect (OIDC) Server & Client Library
252
+ test_files: []