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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +108 -5
- data/examples/confidential_client/Gemfile.lock +1 -1
- data/examples/confidential_client/README.md +11 -1
- data/examples/confidential_client/app.rb +35 -17
- data/examples/confidential_client/scripts/generate_keys.rb +1 -1
- data/examples/minisky_console/Gemfile.lock +2 -2
- data/examples/minisky_console/README.md +20 -1
- data/examples/minisky_console/localhost.rb +5 -3
- data/examples/minisky_console/production.rb +9 -3
- data/lib/authproto/client.rb +173 -123
- data/lib/authproto/configuration.rb +37 -16
- data/lib/authproto/dpop/client.rb +105 -40
- data/lib/authproto/dpop/{key_manager.rb → key_set.rb} +54 -120
- data/lib/authproto/dpop/nonce_manager.rb +38 -29
- data/lib/authproto/dpop/proof_generator.rb +21 -35
- data/lib/authproto/dpop.rb +19 -0
- data/lib/authproto/encryption.rb +29 -12
- data/lib/authproto/http_client.rb +8 -7
- data/lib/authproto/http_helpers.rb +85 -0
- data/lib/authproto/metadata/authorization_server.rb +23 -6
- data/lib/authproto/metadata/client_metadata.rb +46 -6
- data/lib/authproto/metadata/resource_server.rb +7 -5
- data/lib/authproto/minisky.rb +36 -34
- data/lib/authproto/par/client.rb +22 -73
- data/lib/authproto/par/client_assertion.rb +47 -16
- data/lib/authproto/par/request.rb +4 -8
- data/lib/authproto/par.rb +2 -1
- data/lib/authproto/serialization/session.rb +33 -13
- data/lib/authproto/serialization/token_set.rb +6 -4
- data/lib/authproto/state/session.rb +102 -6
- data/lib/authproto/state/session_manager.rb +120 -22
- data/lib/authproto/state/token_set.rb +22 -19
- data/lib/authproto/state.rb +2 -2
- data/lib/authproto/storage/key_builder.rb +3 -11
- data/lib/authproto/storage/memory.rb +8 -2
- data/lib/authproto/token/identity.rb +54 -0
- data/lib/authproto/token/refresh.rb +66 -109
- data/lib/authproto/token/response.rb +73 -0
- data/lib/authproto/token/revocation.rb +92 -0
- data/lib/authproto/validated_uri.rb +23 -0
- data/lib/authproto/version.rb +1 -1
- data/lib/authproto.rb +0 -1
- data/sig/authproto/client.rbs +10 -10
- data/sig/authproto/dependencies.rbs +2 -0
- data/sig/authproto/dpop/client.rbs +11 -4
- data/sig/authproto/dpop/{key_manager.rbs → key_set.rbs} +9 -11
- data/sig/authproto/dpop/nonce_manager.rbs +4 -4
- data/sig/authproto/dpop/proof_generator.rbs +5 -10
- data/sig/authproto/dpop.rbs +6 -0
- data/sig/authproto/encryption.rbs +4 -2
- data/sig/authproto/http_client.rbs +0 -1
- data/sig/authproto/http_helpers.rbs +7 -0
- data/sig/authproto/localhost_server.rbs +1 -1
- data/sig/authproto/metadata/authorization_server.rbs +1 -0
- data/sig/authproto/metadata/client_metadata.rbs +3 -1
- data/sig/authproto/metadata/resource_server.rbs +1 -0
- data/sig/authproto/minisky_oauth.rbs +5 -2
- data/sig/authproto/par/client.rbs +4 -8
- data/sig/authproto/par/client_assertion.rbs +4 -0
- data/sig/authproto/par/request.rbs +0 -9
- data/sig/authproto/state/session.rbs +13 -3
- data/sig/authproto/state/session_manager.rbs +10 -3
- data/sig/authproto/state/token_set.rbs +1 -2
- data/sig/authproto/storage/key_builder.rbs +1 -2
- data/sig/authproto/token/refresh.rbs +5 -5
- data/sig/authproto/token/response.rbs +12 -0
- data/sig/authproto/token/revocation.rbs +14 -0
- data/sig/authproto.rbs +6 -3
- metadata +30 -23
- data/.rspec +0 -1
- data/.rubocop.yml +0 -31
- data/.tm_properties +0 -1
- data/.yardopts +0 -5
- data/AGENTS.md +0 -80
- data/Rakefile +0 -8
- data/examples/confidential_client/.gitignore +0 -6
- data/examples/minisky_console/.gitignore +0 -2
- data/lib/authproto/serialization/dpop_key.rb +0 -38
- data/misc/yard_attributes.rb +0 -34
- 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,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
|
data/misc/yard_attributes.rb
DELETED
|
@@ -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
|