authproto 0.3.0.beta5 → 0.3.0.beta6

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/examples/basic_webapp/Gemfile.lock +1 -1
  4. data/examples/bookmarks/Gemfile.lock +2 -2
  5. data/examples/bookmarks/README.md +16 -7
  6. data/examples/bookmarks/Rakefile +13 -8
  7. data/examples/bookmarks/app/account.rb +2 -1
  8. data/examples/bookmarks/app/bookmark.rb +28 -33
  9. data/examples/bookmarks/app/bookmark_sync.rb +56 -0
  10. data/examples/bookmarks/app/server.rb +23 -9
  11. data/examples/bookmarks/app/session.rb +21 -0
  12. data/examples/bookmarks/db/migrate/20261117120000_add_sessions.rb +36 -0
  13. data/examples/bookmarks/db/migrate/20261117120100_add_timestamps_to_sessions.rb +18 -0
  14. data/examples/bookmarks/db/schema.rb +13 -2
  15. data/examples/bookmarks/views/bookmarks.erb +10 -0
  16. data/examples/minisky_console/Gemfile.lock +2 -2
  17. data/lib/authproto/client.rb +24 -11
  18. data/lib/authproto/client_assertion.rb +147 -0
  19. data/lib/authproto/metadata/authorization_server.rb +15 -3
  20. data/lib/authproto/metadata/client_metadata.rb +2 -2
  21. data/lib/authproto/minisky.rb +1 -0
  22. data/lib/authproto/par/client.rb +1 -1
  23. data/lib/authproto/par/request.rb +8 -3
  24. data/lib/authproto/par.rb +0 -4
  25. data/lib/authproto/storage/sqlite.rb +53 -16
  26. data/lib/authproto/token/refresh.rb +4 -5
  27. data/lib/authproto/token/revocation.rb +3 -3
  28. data/lib/authproto/version.rb +1 -1
  29. data/sig/authproto/client.rbs +3 -2
  30. data/sig/authproto/client_assertion.rbs +14 -0
  31. data/sig/authproto/metadata/authorization_server.rbs +2 -0
  32. data/sig/authproto/minisky.rbs +3 -1
  33. data/sig/authproto/par/request.rbs +3 -0
  34. data/sig/authproto/par.rbs +0 -1
  35. data/sig/authproto/token/refresh.rbs +1 -1
  36. data/sig/authproto/token/revocation.rbs +1 -1
  37. metadata +7 -3
  38. data/lib/authproto/par/client_assertion.rb +0 -146
  39. data/sig/authproto/par/client_assertion.rbs +0 -15
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jose'
4
+ require 'jwt'
5
+ require 'securerandom'
6
+
7
+ require_relative 'configuration'
8
+ require_relative 'errors'
9
+
10
+ module AuthProto
11
+
12
+ #
13
+ # @api private
14
+ #
15
+ # Generates client authentication JWTs according to RFC 7523 for AT Protocol OAuth.
16
+ # Creates signed assertions using ES256 with required claims including iss/sub (client_id),
17
+ # aud (authorization server issuer), jti (unique ID), and iat/exp (timing claims).
18
+ #
19
+
20
+ class ClientAssertion
21
+
22
+ # Raised when client assertion key import or JWT signing fails.
23
+ class Error < AuthProto::Error; end
24
+
25
+ # JWS signing algorithm used for client assertions.
26
+ # @return [String]
27
+ ALGORITHM = "ES256"
28
+
29
+ # URN identifying the assertion type, set in the `client_assertion_type` field in OAuth requests.
30
+ # @return [String]
31
+ TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
32
+
33
+ # Validated private EC P-256 key used by this reusable assertion signer.
34
+ # @return [JOSE::JWK]
35
+ attr_reader :signing_key
36
+
37
+ # Creates an ES256 client assertion signer.
38
+ #
39
+ # @param client_id [String] client ID used in `iss` and `sub`
40
+ # @param signing_key [Hash, JOSE::JWK] private EC P-256 signing key, including its `kid`
41
+ # @raise [Error] if the key cannot sign with ES256 or its usage is incompatible
42
+ # (`key_ops`, when present, must contain `sign` and optionally `verify`, without duplicates)
43
+ # @raise [Error] if the client ID is not a nonblank string
44
+ #
45
+ def initialize(client_id:, signing_key:)
46
+ unless client_id.is_a?(String) && !client_id.strip.empty?
47
+ raise Error, "client_id must be a nonblank string"
48
+ end
49
+
50
+ @client_id = client_id.dup.freeze
51
+ @signing_key = validate_signing_key(signing_key)
52
+ rescue ClientAssertion::Error
53
+ raise
54
+ rescue StandardError => e
55
+ raise Error, "Invalid signing_key: #{e.message}"
56
+ end
57
+
58
+ # Signs a fresh, short-lived client authentication JWT with the cached ES256 key.
59
+ #
60
+ # Includes `iss`, `sub`, `aud`, a unique `jti`, and `iat`/`exp` times.
61
+ #
62
+ # @param audience [String] authorization server issuer URL used as the assertion audience
63
+ # @param lifetime [Integer] positive validity in seconds; defaults to {Configuration#client_assertion_lifetime}
64
+ # @return [String] compact signed client assertion JWT
65
+ # @raise [Error] if the audience is not a nonblank string, lifetime is not a positive integer, or signing fails
66
+ #
67
+ def generate_jwt(audience:, lifetime: AuthProto.configuration.client_assertion_lifetime)
68
+ unless audience.is_a?(String) && !audience.strip.empty?
69
+ raise Error, "audience must be a nonblank string"
70
+ end
71
+
72
+ unless lifetime.is_a?(Integer) && lifetime.positive?
73
+ raise Error, "lifetime must be a positive integer"
74
+ end
75
+
76
+ now = Time.now.to_i
77
+
78
+ payload = {
79
+ iss: @client_id, # issuer
80
+ sub: @client_id, # subject
81
+ aud: audience, # audience is the authorization server issuer
82
+ jti: SecureRandom.uuid, # token identifier
83
+ exp: now + lifetime, # expiration time
84
+ iat: now # issued at time
85
+ }
86
+
87
+ header = {
88
+ alg: ALGORITHM,
89
+ typ: 'JWT',
90
+ kid: @signing_key.fields['kid']
91
+ }
92
+
93
+ JWT.encode(payload, @jwt_signing_key, ALGORITHM, header)
94
+ rescue JWT::Error, ArgumentError => e
95
+ raise Error, "Failed to generate client assertion: #{e.message}"
96
+ end
97
+
98
+
99
+ private
100
+
101
+ def validate_signing_key(signing_key)
102
+ data = signing_key.is_a?(JOSE::JWK) ? signing_key.to_map.to_h : signing_key
103
+
104
+ raise Error, "signing_key must be a hash or a JOSE::JWK" unless data.is_a?(Hash)
105
+ raise Error, "signing_key must be active" if data['revoked']
106
+
107
+ unless data['kty'] == 'EC' && data['crv'] == 'P-256'
108
+ raise Error, "signing_key must be a EC P-256 JWK"
109
+ end
110
+
111
+ unless data['d'].is_a?(String) && !data['d'].empty?
112
+ raise Error, "signing_key must be a private key ('d' field must not be empty)"
113
+ end
114
+
115
+ %w[kid x y].each do |field|
116
+ unless data[field].is_a?(String) && !data[field].empty?
117
+ raise Error, "signing_key '#{field}' field must not be empty"
118
+ end
119
+ end
120
+
121
+ if (data.key?('alg') && data['alg'] != ALGORITHM) ||
122
+ (data.key?('use') && data['use'] != 'sig')
123
+ raise Error, "signing_key must be active and permit #{ALGORITHM} signing"
124
+ end
125
+
126
+ if data.key?('key_ops')
127
+ raise Error, "signing_key.key_ops is not an array" unless data['key_ops'].is_a?(Array)
128
+
129
+ ops = data['key_ops'].sort_by(&:to_s)
130
+
131
+ unless ops == ['sign'] || ops == ['sign', 'verify']
132
+ raise Error, "signing_key.key_ops must contain sign and optionally verify, without duplicates"
133
+ end
134
+ end
135
+
136
+ signing_key = JOSE::JWK.from_map(data)
137
+
138
+ imported_key = JWT::JWK.import(data)
139
+ proof = JWT.encode({}, imported_key, ALGORITHM)
140
+ JWT.decode(proof, imported_key.public_key, true, algorithms: [ALGORITHM])
141
+
142
+ @jwt_signing_key = imported_key
143
+
144
+ signing_key
145
+ end
146
+ end
147
+ end
@@ -3,13 +3,13 @@
3
3
  require 'json'
4
4
  require 'uri'
5
5
 
6
+ require_relative '../client_assertion'
6
7
  require_relative '../configuration'
7
8
  require_relative '../dpop'
8
9
  require_relative '../errors'
9
10
  require_relative '../http_client'
10
11
  require_relative '../http_helpers'
11
12
  require_relative '../metadata'
12
- require_relative '../par/client_assertion'
13
13
  require_relative '../validated_uri'
14
14
 
15
15
  module AuthProto
@@ -102,6 +102,10 @@ module AuthProto
102
102
  # @return [Array<String>]
103
103
  attr_reader :scopes_supported
104
104
 
105
+ # List of prompt modes supported by the authorization server, if supplied.
106
+ # @return [Array<String>, nil]
107
+ attr_reader :prompt_values_supported
108
+
105
109
  # Supported DPoP algorithms, including `ES256`.
106
110
  # @return [Array<String>]
107
111
  attr_reader :dpop_signing_alg_values_supported
@@ -149,7 +153,7 @@ module AuthProto
149
153
  # @return [Hash{Symbol => String, Array<String>, Boolean}] authorization server metadata
150
154
  #
151
155
  def to_h
152
- {
156
+ metadata = {
153
157
  issuer: issuer,
154
158
  authorization_endpoint: authorization_endpoint,
155
159
  token_endpoint: token_endpoint,
@@ -166,6 +170,9 @@ module AuthProto
166
170
  require_pushed_authorization_requests: true,
167
171
  client_id_metadata_document_supported: true
168
172
  }
173
+
174
+ metadata[:prompt_values_supported] = prompt_values_supported if prompt_values_supported
175
+ metadata
169
176
  end
170
177
 
171
178
 
@@ -201,6 +208,11 @@ module AuthProto
201
208
  validate_dpop_signing_algs
202
209
  validate_scopes
203
210
 
211
+ if data.key?('prompt_values_supported')
212
+ @prompt_values_supported = data['prompt_values_supported']
213
+ validate_string_array(@prompt_values_supported, 'prompt_values_supported')
214
+ end
215
+
204
216
  # Required boolean fields
205
217
  validate_boolean_field(data, 'authorization_response_iss_parameter_supported', true)
206
218
  validate_boolean_field(data, 'require_pushed_authorization_requests', true)
@@ -274,7 +286,7 @@ module AuthProto
274
286
  @token_endpoint_auth_signing_alg_values_supported, 'token_endpoint_auth_signing_alg_values_supported'
275
287
  )
276
288
 
277
- algorithm = PAR::ClientAssertion::ALGORITHM
289
+ algorithm = ClientAssertion::ALGORITHM
278
290
 
279
291
  unless @token_endpoint_auth_signing_alg_values_supported.include?(algorithm)
280
292
  raise InvalidAuthorizationServer, "token_endpoint_auth_signing_alg_values_supported must include #{algorithm}"
@@ -5,11 +5,11 @@ require 'jose'
5
5
  require 'json'
6
6
  require 'uri'
7
7
 
8
+ require_relative '../client_assertion'
8
9
  require_relative '../configuration'
9
10
  require_relative '../errors'
10
11
  require_relative '../http_helpers'
11
12
  require_relative '../metadata'
12
- require_relative '../par/client_assertion'
13
13
  require_relative '../validated_uri'
14
14
 
15
15
  module AuthProto
@@ -603,7 +603,7 @@ module AuthProto
603
603
  end
604
604
 
605
605
  def validate_auth_confidential(metadata)
606
- algorithm = PAR::ClientAssertion::ALGORITHM
606
+ algorithm = ClientAssertion::ALGORITHM
607
607
 
608
608
  unless @token_endpoint_auth_signing_alg == algorithm
609
609
  raise InvalidClientMetadata, "token_endpoint_auth_signing_alg must be #{algorithm}"
@@ -160,6 +160,7 @@ class Minisky::OAuth
160
160
  # @option options [String] :handle account handle, optionally prefixed with `@`
161
161
  # @option options [String] :pds PDS URL, as an alternative to `handle`
162
162
  # @option options [String] :scope ('atproto') requested scopes
163
+ # @option options [String] :prompt optional authorization prompt mode, such as `consent`
163
164
  #
164
165
  # @return [Hash{Symbol => String}] `:url` to open and pending `:session_id`
165
166
  # @raise [AuthProto::Error] if authorization, discovery, PAR or persistence fails
@@ -52,7 +52,7 @@ module AuthProto
52
52
  # @example With client authentication (confidential clients)
53
53
  # request = AuthProto::PAR::Request.build do |config|
54
54
  # # ... basic parameters ...
55
- # config.client_assertion = AuthProto::PAR::ClientAssertion.new(client_id: client_id, signing_key: signing_key)
55
+ # config.client_assertion = AuthProto::ClientAssertion.new(client_id: client_id, signing_key: signing_key)
56
56
  # end
57
57
  #
58
58
  # All requests use HTTPS and include a fresh DPoP proof from the supplied
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'uri'
4
4
 
5
+ require_relative '../client_assertion'
5
6
  require_relative '../par'
6
- require_relative 'client_assertion'
7
7
 
8
8
  module AuthProto
9
9
  module PAR
@@ -47,6 +47,10 @@ module AuthProto
47
47
  # @return [String, nil]
48
48
  attr_reader :login_hint
49
49
 
50
+ # Optional authorization prompt mode.
51
+ # @return [String, nil]
52
+ attr_reader :prompt
53
+
50
54
  # Optional authorization nonce parameter.
51
55
  # @return [String, nil]
52
56
  attr_reader :nonce
@@ -119,6 +123,7 @@ module AuthProto
119
123
  }
120
124
 
121
125
  params['login_hint'] = login_hint if login_hint
126
+ params['prompt'] = prompt if prompt
122
127
  params['nonce'] = nonce if nonce
123
128
 
124
129
  if client_assertion
@@ -126,7 +131,7 @@ module AuthProto
126
131
  raise Error, "audience is required with client_assertion"
127
132
  end
128
133
 
129
- params['client_assertion_type'] = CLIENT_ASSERTION_TYPE
134
+ params['client_assertion_type'] = ClientAssertion::TYPE
130
135
  params['client_assertion'] = client_assertion.generate_jwt(audience: audience)
131
136
  end
132
137
 
@@ -151,7 +156,7 @@ module AuthProto
151
156
  return if client_assertion.nil?
152
157
 
153
158
  unless client_assertion.is_a?(ClientAssertion)
154
- raise Error, "client_assertion must be a PAR::ClientAssertion"
159
+ raise Error, "client_assertion must be a ClientAssertion"
155
160
  end
156
161
  end
157
162
  end
data/lib/authproto/par.rb CHANGED
@@ -41,9 +41,5 @@ module AuthProto
41
41
 
42
42
  # Error raised for PAR-related issues
43
43
  class Error < AuthProto::Error; end
44
-
45
- # OAuth JWT bearer client assertion type URN.
46
- # @return [String]
47
- CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
48
44
  end
49
45
  end
@@ -47,11 +47,13 @@ module AuthProto
47
47
  end
48
48
 
49
49
  FileUtils.mkdir_p(File.dirname(path))
50
+ @path = File.expand_path(path)
51
+ @busy_timeout = busy_timeout
52
+ @connection_mutex = Mutex.new
50
53
 
51
- @database = SQLite3::Database.new(path)
52
- @database.busy_timeout = busy_timeout
54
+ @database = open_database
55
+ @database_pid = Process.pid
53
56
 
54
- configure_database
55
57
  create_schema
56
58
  rescue SQLite3::Exception => e
57
59
  raise SQLiteError, "Failed to initialize database: #{e.message}"
@@ -73,7 +75,7 @@ module AuthProto
73
75
 
74
76
  expires_at = ttl && (current_time + ttl)
75
77
 
76
- @database.execute(
78
+ database.execute(
77
79
  <<~SQL,
78
80
  INSERT INTO atproto_storage (key, value, expires_at)
79
81
  VALUES (?, ?, ?)
@@ -98,7 +100,7 @@ module AuthProto
98
100
  validate_key(key)
99
101
 
100
102
  now = current_time
101
- row = @database.get_first_row(
103
+ row = database.get_first_row(
102
104
  <<~SQL,
103
105
  SELECT value
104
106
  FROM atproto_storage
@@ -127,7 +129,7 @@ module AuthProto
127
129
  def delete(key)
128
130
  validate_key(key)
129
131
 
130
- result = @database.get_first_value(
132
+ result = database.get_first_value(
131
133
  "DELETE FROM atproto_storage WHERE key = ? RETURNING 1",
132
134
  [key]
133
135
  )
@@ -149,7 +151,7 @@ module AuthProto
149
151
 
150
152
  now = current_time
151
153
 
152
- exists = @database.get_first_value(
154
+ exists = database.get_first_value(
153
155
  <<~SQL,
154
156
  SELECT 1
155
157
  FROM atproto_storage
@@ -206,8 +208,8 @@ module AuthProto
206
208
  def cleanup_expired_records
207
209
  now = current_time
208
210
 
209
- @database.execute("DELETE FROM atproto_storage WHERE expires_at <= ?", [now])
210
- @database.execute("DELETE FROM atproto_locks WHERE expires_at <= ?", [now])
211
+ database.execute("DELETE FROM atproto_storage WHERE expires_at <= ?", [now])
212
+ database.execute("DELETE FROM atproto_locks WHERE expires_at <= ?", [now])
211
213
  rescue SQLite3::Exception => e
212
214
  raise SQLiteError, "Failed to clean up expired records: #{e.message}"
213
215
  end
@@ -218,16 +220,51 @@ module AuthProto
218
220
  # @raise [SQLiteError] if closing the database fails
219
221
  #
220
222
  def close
221
- @database.close
223
+ @connection_mutex.synchronize do
224
+ @database.close unless @database.nil? || @database.closed?
225
+ end
222
226
  rescue SQLite3::Exception => e
223
227
  raise SQLiteError, "Failed to close database: #{e.message}"
224
228
  end
225
229
 
230
+
226
231
  private
227
232
 
228
- def configure_database
229
- @database.execute("PRAGMA journal_mode = WAL")
230
- @database.execute("PRAGMA synchronous = FULL")
233
+ def database
234
+ @connection_mutex.synchronize do
235
+ if @database_pid != Process.pid || @database.closed?
236
+
237
+ # We're in a different process - this happens after a fork(), if the parent process has opened a connection
238
+ # before the fork was made. This can happen in web servers like Passenger or Puma that use forking to
239
+ # create worker processes.
240
+ #
241
+ # In this case, we discard the existing connection (which sqlite gem has already closed for us for safety)
242
+ # and open a new one.
243
+ #
244
+ # Do NOT close the inherited connection here, this is also potentially unsafe.
245
+
246
+ @database = open_database
247
+ @database_pid = Process.pid
248
+ end
249
+
250
+ @database
251
+ end
252
+ end
253
+
254
+ def open_database
255
+ db = SQLite3::Database.new(@path)
256
+ db.busy_timeout = @busy_timeout
257
+ configure_database(db)
258
+
259
+ db
260
+ rescue StandardError
261
+ db.close if db && !db.closed?
262
+ raise
263
+ end
264
+
265
+ def configure_database(db)
266
+ db.execute("PRAGMA journal_mode = WAL")
267
+ db.execute("PRAGMA synchronous = FULL")
231
268
  end
232
269
 
233
270
  def create_schema
@@ -253,7 +290,7 @@ module AuthProto
253
290
  now = current_time
254
291
  owner = SecureRandom.uuid
255
292
 
256
- acquired_owner = @database.get_first_value(
293
+ acquired_owner = database.get_first_value(
257
294
  <<~SQL,
258
295
  INSERT INTO atproto_locks (key, owner, expires_at)
259
296
  VALUES (?, ?, ?)
@@ -270,7 +307,7 @@ module AuthProto
270
307
  end
271
308
 
272
309
  def release_lock(key, owner)
273
- result = @database.get_first_value(
310
+ result = database.get_first_value(
274
311
  "DELETE FROM atproto_locks WHERE key = ? AND owner = ? RETURNING 1",
275
312
  [key, owner]
276
313
  )
@@ -281,7 +318,7 @@ module AuthProto
281
318
  end
282
319
 
283
320
  def delete_expired_value(key, now)
284
- @database.execute(
321
+ database.execute(
285
322
  "DELETE FROM atproto_storage WHERE key = ? AND expires_at <= ?",
286
323
  [key, now]
287
324
  )
@@ -4,12 +4,11 @@ require 'jose'
4
4
  require 'json'
5
5
  require 'monitor'
6
6
 
7
+ require_relative '../client_assertion'
7
8
  require_relative '../configuration'
8
9
  require_relative '../errors'
9
10
  require_relative '../http_client'
10
11
  require_relative '../http_helpers'
11
- require_relative '../par'
12
- require_relative '../par/client_assertion'
13
12
  require_relative '../state/token_set'
14
13
  require_relative 'identity'
15
14
  require_relative 'response'
@@ -158,7 +157,7 @@ module AuthProto
158
157
  # @param dpop_client [DPoP::Client] proof signer and nonce tracker
159
158
  # @param auth_server [Metadata::AuthorizationServer] server with a token endpoint
160
159
  # @param client_metadata [Metadata::ClientMetadata] client ID and authentication key configuration
161
- # @param client_assertion [PAR::ClientAssertion, nil] reusable validated signer; required for confidential clients
160
+ # @param client_assertion [ClientAssertion, nil] reusable validated signer; required for confidential clients
162
161
  # @raise [ArgumentError] if confidential-client metadata is supplied without an assertion signer
163
162
  #
164
163
  def initialize(session:, dpop_client:, auth_server:, client_metadata:, client_assertion: nil)
@@ -171,7 +170,7 @@ module AuthProto
171
170
  @client_metadata = client_metadata
172
171
  @client_assertion = client_assertion
173
172
 
174
- if client_metadata.confidential? && !client_assertion.is_a?(PAR::ClientAssertion)
173
+ if client_metadata.confidential? && !client_assertion.is_a?(ClientAssertion)
175
174
  raise ArgumentError, "Confidential clients require a client_assertion signer"
176
175
  end
177
176
  end
@@ -291,7 +290,7 @@ module AuthProto
291
290
 
292
291
  def add_client_authentication(body)
293
292
  body.merge!(
294
- client_assertion_type: PAR::CLIENT_ASSERTION_TYPE,
293
+ client_assertion_type: ClientAssertion::TYPE,
295
294
  client_assertion: @client_assertion.generate_jwt(audience: auth_server.issuer)
296
295
  )
297
296
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../client_assertion'
3
4
  require_relative '../configuration'
4
5
  require_relative '../errors'
5
6
  require_relative '../http_helpers'
6
- require_relative '../par'
7
7
 
8
8
  module AuthProto
9
9
  module Token
@@ -23,7 +23,7 @@ module AuthProto
23
23
  # @param session [State::Session] session bound to the issuing authorization server
24
24
  # @param dpop_client [DPoP::Client] proof signer and nonce tracker
25
25
  # @param client_metadata [Metadata::ClientMetadata] client authentication configuration
26
- # @param client_assertion [PAR::ClientAssertion, nil] confidential-client assertion signer
26
+ # @param client_assertion [ClientAssertion, nil] confidential-client assertion signer
27
27
  #
28
28
  def initialize(session:, dpop_client:, client_metadata:, client_assertion: nil)
29
29
  @session = session
@@ -73,7 +73,7 @@ module AuthProto
73
73
 
74
74
  if @client_metadata.confidential?
75
75
  body.merge!(
76
- client_assertion_type: PAR::CLIENT_ASSERTION_TYPE,
76
+ client_assertion_type: ClientAssertion::TYPE,
77
77
  client_assertion: @client_assertion.generate_jwt(audience: @session.auth_server.issuer)
78
78
  )
79
79
  end
@@ -4,5 +4,5 @@ module AuthProto
4
4
 
5
5
  # Current gem version.
6
6
  # @return [String]
7
- VERSION = "0.3.0.beta5"
7
+ VERSION = "0.3.0.beta6"
8
8
  end
@@ -30,7 +30,7 @@ module AuthProto
30
30
  ?signing_key: (json_object | JOSE::JWK)?
31
31
  ) -> void
32
32
  def http: () -> _HTTPClient?
33
- def authorize: (?handle: String?, ?pds: (String | URI::HTTPS)?, ?scope: String) -> authorization_result
33
+ def authorize: (?handle: String?, ?pds: (String | URI::HTTPS)?, ?scope: String, ?prompt: String?) -> authorization_result
34
34
  def handle_callback: (
35
35
  Hash[String | Symbol, untyped] callback_params, expected_session_id: String
36
36
  ) -> State::SessionInfo
@@ -54,7 +54,8 @@ module AuthProto
54
54
  def submit_authorization_par: (
55
55
  Metadata::AuthorizationServer authorization_server,
56
56
  State::Session session,
57
- ?login_hint: String?
57
+ ?login_hint: String?,
58
+ ?prompt: String?
58
59
  ) -> String
59
60
  def validate_callback_params: (Hash[String | Symbol, untyped] callback_params) -> Hash[String, untyped]
60
61
  def exchange_code: (code: String, session: State::Session) -> State::TokenSet
@@ -0,0 +1,14 @@
1
+ module AuthProto
2
+ class ClientAssertion
3
+ class Error < AuthProto::Error
4
+ end
5
+ ALGORITHM: String
6
+ TYPE: String
7
+ attr_reader signing_key: JOSE::JWK
8
+ def initialize: (client_id: String, signing_key: (json_object | JOSE::JWK)) -> void
9
+ def generate_jwt: (audience: String, ?lifetime: Integer) -> String
10
+
11
+ private
12
+ def validate_signing_key: ((json_object | JOSE::JWK) signing_key) -> JOSE::JWK
13
+ end
14
+ end
@@ -12,6 +12,7 @@ module AuthProto
12
12
  @token_endpoint_auth_methods_supported: Array[String]
13
13
  @token_endpoint_auth_signing_alg_values_supported: Array[String]
14
14
  @scopes_supported: Array[String]
15
+ @prompt_values_supported: Array[String]?
15
16
  @dpop_signing_alg_values_supported: Array[String]
16
17
 
17
18
  REQUIRED_FIELDS: ::Array["issuer" | "authorization_endpoint" | "token_endpoint" | "response_types_supported" | "grant_types_supported" | "code_challenge_methods_supported" | "token_endpoint_auth_methods_supported" | "token_endpoint_auth_signing_alg_values_supported" | "scopes_supported" | "dpop_signing_alg_values_supported" | "pushed_authorization_request_endpoint"]
@@ -26,6 +27,7 @@ module AuthProto
26
27
  attr_reader token_endpoint_auth_methods_supported: Array[String]
27
28
  attr_reader token_endpoint_auth_signing_alg_values_supported: Array[String]
28
29
  attr_reader scopes_supported: Array[String]
30
+ attr_reader prompt_values_supported: Array[String]?
29
31
  attr_reader dpop_signing_alg_values_supported: Array[String]
30
32
 
31
33
  def initialize: (Hash[String, untyped] metadata) -> void
@@ -24,7 +24,9 @@ class OAuth
24
24
  ?oauth_client: AuthProto::Client?
25
25
  ) -> void
26
26
  def config: () -> nil
27
- def authorize: (?handle: String?, ?pds: (String | URI::HTTPS)?, ?scope: String) -> AuthProto::authorization_result
27
+ def authorize: (
28
+ ?handle: String?, ?pds: (String | URI::HTTPS)?, ?scope: String, ?prompt: String?
29
+ ) -> AuthProto::authorization_result
28
30
  def handle_callback: (
29
31
  Hash[String | Symbol, untyped] callback_params, expected_session_id: String
30
32
  ) -> AuthProto::State::SessionInfo
@@ -7,6 +7,7 @@ module AuthProto
7
7
  @state: String
8
8
  @scope: String
9
9
  @login_hint: String?
10
+ @prompt: String?
10
11
  @nonce: String?
11
12
  @client_assertion: ClientAssertion?
12
13
 
@@ -17,6 +18,7 @@ module AuthProto
17
18
  attr_accessor state: String?
18
19
  attr_accessor scope: String?
19
20
  attr_accessor login_hint: String?
21
+ attr_accessor prompt: String?
20
22
  attr_accessor nonce: String?
21
23
  attr_accessor client_assertion: ClientAssertion?
22
24
  end
@@ -27,6 +29,7 @@ module AuthProto
27
29
  attr_reader redirect_uri: String
28
30
  attr_reader scope: String
29
31
  attr_reader login_hint: String?
32
+ attr_reader prompt: String?
30
33
  attr_reader nonce: String?
31
34
  attr_reader client_assertion: ClientAssertion?
32
35
 
@@ -1,6 +1,5 @@
1
1
  module AuthProto
2
2
  module PAR
3
- CLIENT_ASSERTION_TYPE: String
4
3
  class Error < AuthProto::Error
5
4
  end
6
5
  end
@@ -27,7 +27,7 @@ module AuthProto
27
27
  attr_reader auth_server: Metadata::AuthorizationServer
28
28
  attr_reader client_metadata: Metadata::ClientMetadata
29
29
 
30
- def initialize: (session: State::Session, dpop_client: DPoP::Client, auth_server: Metadata::AuthorizationServer, client_metadata: Metadata::ClientMetadata, ?client_assertion: PAR::ClientAssertion?) -> void
30
+ def initialize: (session: State::Session, dpop_client: DPoP::Client, auth_server: Metadata::AuthorizationServer, client_metadata: Metadata::ClientMetadata, ?client_assertion: ClientAssertion?) -> void
31
31
  def perform_refresh: () -> State::TokenSet
32
32
 
33
33
  private
@@ -5,7 +5,7 @@ module AuthProto
5
5
  class Error < AuthProto::Error
6
6
  end
7
7
 
8
- def initialize: (session: State::Session, dpop_client: DPoP::Client, client_metadata: Metadata::ClientMetadata, ?client_assertion: PAR::ClientAssertion?) -> void
8
+ def initialize: (session: State::Session, dpop_client: DPoP::Client, client_metadata: Metadata::ClientMetadata, ?client_assertion: ClientAssertion?) -> void
9
9
  def revoke_token: (String token, token_type: String | Symbol) -> void
10
10
 
11
11
  private