omniauth-atproto 0.1.2 → 0.1.4
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/LICENSE +21 -0
- data/README.md +1 -1
- data/lib/omniauth/strategies/atproto.rb +9 -51
- data/lib/omniauth-atproto/version.rb +1 -1
- metadata +10 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f160f72bb32ee424debc508de26eb57909a0099dd843514c4787f925ab49339
|
|
4
|
+
data.tar.gz: e17bf34036b05597a16b25aec8003fce7422fe511ae3c82074144b5546f8cc16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c88cd60ddba8dcb55801fc80ef932ccdfea21fdcb6bc4f9e646f6bf5cd1185608bd497a6ce9a55547c3a03fd7920191c482a89a795b0ba3b5ef0fbb813ebbd64
|
|
7
|
+
data.tar.gz: ff8baae3478d2ad51e8291252a0d08a5552631ff692416ffc40b26fa0d65e4b2bc73b8861aa8fc2d0e89094076b5eb24ce56a38538ab7d69dd06a386f18aac64
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 François Brault
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -78,7 +78,7 @@ rails atproto:generate_metadata
|
|
|
78
78
|
```
|
|
79
79
|
The values from the metadata endpoint should correspond to those you gave as option for the strategy (that's why a generator would be very handy).
|
|
80
80
|
|
|
81
|
-
All subsequent request made with the token should use the same private_key (with dpop,
|
|
81
|
+
All subsequent request made with the token should use the same private_key (with dpop), you might want to use https://github.com/lasercatspro/atproto-ruby.
|
|
82
82
|
|
|
83
83
|
The pds is going to request your app at oauth/client-metadata.json. For developement you will have to use some kind of proxy, like ngrok (there is a "development mode" in the spec but I didnt try it)
|
|
84
84
|
|
|
@@ -52,61 +52,19 @@ module OmniAuth
|
|
|
52
52
|
private
|
|
53
53
|
|
|
54
54
|
def build_access_token
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
response = AtProto::Client.new(private_key: options.private_key).get_token!(
|
|
56
|
+
**token_params.merge({
|
|
57
|
+
code: request.params['code'],
|
|
58
|
+
jwk: options.client_jwk,
|
|
59
|
+
client_id: options.client_id,
|
|
60
|
+
redirect_uri: full_host + callback_path,
|
|
61
|
+
site: options.client_options.site,
|
|
62
|
+
endpoint: options.client_options.token_url
|
|
63
|
+
}).to_h.symbolize_keys
|
|
64
64
|
)
|
|
65
|
-
dpop_handler = AtProto::DpopHandler.new(options.private_key)
|
|
66
|
-
response = dpop_handler.make_request(
|
|
67
|
-
client.token_url,
|
|
68
|
-
:post,
|
|
69
|
-
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' },
|
|
70
|
-
body: new_token_params
|
|
71
|
-
)
|
|
72
|
-
|
|
73
65
|
::OAuth2::AccessToken.from_hash(client, response)
|
|
74
66
|
end
|
|
75
67
|
|
|
76
|
-
def generate_client_assertion
|
|
77
|
-
# Should return a JWT signed with the private key corresponding to the one in client-metadata.json
|
|
78
|
-
|
|
79
|
-
raise 'Client ID is required' unless options.client_id
|
|
80
|
-
raise 'Client JWK is required' unless options.client_jwk
|
|
81
|
-
|
|
82
|
-
private_key = if options.private_key.is_a?(String)
|
|
83
|
-
OpenSSL::PKey::EC.new(options.private_key)
|
|
84
|
-
elsif options.private_key.is_a?(OpenSSL::PKey::EC)
|
|
85
|
-
options.private_key
|
|
86
|
-
else
|
|
87
|
-
raise 'Invalid private_key format'
|
|
88
|
-
end
|
|
89
|
-
jwt_payload = {
|
|
90
|
-
iss: options.client_id,
|
|
91
|
-
sub: options.client_id,
|
|
92
|
-
aud: options.client_options.site,
|
|
93
|
-
jti: SecureRandom.uuid,
|
|
94
|
-
iat: Time.now.to_i,
|
|
95
|
-
exp: Time.now.to_i + 300
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
JWT.encode(
|
|
99
|
-
jwt_payload,
|
|
100
|
-
private_key,
|
|
101
|
-
'ES256',
|
|
102
|
-
{
|
|
103
|
-
typ: 'jwt',
|
|
104
|
-
alg: 'ES256',
|
|
105
|
-
kid: options.client_jwk[:kid]
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
68
|
def self.get_authorization_server(pds_endpoint)
|
|
111
69
|
response = Faraday.get("#{pds_endpoint}/.well-known/oauth-protected-resource")
|
|
112
70
|
|
metadata
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-atproto
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- frabr
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: atproto_client
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 0.1.4
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
25
|
+
version: 0.1.4
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: didkit
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -56,14 +55,14 @@ dependencies:
|
|
|
56
55
|
name: jwt
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
|
-
- - "
|
|
58
|
+
- - ">="
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
60
|
version: '2.7'
|
|
62
61
|
type: :runtime
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- - "
|
|
65
|
+
- - ">="
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
67
|
version: '2.7'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
@@ -129,6 +128,7 @@ executables: []
|
|
|
129
128
|
extensions: []
|
|
130
129
|
extra_rdoc_files: []
|
|
131
130
|
files:
|
|
131
|
+
- LICENSE
|
|
132
132
|
- README.md
|
|
133
133
|
- lib/omniauth-atproto.rb
|
|
134
134
|
- lib/omniauth-atproto/key_manager.rb
|
|
@@ -142,7 +142,6 @@ metadata:
|
|
|
142
142
|
homepage_uri: https://github.com/lasercats/omniauth-atproto
|
|
143
143
|
source_code_uri: https://github.com/lasercats/omniauth-atproto
|
|
144
144
|
changelog_uri: https://github.com/lasercats/omniauth-atproto/blob/master/CHANGELOG.md
|
|
145
|
-
post_install_message:
|
|
146
145
|
rdoc_options: []
|
|
147
146
|
require_paths:
|
|
148
147
|
- lib
|
|
@@ -157,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
157
156
|
- !ruby/object:Gem::Version
|
|
158
157
|
version: '0'
|
|
159
158
|
requirements: []
|
|
160
|
-
rubygems_version: 3.
|
|
161
|
-
signing_key:
|
|
159
|
+
rubygems_version: 3.7.2
|
|
162
160
|
specification_version: 4
|
|
163
161
|
summary: OmniAuth strategy for AtProto
|
|
164
162
|
test_files: []
|