devise-web3 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2ba920bf0ddf9dab801ad64ade277225bc92772de4e68650840b88ef814968dc
4
+ data.tar.gz: 0fb54f1b5dac199956226250263d22e9ba823b3b447a7dbc78003740f2d58702
5
+ SHA512:
6
+ metadata.gz: 708031b17df449f109f7ca855e00e2027ee04e24900d28091247180d81db6a872c078d405a2109f79b98c8eb3476a65b70c2eeb30210ea1dac09c88c3afc7680
7
+ data.tar.gz: '0378ee4ad0d14c51858492550fbffc8a07d332a3b9fe87537fd0ec459cc1c46782789630204b4cbee6371cc5f685a77b2fb44ce15bf7f2e3efccd5bcb171bf8e'
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.6
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in devise-web3.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,320 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ devise-web3 (0.1.0)
5
+ devise (~> 4.0)
6
+ eth (~> 0.5.15)
7
+ redis
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (8.0.2.1)
13
+ actionpack (= 8.0.2.1)
14
+ activesupport (= 8.0.2.1)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ zeitwerk (~> 2.6)
18
+ actionmailbox (8.0.2.1)
19
+ actionpack (= 8.0.2.1)
20
+ activejob (= 8.0.2.1)
21
+ activerecord (= 8.0.2.1)
22
+ activestorage (= 8.0.2.1)
23
+ activesupport (= 8.0.2.1)
24
+ mail (>= 2.8.0)
25
+ actionmailer (8.0.2.1)
26
+ actionpack (= 8.0.2.1)
27
+ actionview (= 8.0.2.1)
28
+ activejob (= 8.0.2.1)
29
+ activesupport (= 8.0.2.1)
30
+ mail (>= 2.8.0)
31
+ rails-dom-testing (~> 2.2)
32
+ actionpack (8.0.2.1)
33
+ actionview (= 8.0.2.1)
34
+ activesupport (= 8.0.2.1)
35
+ nokogiri (>= 1.8.5)
36
+ rack (>= 2.2.4)
37
+ rack-session (>= 1.0.1)
38
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.2)
40
+ rails-html-sanitizer (~> 1.6)
41
+ useragent (~> 0.16)
42
+ actiontext (8.0.2.1)
43
+ actionpack (= 8.0.2.1)
44
+ activerecord (= 8.0.2.1)
45
+ activestorage (= 8.0.2.1)
46
+ activesupport (= 8.0.2.1)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (8.0.2.1)
50
+ activesupport (= 8.0.2.1)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.11)
53
+ rails-dom-testing (~> 2.2)
54
+ rails-html-sanitizer (~> 1.6)
55
+ activejob (8.0.2.1)
56
+ activesupport (= 8.0.2.1)
57
+ globalid (>= 0.3.6)
58
+ activemodel (8.0.2.1)
59
+ activesupport (= 8.0.2.1)
60
+ activerecord (8.0.2.1)
61
+ activemodel (= 8.0.2.1)
62
+ activesupport (= 8.0.2.1)
63
+ timeout (>= 0.4.0)
64
+ activestorage (8.0.2.1)
65
+ actionpack (= 8.0.2.1)
66
+ activejob (= 8.0.2.1)
67
+ activerecord (= 8.0.2.1)
68
+ activesupport (= 8.0.2.1)
69
+ marcel (~> 1.0)
70
+ activesupport (8.0.2.1)
71
+ base64
72
+ benchmark (>= 0.3)
73
+ bigdecimal
74
+ concurrent-ruby (~> 1.0, >= 1.3.1)
75
+ connection_pool (>= 2.2.5)
76
+ drb
77
+ i18n (>= 1.6, < 2)
78
+ logger (>= 1.4.2)
79
+ minitest (>= 5.1)
80
+ securerandom (>= 0.3)
81
+ tzinfo (~> 2.0, >= 2.0.5)
82
+ uri (>= 0.13.1)
83
+ base64 (0.3.0)
84
+ bcrypt (3.1.20)
85
+ benchmark (0.4.1)
86
+ bigdecimal (3.2.2)
87
+ builder (3.3.0)
88
+ coderay (1.1.3)
89
+ concurrent-ruby (1.3.5)
90
+ connection_pool (2.5.3)
91
+ crass (1.0.6)
92
+ date (3.4.1)
93
+ devise (4.9.4)
94
+ bcrypt (~> 3.0)
95
+ orm_adapter (~> 0.1)
96
+ railties (>= 4.1.0)
97
+ responders
98
+ warden (~> 1.2.3)
99
+ diff-lcs (1.6.2)
100
+ drb (2.2.3)
101
+ erb (5.0.2)
102
+ erubi (1.13.1)
103
+ eth (0.5.15)
104
+ bigdecimal (~> 3.1)
105
+ forwardable (~> 1.3)
106
+ keccak (~> 1.3)
107
+ konstructor (~> 1.0)
108
+ openssl (~> 3.3)
109
+ rbsecp256k1 (~> 6.0)
110
+ scrypt (~> 3.0)
111
+ ffi (1.17.2)
112
+ ffi (1.17.2-aarch64-linux-gnu)
113
+ ffi (1.17.2-aarch64-linux-musl)
114
+ ffi (1.17.2-arm-linux-gnu)
115
+ ffi (1.17.2-arm-linux-musl)
116
+ ffi (1.17.2-arm64-darwin)
117
+ ffi (1.17.2-x86-linux-gnu)
118
+ ffi (1.17.2-x86-linux-musl)
119
+ ffi (1.17.2-x86_64-darwin)
120
+ ffi (1.17.2-x86_64-linux-gnu)
121
+ ffi (1.17.2-x86_64-linux-musl)
122
+ ffi-compiler (1.3.2)
123
+ ffi (>= 1.15.5)
124
+ rake
125
+ forwardable (1.3.3)
126
+ globalid (1.2.1)
127
+ activesupport (>= 6.1)
128
+ i18n (1.14.7)
129
+ concurrent-ruby (~> 1.0)
130
+ io-console (0.8.1)
131
+ irb (1.15.2)
132
+ pp (>= 0.6.0)
133
+ rdoc (>= 4.0.0)
134
+ reline (>= 0.4.2)
135
+ keccak (1.3.2)
136
+ konstructor (1.0.2)
137
+ logger (1.7.0)
138
+ loofah (2.24.1)
139
+ crass (~> 1.0.2)
140
+ nokogiri (>= 1.12.0)
141
+ mail (2.8.1)
142
+ mini_mime (>= 0.1.1)
143
+ net-imap
144
+ net-pop
145
+ net-smtp
146
+ marcel (1.0.4)
147
+ method_source (1.1.0)
148
+ mini_mime (1.1.5)
149
+ mini_portile2 (2.8.9)
150
+ minitest (5.25.5)
151
+ net-imap (0.5.9)
152
+ date
153
+ net-protocol
154
+ net-pop (0.1.2)
155
+ net-protocol
156
+ net-protocol (0.2.2)
157
+ timeout
158
+ net-smtp (0.5.1)
159
+ net-protocol
160
+ nio4r (2.7.4)
161
+ nokogiri (1.18.9)
162
+ mini_portile2 (~> 2.8.2)
163
+ racc (~> 1.4)
164
+ nokogiri (1.18.9-aarch64-linux-gnu)
165
+ racc (~> 1.4)
166
+ nokogiri (1.18.9-aarch64-linux-musl)
167
+ racc (~> 1.4)
168
+ nokogiri (1.18.9-arm-linux-gnu)
169
+ racc (~> 1.4)
170
+ nokogiri (1.18.9-arm-linux-musl)
171
+ racc (~> 1.4)
172
+ nokogiri (1.18.9-arm64-darwin)
173
+ racc (~> 1.4)
174
+ nokogiri (1.18.9-x86_64-darwin)
175
+ racc (~> 1.4)
176
+ nokogiri (1.18.9-x86_64-linux-gnu)
177
+ racc (~> 1.4)
178
+ nokogiri (1.18.9-x86_64-linux-musl)
179
+ racc (~> 1.4)
180
+ openssl (3.3.0)
181
+ orm_adapter (0.5.0)
182
+ pkg-config (1.6.2)
183
+ pp (0.6.2)
184
+ prettyprint
185
+ prettyprint (0.2.0)
186
+ pry (0.15.2)
187
+ coderay (~> 1.1)
188
+ method_source (~> 1.0)
189
+ psych (5.2.6)
190
+ date
191
+ stringio
192
+ racc (1.8.1)
193
+ rack (3.2.0)
194
+ rack-session (2.1.1)
195
+ base64 (>= 0.1.0)
196
+ rack (>= 3.0.0)
197
+ rack-test (2.2.0)
198
+ rack (>= 1.3)
199
+ rackup (2.2.1)
200
+ rack (>= 3)
201
+ rails (8.0.2.1)
202
+ actioncable (= 8.0.2.1)
203
+ actionmailbox (= 8.0.2.1)
204
+ actionmailer (= 8.0.2.1)
205
+ actionpack (= 8.0.2.1)
206
+ actiontext (= 8.0.2.1)
207
+ actionview (= 8.0.2.1)
208
+ activejob (= 8.0.2.1)
209
+ activemodel (= 8.0.2.1)
210
+ activerecord (= 8.0.2.1)
211
+ activestorage (= 8.0.2.1)
212
+ activesupport (= 8.0.2.1)
213
+ bundler (>= 1.15.0)
214
+ railties (= 8.0.2.1)
215
+ rails-dom-testing (2.3.0)
216
+ activesupport (>= 5.0.0)
217
+ minitest
218
+ nokogiri (>= 1.6)
219
+ rails-html-sanitizer (1.6.2)
220
+ loofah (~> 2.21)
221
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
222
+ railties (8.0.2.1)
223
+ actionpack (= 8.0.2.1)
224
+ activesupport (= 8.0.2.1)
225
+ irb (~> 1.13)
226
+ rackup (>= 1.0.0)
227
+ rake (>= 12.2)
228
+ thor (~> 1.0, >= 1.2.2)
229
+ zeitwerk (~> 2.6)
230
+ rake (12.3.3)
231
+ rbsecp256k1 (6.0.0)
232
+ mini_portile2 (~> 2.8)
233
+ pkg-config (~> 1.5)
234
+ rubyzip (~> 2.3)
235
+ rdoc (6.14.2)
236
+ erb
237
+ psych (>= 4.0.0)
238
+ redis (5.4.1)
239
+ redis-client (>= 0.22.0)
240
+ redis-client (0.25.2)
241
+ connection_pool
242
+ reline (0.6.2)
243
+ io-console (~> 0.5)
244
+ responders (3.1.1)
245
+ actionpack (>= 5.2)
246
+ railties (>= 5.2)
247
+ rspec (3.13.1)
248
+ rspec-core (~> 3.13.0)
249
+ rspec-expectations (~> 3.13.0)
250
+ rspec-mocks (~> 3.13.0)
251
+ rspec-core (3.13.5)
252
+ rspec-support (~> 3.13.0)
253
+ rspec-expectations (3.13.5)
254
+ diff-lcs (>= 1.2.0, < 2.0)
255
+ rspec-support (~> 3.13.0)
256
+ rspec-mocks (3.13.5)
257
+ diff-lcs (>= 1.2.0, < 2.0)
258
+ rspec-support (~> 3.13.0)
259
+ rspec-rails (8.0.0)
260
+ actionpack (>= 7.2)
261
+ activesupport (>= 7.2)
262
+ railties (>= 7.2)
263
+ rspec-core (~> 3.13)
264
+ rspec-expectations (~> 3.13)
265
+ rspec-mocks (~> 3.13)
266
+ rspec-support (~> 3.13)
267
+ rspec-support (3.13.5)
268
+ rubyzip (2.4.1)
269
+ scrypt (3.0.8)
270
+ ffi-compiler (>= 1.0, < 2.0)
271
+ rake (>= 9, < 14)
272
+ securerandom (0.4.1)
273
+ sqlite3 (2.7.3-aarch64-linux-gnu)
274
+ sqlite3 (2.7.3-aarch64-linux-musl)
275
+ sqlite3 (2.7.3-arm-linux-gnu)
276
+ sqlite3 (2.7.3-arm-linux-musl)
277
+ sqlite3 (2.7.3-arm64-darwin)
278
+ sqlite3 (2.7.3-x86-linux-gnu)
279
+ sqlite3 (2.7.3-x86-linux-musl)
280
+ sqlite3 (2.7.3-x86_64-darwin)
281
+ sqlite3 (2.7.3-x86_64-linux-gnu)
282
+ sqlite3 (2.7.3-x86_64-linux-musl)
283
+ stringio (3.1.7)
284
+ thor (1.4.0)
285
+ timeout (0.4.3)
286
+ tzinfo (2.0.6)
287
+ concurrent-ruby (~> 1.0)
288
+ uri (1.0.3)
289
+ useragent (0.16.11)
290
+ warden (1.2.9)
291
+ rack (>= 2.0.9)
292
+ websocket-driver (0.8.0)
293
+ base64
294
+ websocket-extensions (>= 0.1.0)
295
+ websocket-extensions (0.1.5)
296
+ zeitwerk (2.7.3)
297
+
298
+ PLATFORMS
299
+ aarch64-linux-gnu
300
+ aarch64-linux-musl
301
+ arm-linux-gnu
302
+ arm-linux-musl
303
+ arm64-darwin
304
+ x86-linux-gnu
305
+ x86-linux-musl
306
+ x86_64-darwin
307
+ x86_64-linux-gnu
308
+ x86_64-linux-musl
309
+
310
+ DEPENDENCIES
311
+ devise-web3!
312
+ pry
313
+ rails
314
+ rake (~> 12.0)
315
+ rspec (~> 3.0)
316
+ rspec-rails
317
+ sqlite3
318
+
319
+ BUNDLED WITH
320
+ 2.6.8
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 TheSmartnik
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Devise::Web3
2
+
3
+ `Devise::Web3` allows to easily add support for authentication with etherium wallet.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'devise-web3'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install devise-web3
20
+
21
+ ## Usage
22
+ Add `:web3_authenticatable` module to your model along your other devise modules
23
+
24
+ Example
25
+ ```
26
+ class User < ApplicationRecord
27
+ devise :jwt_authenticatable,
28
+ :web3_authenticatable
29
+ end
30
+
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/devise-web3.
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "devise/web3"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ require_relative 'lib/devise/web3/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "devise-web3"
5
+ spec.version = Devise::Web3::VERSION
6
+ spec.authors = ["TheSmartnik"]
7
+ spec.email = ["misharinn@gmail.com"]
8
+
9
+ spec.summary = %q{Devise extension that allows to easily login with ethereum wallet}
10
+ spec.description = <<~EOF
11
+ Devise-web3 allows to easily implement login with metamask or any other ethereum wallet providers.
12
+ It works by providing a nonce for a user to sign and then cryptographically checking that signature is valid.
13
+ This allows for a simple one click login popular among web3 apps.
14
+ EOF
15
+ spec.homepage = "https://thesmartnik.com"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'devise', '~> 4.0'
33
+ spec.add_dependency 'eth', '~> 0.5.15'
34
+ spec.add_dependency 'redis'
35
+
36
+ spec.add_development_dependency 'rails'
37
+ spec.add_development_dependency 'rspec-rails'
38
+ spec.add_development_dependency "rspec"
39
+ spec.add_development_dependency 'sqlite3'
40
+
41
+ spec.add_development_dependency 'pry'
42
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+
5
+ module Devise
6
+ module Models
7
+ module Web3Authenticatable
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ def self.find_for_web3_authentication(address)
12
+ find_by(public_address: address)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require 'redis'
2
+
3
+ module Devise
4
+ module Web3
5
+ class RedisStore
6
+ attr_reader :redis
7
+
8
+ TTL = 10.minutes.to_i
9
+ NONCE_KEY = "web3-auth-nonce"
10
+
11
+ def initialize(redis_url)
12
+ @redis = Redis.new(url: redis_url)
13
+ end
14
+
15
+ def generate_nonce_with_id
16
+ nonce_id = redis.incr(NONCE_KEY)
17
+ nonce = SecureRandom.hex
18
+ redis.setex(key(nonce_id), TTL, nonce)
19
+ [nonce, nonce_id]
20
+ end
21
+
22
+ def fetch_nonce(nonce_id)
23
+ redis.get(key(nonce_id))
24
+ end
25
+
26
+ private
27
+
28
+ def key(id)
29
+ "#{NONCE_KEY}-#{id}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ module Devise
3
+ module Strategies
4
+ class Web3Authenticatable < Authenticatable
5
+ def authenticate!
6
+ redis_store = Devise::Web3::RedisStore.new(nil)
7
+
8
+ nonce = redis_store.fetch_nonce(nonce_id)
9
+ return fail!("Nonce coldn't be found. Perhaps it's already expired") if nonce.blank?
10
+ recovered_public_key = Eth::Signature.personal_recover nonce, signature
11
+ recovered_address = Eth::Util.public_key_to_address(recovered_public_key)&.address
12
+
13
+ return fail!("Signature verification failed") if recovered_address != address
14
+ user = User.find_or_create_by(public_address: address)
15
+ success!(user)
16
+ end
17
+
18
+ def valid?
19
+ credentials = params[:credentials]
20
+ credentials && credentials[:signature] && credentials[:nonce_id] && credentials[:address]
21
+ end
22
+
23
+ def nonce_id
24
+ params[:credentials][:nonce_id]
25
+ end
26
+
27
+ def address
28
+ params[:credentials][:address]
29
+ end
30
+
31
+ def signature
32
+ params[:credentials][:signature]
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+
39
+ Warden::Strategies.add(:web3_authenticatable, Devise::Strategies::Web3Authenticatable)
@@ -0,0 +1,5 @@
1
+ module Devise
2
+ module Web3
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require 'devise'
2
+ require 'redis'
3
+ require 'eth'
4
+ require 'devise/web3/version'
5
+ require 'devise/web3/redis_store'
6
+ require 'devise/web3/models/web3_authenticatable'
7
+ require 'devise/web3/strategies/web3_authenticatable'
8
+
9
+ module Devise
10
+ module Web3
11
+ class Error < StandardError; end
12
+
13
+ Devise.add_module :web3_authenticatable,
14
+ strategy: true,
15
+ model: 'web3/models/web3_authenticatable',
16
+ no_input: true
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise-web3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TheSmartnik
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-09-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: devise
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: eth
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.5.15
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.5.15
40
+ - !ruby/object:Gem::Dependency
41
+ name: redis
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rails
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec-rails
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rspec
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: sqlite3
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: pry
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ description: |
125
+ Devise-web3 allows to easily implement login with metamask or any other ethereum wallet providers.
126
+ It works by providing a nonce for a user to sign and then cryptographically checking that signature is valid.
127
+ This allows for a simple one click login popular among web3 apps.
128
+ email:
129
+ - misharinn@gmail.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - bin/console
143
+ - bin/setup
144
+ - devise-web3.gemspec
145
+ - lib/devise/web3.rb
146
+ - lib/devise/web3/models/web3_authenticatable.rb
147
+ - lib/devise/web3/redis_store.rb
148
+ - lib/devise/web3/strategies/web3_authenticatable.rb
149
+ - lib/devise/web3/version.rb
150
+ homepage: https://thesmartnik.com
151
+ licenses:
152
+ - MIT
153
+ metadata:
154
+ homepage_uri: https://thesmartnik.com
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 2.3.0
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.6.2
170
+ specification_version: 4
171
+ summary: Devise extension that allows to easily login with ethereum wallet
172
+ test_files: []