forked from spruceid/discourse-siwe-auth
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.rb
More file actions
66 lines (54 loc) · 1.83 KB
/
plugin.rb
File metadata and controls
66 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
# name: discourse-siwe-auth
# about: Authenticate users via the Sign In with Ethereum (SIWE) standard
# version: 1.3.2
# authors: EthID
# url: https://siwe.xyz
enabled_site_setting :discourse_siwe_enabled
register_svg_icon 'fab-ethereum'
register_asset 'stylesheets/discourse-siwe-auth.scss'
gem 'forwardable', '1.3.3', require: false
gem 'keccak', '1.3.3', require: false
gem 'rbsecp256k1', '6.0.0', require: false
gem 'konstructor', '1.0.2', require: false
gem 'ffi', '1.17.4', require: false
gem 'ffi-compiler', '1.0.1', require: false
gem 'scrypt', '3.0.7', require: false
gem 'eth', '0.5.11', require: false
gem 'siwe-rb', '0.1.2', require: false
# Load after gem declarations — the strategy file requires 'siwe', which only
# resolves once siwe-rb has been activated above.
%w[
../lib/omniauth/strategies/siwe.rb
].each { |path| load File.expand_path(path, __FILE__) }
class ::SiweAuthenticator < ::Auth::ManagedAuthenticator
def name
'siwe'
end
def register_middleware(omniauth)
omniauth.provider :siwe,
setup: lambda { |env|
strategy = env['omniauth.strategy']
}
end
def enabled?
SiteSetting.discourse_siwe_enabled
end
def primary_email_verified?
false
end
def description_for_auth_hash(auth_token)
auth_token&.provider_uid || super
end
end
auth_provider authenticator: ::SiweAuthenticator.new,
icon: 'fab-ethereum',
title_setting: :siwe_statement,
full_screen_login: true
after_initialize do
load File.expand_path('../app/controllers/discourse_siwe/auth_controller.rb', __FILE__)
Discourse::Application.routes.prepend do
get '/discourse-siwe/auth' => 'discourse_siwe/auth#index'
get '/discourse-siwe/message' => 'discourse_siwe/auth#message'
end
end