Skip to content

Commit a2bca65

Browse files
committed
omniauth: implement request phase stub
1 parent 6d94d42 commit a2bca65

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/omniauth-ethereum.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@ module OmniAuth
44
module Strategies
55
class Ethereum
66
include OmniAuth::Strategy
7+
8+
# ethereum authentication strategy fields
9+
# `eth_message`: contains a custom string, the request time, and the specific nonce to sign
10+
# `eth_address`: contains the public Eth::Address of the user's Ethereum account
11+
# `eth_signature`: contains the signature of the `eth_message` signed by `eth_address`
12+
option :fields, [:eth_message, :eth_address, :eth_signature]
13+
14+
# the `eth_address` will be the _fake_ unique identifier for the Ethereum strategy
15+
option :uid_field, :eth_address
16+
17+
# the omniauth request phase
18+
def request_phase
19+
20+
# helper omniauth form to gather required data
21+
form = OmniAuth::Form.new :title => "Ethereum Authentication", :url => callback_path
22+
options.fields.each do |field|
23+
24+
# these fields are read-only and will be filled by javascript in the process
25+
form.text_field field.to_s.capitalize.gsub("_", " "), field.to_s, readonly: true, class: field.to_s
26+
end
27+
28+
# the form button will be heavy on javascript, requesting account, nonce, and signature before submission
29+
form.button "Sign-In with Ethereum", class: "eth_connect"
30+
form.to_response
31+
end
732
end
833
end
934
end

0 commit comments

Comments
 (0)