omniauth-ethereum 0.1.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06e7d6bb22e75786a859fa75494b98c7f89de1516adaba495e5792f96dbb6a1c
4
- data.tar.gz: b2df0312a95aaed2eb803074a6f0f6a9725042330692d76ce3d99e521b36e803
3
+ metadata.gz: 2285babef95f18732c8816620b392941e58350f2ea32800b45f7a54f9fefbaaa
4
+ data.tar.gz: 859bc6fd3b38eb10e711f4b0d9d4c4bbd3f964e030509cd155a1af3186c3e88f
5
5
  SHA512:
6
- metadata.gz: 5fda951ff144eb22a906dd82a1b831c72cee027d71676fe9bb911f52f870dad91915d40572c7f9a8ebdc6a473d8d75f3add6182512c242b4702a6c8f83fe5a30
7
- data.tar.gz: 5f87d296ef4f9b568222fa9f305f2f8c5d6dd215b56d456b4daf30ee7d3898bbda61d6e14182b746f8c93887906b12d6b6c915e124d763d0612f94a0414af3c7
6
+ metadata.gz: 0ec10f640de7d95291c442d7ba177e3c951adebc4f01d8449994a53ebf5517d514ce297150adac3ae49665347c77a9177d3af6048332b2202bcad632bc79d42a
7
+ data.tar.gz: 8adf7bfd0e2edf4f352448082ce24934cc3063dab2acb48f686e513671dd5332a484fc93256c2ebe6f1d7401c9cede411be11fdd180525d8733f14c2e54ff508
@@ -0,0 +1,18 @@
1
+ ---
2
+ updates:
3
+ -
4
+ directory: /
5
+ labels:
6
+ - dependencies
7
+ package-ecosystem: bundler
8
+ schedule:
9
+ interval: weekly
10
+ versioning-strategy: increase
11
+ -
12
+ directory: /
13
+ labels:
14
+ - operations
15
+ package-ecosystem: github-actions
16
+ schedule:
17
+ interval: monthly
18
+ version: 2
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: CodeQL
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+ push:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ language:
24
+ - ruby
25
+ steps:
26
+ - name: "Checkout repository"
27
+ uses: actions/checkout@v4
28
+ - name: "Initialize CodeQL"
29
+ uses: github/codeql-action/init@v3
30
+ with:
31
+ languages: "${{ matrix.language }}"
32
+ - name: Autobuild
33
+ uses: github/codeql-action/autobuild@v3
34
+ - name: "Perform CodeQL Analysis"
35
+ uses: github/codeql-action/analyze@v3
36
+ - uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: '3.3'
39
+ bundler-cache: true
40
+ - name: "Run rufo code formatting checks"
41
+ run: |
42
+ gem install rufo
43
+ rufo --check ./lib
44
+ rufo --check ./spec
@@ -15,13 +15,18 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- os: [ubuntu-latest]
19
- ruby: ['2.7', '3.0']
18
+ os: ['ubuntu-latest', 'macos-latest']
19
+ ruby: ['3.0', '3.2', '3.3']
20
20
  steps:
21
- - uses: actions/checkout@v2
21
+ - uses: actions/checkout@v4
22
+ - name: MacOs Dependencies
23
+ run: |
24
+ brew install --verbose pkg-config automake autogen libtool gmp libffi
25
+ if: startsWith(matrix.os, 'macOS')
22
26
  - uses: ruby/setup-ruby@v1
23
27
  with:
24
28
  ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
25
30
  - name: Install Dependencies
26
31
  run: |
27
32
  bundle install
data/.gitignore CHANGED
@@ -35,6 +35,7 @@ config/master.key
35
35
  # these should all be checked in to normalize the environment:
36
36
  # Gemfile.lock, .ruby-version, .ruby-gemset
37
37
  *.gem
38
+ Gemfile.lock
38
39
 
39
40
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40
41
  .rvmrc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # omniauth-ethereum
2
2
 
3
- [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/q9f/omniauth-ethereum/Test)](https://github.com/q9f/omniauth-ethereum/actions)
3
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/q9f/omniauth-ethereum.rb/test.yml?branch=main)](https://github.com/q9f/omniauth-ethereum/actions)
4
4
  [![GitHub release (latest by date)](https://img.shields.io/github/v/release/q9f/omniauth-ethereum)](https://github.com/q9f/omniauth-ethereum/releases)
5
5
  [![Gem](https://img.shields.io/gem/v/omniauth-ethereum)](https://rubygems.org/gems/omniauth-ethereum)
6
6
  [![GitHub top language](https://img.shields.io/github/languages/top/q9f/omniauth-ethereum?color=red)](https://github.com/q9f/omniauth-ethereum/pulse)
data/lib/new_session.js CHANGED
@@ -22,7 +22,7 @@ if (typeof window.ethereum !== 'undefined') {
22
22
  const etherbase = accounts[0];
23
23
 
24
24
  // sign a message with current time
25
- const customTitle = "Hello from Ruby!";
25
+ const customTitle = document.querySelector('.custom_title').textContent;
26
26
  const requestTime = Math.floor(new Date().getTime() / 1000);
27
27
  const message = customTitle + " " + requestTime;
28
28
  const signature = await personalSign(etherbase, message);
@@ -1,5 +1,5 @@
1
- require 'omniauth'
2
- require 'eth'
1
+ require "omniauth"
2
+ require "eth"
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
@@ -14,11 +14,13 @@ module OmniAuth
14
14
 
15
15
  # the `eth_address` will be the _fake_ unique identifier for the Ethereum strategy
16
16
  option :uid_field, :eth_address
17
- option :fields, [:eth_message, :eth_address, :eth_signature]
18
- option :uid_field, :eth_address
17
+
18
+ # this will be shown on signature screen
19
+ option :custom_title, "Hello from Ruby!"
19
20
 
20
21
  def request_phase
21
- form = OmniAuth::Form.new :title => 'Ethereum Authentication', :url => callback_path
22
+ form = OmniAuth::Form.new :title => "Ethereum Authentication", :url => callback_path
23
+ form.html("<span class='custom_title'>#{options.custom_title}</span>")
22
24
  options.fields.each do |field|
23
25
 
24
26
  # these fields are read-only and will be filled by javascript in the process
@@ -30,8 +32,8 @@ module OmniAuth
30
32
  end
31
33
 
32
34
  # the form button will be heavy on javascript, requesting account, nonce, and signature before submission
33
- form.button 'Sign In'
34
- path = File.join( File.dirname(__FILE__), 'new_session.js')
35
+ form.button "Sign In"
36
+ path = File.join(File.dirname(__FILE__), "new_session.js")
35
37
  js = File.read(path)
36
38
  mod = "<script type='module'>\n#{js}\n</script>"
37
39
 
@@ -40,17 +42,16 @@ module OmniAuth
40
42
  end
41
43
 
42
44
  def callback_phase
43
- address = request.params['eth_address'].downcase
44
- message = request.params['eth_message']
45
- signature = request.params['eth_signature']
46
- signature_pubkey = Eth::Key.personal_recover message, signature
47
- signature_address = (Eth::Utils.public_key_to_address signature_pubkey).downcase
48
-
49
- unix_time = message.scan(/\d+/).first.to_i
45
+ message = request.params["eth_message"]
46
+ unix_time = message.scan(/\d+/).last.to_i
50
47
  ten_min = 10 * 60
51
48
  return fail!(:invalid_time) unless unix_time + ten_min >= now && unix_time - ten_min <= now
52
49
 
53
- return fail!(:invalid_credentials) unless signature_address == address
50
+ address = Eth::Address.new request.params["eth_address"]
51
+ signature = request.params["eth_signature"]
52
+ signature_pubkey = Eth::Signature.personal_recover message, signature
53
+ signature_address = Eth::Util.public_key_to_address(signature_pubkey)
54
+ return fail!(:invalid_credentials) unless signature_address.to_s == address.to_s
54
55
 
55
56
  super
56
57
  end
@@ -1,36 +1,36 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
- spec.name = 'omniauth-ethereum'
6
- spec.version = '0.1.0'
7
- spec.summary = "OmniAuth Strategy for Ethereum"
8
- spec.description = "Authentication Strategy for OmniAuth to authenticate a user with an Ethereum account"
9
- spec.authors = ["Afri Schoedon"]
10
- spec.email = 'gems@fault.dev'
11
- spec.homepage = 'https://github.com/q9f/omniauth-ethereum'
12
- spec.license = 'Apache-2.0'
5
+ spec.name = "omniauth-ethereum"
6
+ spec.version = "0.2.1"
7
+ spec.summary = "OmniAuth Strategy for Ethereum"
8
+ spec.description = "Authentication Strategy for OmniAuth to authenticate a user with an Ethereum account"
9
+ spec.authors = ["Afri Schoedon"]
10
+ spec.email = "gems@q9f.cc"
11
+ spec.homepage = "https://github.com/q9f/omniauth-ethereum.rb"
12
+ spec.license = "Apache-2.0"
13
13
 
14
- spec.metadata = {
15
- 'homepage_uri' => 'https://github.com/q9f/omniauth-ethereum',
16
- 'source_code_uri' => 'https://github.com/q9f/omniauth-ethereum',
17
- 'github_repo' => 'https://github.com/q9f/omniauth-ethereum',
18
- 'bug_tracker_uri' => 'https://github.com/q9f/omniauth-ethereum/issues',
14
+ spec.metadata = {
15
+ "homepage_uri" => "https://github.com/q9f/omniauth-ethereum.rb",
16
+ "source_code_uri" => "https://github.com/q9f/omniauth-ethereum.rb",
17
+ "github_repo" => "https://github.com/q9f/omniauth-ethereum.rb",
18
+ "bug_tracker_uri" => "https://github.com/q9f/omniauth-ethereum.rb/issues",
19
19
  }.freeze
20
20
 
21
- spec.require_paths = ["lib"]
22
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.require_paths = ["lib"]
22
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
 
24
24
  spec.platform = Gem::Platform::RUBY
25
- spec.required_ruby_version = ">= 2.7", "< 4.0"
25
+ spec.required_ruby_version = ">= 3.0", "< 4.0"
26
26
 
27
27
  # OmniAuth is what this strategy is providing
28
- spec.add_dependency 'omniauth', '~> 2.0'
28
+ spec.add_dependency "omniauth", "~> 2.1"
29
29
 
30
30
  # Use Ruby-Eth for signature recovery
31
- spec.add_dependency 'eth', '~> 0.4.16'
31
+ spec.add_dependency "eth", "~> 0.5"
32
32
 
33
33
  # Spec tests
34
- spec.add_development_dependency 'rspec', '~> 3.10'
35
- spec.add_development_dependency 'rack-test', '~> 1.1'
34
+ spec.add_development_dependency "rspec", "~> 3.12"
35
+ spec.add_development_dependency "rack-test", "~> 1.1"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-ethereum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Afri Schoedon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-23 00:00:00.000000000 Z
11
+ date: 2024-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.16
33
+ version: '0.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.16
40
+ version: '0.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.10'
47
+ version: '3.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.10'
54
+ version: '3.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -68,28 +68,29 @@ dependencies:
68
68
  version: '1.1'
69
69
  description: Authentication Strategy for OmniAuth to authenticate a user with an Ethereum
70
70
  account
71
- email: gems@fault.dev
71
+ email: gems@q9f.cc
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/dependabot.yml"
77
+ - ".github/workflows/code.yml"
76
78
  - ".github/workflows/test.yml"
77
79
  - ".gitignore"
78
80
  - Gemfile
79
- - Gemfile.lock
80
81
  - LICENSE
81
82
  - README.md
82
83
  - lib/new_session.js
83
84
  - lib/omniauth-ethereum.rb
84
85
  - omniauth-ethereum.gemspec
85
- homepage: https://github.com/q9f/omniauth-ethereum
86
+ homepage: https://github.com/q9f/omniauth-ethereum.rb
86
87
  licenses:
87
88
  - Apache-2.0
88
89
  metadata:
89
- homepage_uri: https://github.com/q9f/omniauth-ethereum
90
- source_code_uri: https://github.com/q9f/omniauth-ethereum
91
- github_repo: https://github.com/q9f/omniauth-ethereum
92
- bug_tracker_uri: https://github.com/q9f/omniauth-ethereum/issues
90
+ homepage_uri: https://github.com/q9f/omniauth-ethereum.rb
91
+ source_code_uri: https://github.com/q9f/omniauth-ethereum.rb
92
+ github_repo: https://github.com/q9f/omniauth-ethereum.rb
93
+ bug_tracker_uri: https://github.com/q9f/omniauth-ethereum.rb/issues
93
94
  post_install_message:
94
95
  rdoc_options: []
95
96
  require_paths:
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - ">="
100
101
  - !ruby/object:Gem::Version
101
- version: '2.7'
102
+ version: '3.0'
102
103
  - - "<"
103
104
  - !ruby/object:Gem::Version
104
105
  version: '4.0'
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.2.29
112
+ rubygems_version: 3.2.32
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: OmniAuth Strategy for Ethereum
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-ethereum (0.1.0)
5
- eth (~> 0.4.16)
6
- omniauth (~> 2.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- 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)
17
- scrypt (~> 3.0)
18
- ffi (1.15.4)
19
- ffi-compiler (1.0.1)
20
- ffi (>= 1.0.0)
21
- rake
22
- hashie (5.0.0)
23
- keccak (1.2.2)
24
- money-tree (0.10.0)
25
- ffi
26
- omniauth (2.0.4)
27
- hashie (>= 3.4.6)
28
- rack (>= 1.6.2, < 3)
29
- rack-protection
30
- rack (2.2.3)
31
- rack-protection (2.1.0)
32
- rack
33
- rack-test (1.1.0)
34
- rack (>= 1.0, < 3)
35
- 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)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.10.0)
46
- rspec-mocks (3.10.2)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.10.0)
49
- rspec-support (3.10.3)
50
- scrypt (3.0.7)
51
- ffi-compiler (>= 1.0, < 2.0)
52
-
53
- PLATFORMS
54
- x86_64-linux
55
-
56
- DEPENDENCIES
57
- omniauth-ethereum!
58
- rack-test (~> 1.1)
59
- rspec (~> 3.10)
60
-
61
- BUNDLED WITH
62
- 2.2.28