Sign-In with Ethereum plugin

A Discourse plugin that lets users authenticate with their Ethereum wallet using
the Sign-In with Ethereum (SIWE) standard. Injected wallets
(MetaMask, Safe, etc.) work out of the box. ENS names and avatars are resolved
server-side when an RPC endpoint is configured.

Requirements

  • A Discourse forum that is self-hosted or hosted with a provider that supports
    third-party plugins, like Communiteq.

Installation

Access your container’s app.yml file:

cd /var/discourse
nano containers/app.yml

Add the plugin’s repository URL to the after_code hook:

hooks:
  after_code:
    - exec:
      cd: $home/plugins
      cmd:
        - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
        - sudo -E -u discourse git clone https://github.com/signinwithethereum/discourse-siwe-auth.git # <-- added

Follow the existing format of the docker_manager.git line; if it does not
contain sudo -E -u discourse then use
git clone https://github.com/signinwithethereum/discourse-siwe-auth.git instead.

Rebuild the container:

cd /var/discourse
./launcher rebuild app

Configuration

After installation, find the plugin under Admin > Plugins and make sure it
is enabled:

Click Settings to configure the plugin:

From here you can customize the sign-in statement and optionally add a
WalletConnect / Reown project ID. Without a project ID, only injected wallets
(MetaMask, Safe, etc.) are available.

Settings

Setting Description
Discourse siwe enabled Enable or disable Sign-In with Ethereum authentication.
Siwe ethereum rpc url Optional. An Ethereum JSON-RPC endpoint used for ENS name/avatar resolution and EIP-1271 signature verification (required for smart contract wallets like SAFE). A dedicated provider (Alchemy, Infura) is recommended. Example: https://mainnet.infura.io/v3/YOUR_KEY.
Siwe project ID Optional. A WalletConnect / Reown project ID. Without it, only injected wallets (MetaMask, Safe, etc.) are available. To enable WalletConnect, create a free project ID at dashboard.reown.com.
Siwe statement The human-readable statement shown in the SIWE message. Defaults to “Sign in with Ethereum”.

How it works

When a user clicks the Ethereum login button, the plugin opens a dedicated
authentication. The user connects their wallet, signs a SIWE message,
and is authenticated via an OmniAuth strategy on the server side.

After first sign-in, users are asked to associate an email address with their
account. If an RPC URL is configured and the connected address has an ENS name,
the name is resolved and verified server-side and suggested as the default
username. ENS avatars are fetched via the ENS metadata service and used as the
profile photo.

Alternatively, existing users can connect their Ethereum accounts via
their profile settings.

14 Likes

some discussion about dependencies here Discourse can't find gems specified in the plugin

Found this on GitHub, seems to be actively developed too. Seems like it allows web3 logins (still require email addresses after logging in with your wallet).

However the dev is facing an issue that prevents installing the plugin and bootstrapping discourse after. Full details in the issue below. Maybe it’s a really simple issue and someone here can submit a PR for the dev.

1 Like

Hold my beer :wink:
Solution in the Github issue.

3 Likes

That is awesome, trying it right now. I hope this helps te developer aswell :grinning:

EDIT: I end up with the same error it seems even tho it looks like the gem is being installed:

version 2.3.0.
Successfully installed rubyzip-2.3.2
1 gem installed
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 777 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

Can you please do this?

2 Likes

Going through the logs, posting things that I believe might be relevant.

@moderators maybe a topic split for this? There is no official topic from this plugin, I don’t think the dev is on meta.

I, [2022-07-04T16:43:46.394301 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
Gem::ConflictError: Unable to activate eth-0.5.1, because openssl-3.0.0 conflicts with openssl (~> 2.2)

I don’t see any other errors at this moment (or I’m missing them, logs are long)

1 Like

To be honest, I’m not following the gist of what’s going on here. :slightly_smiling_face: @RGJ and @michaeld have the power to split, so perhaps they’ll do the honours and manage it in a more sensitive manner than I will. :slightly_smiling_face::crossed_fingers: (or, alternatively, pick the post to split from, name the category you want it to go in, and let me know a title to give it :+1:)

1 Like

My suggestion is split from here:

https://meta.discourse.org/t/web-3-0-features/203321/19?u=marcp

The most suitable category would be Support or #plugins (i’m not sure.. how do we deal with plugins that are not developed by a member of Meta.. maybe he will join meta or we can invite him through github to meta someday?)

EDIT:

Seems this is the dev, so he is on meta? @w4ll3

@michaeld made a PR for this yesterday, but it’s not merged yet. You can use GitHub - communiteq/discourse-siwe-auth: Discourse plugin for SIWE authentication in the meanwhile.

3 Likes

Can confirm this works! Thanks Michael.

1 Like

So to sum it up, you need both the before_code as described in the issue Cannot Install Plugin on Self-Hosted Discourse server - rbsecp256k1 · Issue #15 · spruceid/discourse-siwe-auth · GitHub AND the newer version of the eth gem that I made the (currently unmerged) PR for.

5 Likes

A bit late here on the official forum, but hey - Rocco here from the Spruce team.

Thanks again @michaeld for the fixes there, it took care of it and we updated the documentation from our side. Also thanks for bringing this all up - we’re still actively developing / maintaining things around Sign-In with Ethereum.

Was also curious here - is there a path to eventually making this an officially supported plugin :grinning: - we love Discourse and want to figure out how to extend this functionality to instances that aren’t self-hosted.

2 Likes

Just for clarity, Communiteq does support this plugin on our managed hosting plans, it’s available on the Professional plan and higher.

3 Likes

My apologies about that!

No need to apologize! The official hosting does not have it (yet?). I just wanted to emphasize our commitment to these web3 plugins.

3 Likes

Yeah - not an officially supported plugin, unfortunately.

But definitely kudos for the support from Communiteq! Anything to help support Web3 users is really awesome.

From our end we’re working on various different ways to support Sign-In with Ethereum adoption and Discourse was always at the top of our list which is why after we standardized it EIP-4361 we created the plugin. The other thing that has been top of mind is around what else to add to it - with the custom RPC provider being one of the first pieces.

3 Likes

This plugin is not working for me there is some issue with plugin not able to install , can somebody share alternative or help with this one @michaeld @RGJ

You will need to share details if you want help.

1 Like

@RGJ when i try to install this plugin , rebuild fails with this error

You are specifying the gem rbsecp256k1 in /var/www/discourse/plugins/discourse-siwe-auth/plugin.rb, however it does not exist!
Looked for: /var/www/discourse/plugins/discourse-siwe-auth/gems/2.7.6/specifications/rbsecp256k1-5.1.0.gemspec