authproto 0.3.0.beta2 → 0.3.0.beta4

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +108 -5
  4. data/examples/confidential_client/Gemfile.lock +1 -1
  5. data/examples/confidential_client/README.md +11 -1
  6. data/examples/confidential_client/app.rb +35 -17
  7. data/examples/confidential_client/scripts/generate_keys.rb +1 -1
  8. data/examples/minisky_console/Gemfile.lock +2 -2
  9. data/examples/minisky_console/README.md +20 -1
  10. data/examples/minisky_console/localhost.rb +5 -3
  11. data/examples/minisky_console/production.rb +9 -3
  12. data/lib/authproto/client.rb +173 -123
  13. data/lib/authproto/configuration.rb +37 -16
  14. data/lib/authproto/dpop/client.rb +105 -40
  15. data/lib/authproto/dpop/{key_manager.rb → key_set.rb} +54 -120
  16. data/lib/authproto/dpop/nonce_manager.rb +38 -29
  17. data/lib/authproto/dpop/proof_generator.rb +21 -35
  18. data/lib/authproto/dpop.rb +19 -0
  19. data/lib/authproto/encryption.rb +29 -12
  20. data/lib/authproto/http_client.rb +8 -7
  21. data/lib/authproto/http_helpers.rb +85 -0
  22. data/lib/authproto/metadata/authorization_server.rb +23 -6
  23. data/lib/authproto/metadata/client_metadata.rb +46 -6
  24. data/lib/authproto/metadata/resource_server.rb +7 -5
  25. data/lib/authproto/minisky.rb +36 -34
  26. data/lib/authproto/par/client.rb +22 -73
  27. data/lib/authproto/par/client_assertion.rb +47 -16
  28. data/lib/authproto/par/request.rb +4 -8
  29. data/lib/authproto/par.rb +2 -1
  30. data/lib/authproto/serialization/session.rb +33 -13
  31. data/lib/authproto/serialization/token_set.rb +6 -4
  32. data/lib/authproto/state/session.rb +102 -6
  33. data/lib/authproto/state/session_manager.rb +120 -22
  34. data/lib/authproto/state/token_set.rb +22 -19
  35. data/lib/authproto/state.rb +2 -2
  36. data/lib/authproto/storage/key_builder.rb +3 -11
  37. data/lib/authproto/storage/memory.rb +8 -2
  38. data/lib/authproto/token/identity.rb +54 -0
  39. data/lib/authproto/token/refresh.rb +66 -109
  40. data/lib/authproto/token/response.rb +73 -0
  41. data/lib/authproto/token/revocation.rb +92 -0
  42. data/lib/authproto/validated_uri.rb +23 -0
  43. data/lib/authproto/version.rb +1 -1
  44. data/lib/authproto.rb +0 -1
  45. data/sig/authproto/client.rbs +10 -10
  46. data/sig/authproto/dependencies.rbs +2 -0
  47. data/sig/authproto/dpop/client.rbs +11 -4
  48. data/sig/authproto/dpop/{key_manager.rbs → key_set.rbs} +9 -11
  49. data/sig/authproto/dpop/nonce_manager.rbs +4 -4
  50. data/sig/authproto/dpop/proof_generator.rbs +5 -10
  51. data/sig/authproto/dpop.rbs +6 -0
  52. data/sig/authproto/encryption.rbs +4 -2
  53. data/sig/authproto/http_client.rbs +0 -1
  54. data/sig/authproto/http_helpers.rbs +7 -0
  55. data/sig/authproto/localhost_server.rbs +1 -1
  56. data/sig/authproto/metadata/authorization_server.rbs +1 -0
  57. data/sig/authproto/metadata/client_metadata.rbs +3 -1
  58. data/sig/authproto/metadata/resource_server.rbs +1 -0
  59. data/sig/authproto/minisky_oauth.rbs +5 -2
  60. data/sig/authproto/par/client.rbs +4 -8
  61. data/sig/authproto/par/client_assertion.rbs +4 -0
  62. data/sig/authproto/par/request.rbs +0 -9
  63. data/sig/authproto/state/session.rbs +13 -3
  64. data/sig/authproto/state/session_manager.rbs +10 -3
  65. data/sig/authproto/state/token_set.rbs +1 -2
  66. data/sig/authproto/storage/key_builder.rbs +1 -2
  67. data/sig/authproto/token/refresh.rbs +5 -5
  68. data/sig/authproto/token/response.rbs +12 -0
  69. data/sig/authproto/token/revocation.rbs +14 -0
  70. data/sig/authproto.rbs +6 -3
  71. metadata +30 -23
  72. data/.rspec +0 -1
  73. data/.rubocop.yml +0 -31
  74. data/.tm_properties +0 -1
  75. data/.yardopts +0 -5
  76. data/AGENTS.md +0 -80
  77. data/Rakefile +0 -8
  78. data/examples/confidential_client/.gitignore +0 -6
  79. data/examples/minisky_console/.gitignore +0 -2
  80. data/lib/authproto/serialization/dpop_key.rb +0 -38
  81. data/misc/yard_attributes.rb +0 -34
  82. data/sig/authproto/serialization/dpop_key.rbs +0 -14
data/AGENTS.md DELETED
@@ -1,80 +0,0 @@
1
- ### Ruby code:
2
-
3
- - always add `# frozen_string_literal: true` at the beginning of Ruby files (both library and tests)
4
- - keep `require`s and `require_relative`s organized in separate blocks, ordered alphabetically in each:
5
-
6
- ```
7
- require 'ipaddr'
8
- require 'socket'
9
- require 'timeout'
10
- require 'uri'
11
-
12
- require_relative 'client_metadata'
13
- require_relative 'validated_uri'
14
- ```
15
-
16
- - wrap lines longer than 120 characters
17
- - for multi-line `if ... end` / `unless ... end` blocks, keep one empty line above/below separating them from the rest of the code in the method, unless it's at the beginning/end of the method, e.g.:
18
-
19
- ```
20
- def validate_grant_types(grant_types)
21
- unless grant_types.include?('authorization_code')
22
- raise InvalidClientMetadata, "grant_types must include authorization_code"
23
- end
24
-
25
- valid_types = %w[authorization_code refresh_token]
26
- ```
27
-
28
- - prefer single-quote strings for strings containing identifiers without spaces, like `'code'`, `'access_token'`, and for `require`s
29
- - prefer double-quote strings for strings containing messages with spaces meant to be shown to the user, e.g. `puts "grant_types must include authorization_code"`
30
-
31
- ### Unit tests:
32
-
33
- - use the classic RSpec `foo.should be_...` matcher style instead of `expect()`
34
- - except for calling matchers on blocks as in `expect { ... }.to(not) raise_error...`
35
- - use the classic `it "should do this"` naming for test cases instead of `it "does this"`
36
- - use raw `describe` instead of `RSpec.describe` at the top level
37
-
38
- ### Documentation:
39
-
40
- - use YARD with Markdown formatting
41
- - for class comments, keep one empty # line at the beginning and end, and one empty line above and below that, like:
42
-
43
- ```
44
-
45
- #
46
- # OAuth client implementation class.
47
- #
48
-
49
- class ...
50
- ```
51
-
52
- - for method comments, leave one empty line above, no empty # starting line, and one empty # trailing line that is immediately followed by the method definition, like:
53
-
54
- ```
55
-
56
- # Reads tokens for a session with a currently valid access token.
57
- #
58
- # @param session_id [String] session identifier
59
- # @return [Hash{Symbol => String, Integer, nil}, nil] token details, or `nil` for missing/unauthorized sessions
60
- #
61
- def get_tokens(session_id)
62
- ```
63
-
64
- - for properties, and also for one-liner classes like error types, use a compact style like:
65
-
66
- ```
67
-
68
- # Identifier of the session associated with the failure, if known.
69
- # @return [String, nil]
70
- attr_reader :session_id
71
-
72
- # Error raised when token operations fail
73
- class TokenError < Error; end
74
-
75
- ```
76
-
77
-
78
- ### Running code:
79
-
80
- - make sure you don't use the ancient system Ruby 2.6, but a version supported by the library (my installation uses `asdf`)
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: %i[spec]
@@ -1,6 +0,0 @@
1
- .env
2
- /config/client-metadata.json
3
- /config/oauth-client-metadata.json
4
- /config/keys.json
5
- /config/public-keys.json
6
- /db/
@@ -1,2 +0,0 @@
1
- .env
2
- db
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../dpop/key_manager'
4
- require_relative 'base'
5
-
6
- module AuthProto
7
- module Serialization
8
-
9
- #
10
- # Handles serialization of DPoP keys
11
- #
12
-
13
- class DPoPKey < Base
14
-
15
- # Returns the envelope type used by this serializer.
16
- # @return [String] `DPoPKey`
17
- def type_identifier
18
- "DPoPKey"
19
- end
20
-
21
- private
22
-
23
- def validate_object(obj)
24
- return if obj.is_a?(AuthProto::DPoP::KeyManager)
25
-
26
- raise ValidationError, "Expected KeyManager object, got #{obj.class}"
27
- end
28
-
29
- def serialize_data(obj)
30
- obj.to_jwk(include_private: true).to_h
31
- end
32
-
33
- def deserialize_data(data)
34
- AuthProto::DPoP::KeyManager.from_jwk(data)
35
- end
36
- end
37
- end
38
- end
@@ -1,34 +0,0 @@
1
- require 'yard'
2
-
3
- YARD::Parser::SourceParser.after_parse_list do
4
- fields = YARD::Registry.at('AuthProto::PAR::Request::Fields').attributes[:instance]
5
-
6
- {
7
- 'AuthProto::PAR::Request' => false,
8
- 'AuthProto::PAR::Request::Configuration' => true
9
- }.each do |path, writable|
10
- target = YARD::Registry.at(path)
11
-
12
- fields.each do |name, attribute|
13
- original = attribute[:read]
14
-
15
- reader = YARD::CodeObjects::MethodObject.new(target, name, :instance)
16
- reader.docstring = original.docstring.to_raw
17
- reader.signature = "def #{name}"
18
-
19
- target.attributes[:instance][name] = { read: reader, write: nil }
20
-
21
- next unless writable
22
-
23
- return_tag = reader.tag(:return)
24
- return_tag.types = (return_tag.types + ['nil']).uniq
25
-
26
- writer = YARD::CodeObjects::MethodObject.new(target, "#{name}=", :instance)
27
- writer.docstring = original.docstring.to_raw
28
- writer.parameters = [['value', nil]]
29
- writer.signature = "def #{name}=(value)"
30
-
31
- target.attributes[:instance][name][:write] = writer
32
- end
33
- end
34
- end
@@ -1,14 +0,0 @@
1
- module AuthProto
2
- module Serialization
3
- class DPoPKey < Base[DPoP::KeyManager]
4
- def self.serialize: (DPoP::KeyManager obj) -> String
5
- def self.deserialize: (String data) -> DPoP::KeyManager
6
- def type_identifier: () -> String
7
-
8
- private
9
- def validate_object: (DPoP::KeyManager obj) -> void
10
- def serialize_data: (DPoP::KeyManager obj) -> json_object
11
- def deserialize_data: (json_object data) -> DPoP::KeyManager
12
- end
13
- end
14
- end