File tree Expand file tree Collapse file tree 4 files changed +48
-40
lines changed Expand file tree Collapse file tree 4 files changed +48
-40
lines changed Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- omniauth-ethereum (0.1 .0 )
5- eth (~> 0.4.16 )
6- omniauth (~> 2.0 )
4+ omniauth-ethereum (0.2 .0 )
5+ eth (~> 0.5 )
6+ omniauth (~> 2.1 )
77
88GEM
99 remote: https://rubygems.org/
1010 specs:
11- diff-lcs (1.4.4 )
12- eth (0.4.16 )
13- ffi (~> 1.15 )
14- keccak (~> 1.2 )
15- money-tree (~> 0.10 )
16- rlp (~> 0.7 )
11+ diff-lcs (1.5.0 )
12+ eth (0.5.2 )
13+ keccak (~> 1.3 )
14+ konstructor (~> 1.0 )
15+ openssl (~> 2.2 )
16+ rbsecp256k1 (~> 5.1 )
1717 scrypt (~> 3.0 )
18- ffi (1.15.4 )
18+ ffi (1.15.5 )
1919 ffi-compiler (1.0.1 )
2020 ffi (>= 1.0.0 )
2121 rake
2222 hashie (5.0.0 )
23- keccak (1.2.2 )
24- money-tree (0.10.0 )
25- ffi
26- omniauth (2.0.4 )
23+ ipaddr (1.2.4 )
24+ keccak (1.3.0 )
25+ konstructor (1.0.2 )
26+ mini_portile2 (2.8.0 )
27+ omniauth (2.1.0 )
2728 hashie (>= 3.4.6 )
28- rack (>= 1.6.2 , < 3 )
29+ rack (>= 2.2. 3 )
2930 rack-protection
31+ openssl (2.2.1 )
32+ ipaddr
33+ pkg-config (1.4.7 )
3034 rack (2.2.3 )
31- rack-protection (2.1 .0 )
35+ rack-protection (2.2 .0 )
3236 rack
3337 rack-test (1.1.0 )
3438 rack (>= 1.0 , < 3 )
3539 rake (13.0.6 )
36- rlp (0.7.3 )
37- rspec (3.10.0 )
38- rspec-core (~> 3.10.0 )
39- rspec-expectations (~> 3.10.0 )
40- rspec-mocks (~> 3.10.0 )
41- rspec-core (3.10.1 )
42- rspec-support (~> 3.10.0 )
43- rspec-expectations (3.10.1 )
40+ rbsecp256k1 (5.1.0 )
41+ mini_portile2 (~> 2.7 )
42+ pkg-config (~> 1.4 )
43+ rubyzip (~> 2.3 )
44+ rspec (3.11.0 )
45+ rspec-core (~> 3.11.0 )
46+ rspec-expectations (~> 3.11.0 )
47+ rspec-mocks (~> 3.11.0 )
48+ rspec-core (3.11.0 )
49+ rspec-support (~> 3.11.0 )
50+ rspec-expectations (3.11.0 )
4451 diff-lcs (>= 1.2.0 , < 2.0 )
45- rspec-support (~> 3.10 .0 )
46- rspec-mocks (3.10.2 )
52+ rspec-support (~> 3.11 .0 )
53+ rspec-mocks (3.11.1 )
4754 diff-lcs (>= 1.2.0 , < 2.0 )
48- rspec-support (~> 3.10.0 )
49- rspec-support (3.10.3 )
55+ rspec-support (~> 3.11.0 )
56+ rspec-support (3.11.0 )
57+ rubyzip (2.3.2 )
5058 scrypt (3.0.7 )
5159 ffi-compiler (>= 1.0 , < 2.0 )
5260
@@ -56,7 +64,7 @@ PLATFORMS
5664DEPENDENCIES
5765 omniauth-ethereum !
5866 rack-test (~> 1.1 )
59- rspec (~> 3.10 )
67+ rspec (~> 3.11 )
6068
6169BUNDLED WITH
6270 2.2.28
Original file line number Diff line number Diff line change @@ -42,17 +42,17 @@ def request_phase
4242 end
4343
4444 def callback_phase
45- address = request . params [ 'eth_address' ] . downcase
46- message = request . params [ 'eth_message' ]
47- signature = request . params [ 'eth_signature' ]
48- signature_pubkey = Eth ::Key . personal_recover message , signature
49- signature_address = ( Eth ::Utils . public_key_to_address signature_pubkey ) . downcase
5045
46+ message = request . params [ 'eth_message' ]
5147 unix_time = message . scan ( /\d +/ ) . first . to_i
5248 ten_min = 10 * 60
5349 return fail! ( :invalid_time ) unless unix_time + ten_min >= now && unix_time - ten_min <= now
5450
55- return fail! ( :invalid_credentials ) unless signature_address == address
51+ address = Eth ::Address . new request . params [ 'eth_address' ]
52+ signature = request . params [ 'eth_signature' ]
53+ signature_pubkey = Eth ::Signature . personal_recover message , signature
54+ signature_address = Eth ::Util . public_key_to_address ( signature_pubkey )
55+ return fail! ( :invalid_credentials ) unless signature_address . to_s == address . to_s
5656
5757 super
5858 end
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
33
44Gem ::Specification . new do |spec |
55 spec . name = 'omniauth-ethereum'
6- spec . version = '0.1 .0'
6+ spec . version = '0.2 .0'
77 spec . summary = "OmniAuth Strategy for Ethereum"
88 spec . description = "Authentication Strategy for OmniAuth to authenticate a user with an Ethereum account"
99 spec . authors = [ "Afri Schoedon" ]
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
2525 spec . required_ruby_version = ">= 2.7" , "< 4.0"
2626
2727 # OmniAuth is what this strategy is providing
28- spec . add_dependency 'omniauth' , '~> 2.0 '
28+ spec . add_dependency 'omniauth' , '~> 2.1 '
2929
3030 # Use Ruby-Eth for signature recovery
31- spec . add_dependency 'eth' , '~> 0.4.16 '
31+ spec . add_dependency 'eth' , '~> 0.5 '
3232
3333 # Spec tests
34- spec . add_development_dependency 'rspec' , '~> 3.10 '
34+ spec . add_development_dependency 'rspec' , '~> 3.11 '
3535 spec . add_development_dependency 'rack-test' , '~> 1.1'
3636end
Original file line number Diff line number Diff line change 7474
7575 it 'fails with invalid credentials' do
7676 expect ( last_response . status ) . to eq ( 302 )
77- expect ( last_response . location ) . to eq ( '/auth/failure?message=invalid_credentials &strategy=ethereum' )
77+ expect ( last_response . location ) . to eq ( '/auth/failure?message=Invalid+signature+v+byte+0+for+chain+ID+1%21 &strategy=ethereum' )
7878 end
7979 end
8080
You can’t perform that action at this time.
0 commit comments