GithubHelp home page GithubHelp logo

anegg0 / siwe-nethereum Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaerith/siwe-nethereum

0.0 0.0 0.0 8.38 MB

A port of the first SIWE example (i.e., Notepad) that uses C# and Nethereum.

License: MIT License

JavaScript 2.57% C# 73.26% CSS 0.51% HTML 23.66%

siwe-nethereum's Introduction

siwe-nethereum

A port of the first SIWE example (i.e., Notepad) that uses C# and Nethereum to create a Blazor Server solution with a REST API backend. In this example, the sign-in process uses the SIWE standard to gain authorization via the issuance of JWTs, which are then saved in the browser as local storage. Examples of session storage are included, but they mainly exist for demonstrative purposes.

Many thanks to Juan Blanco for the projects from his Nethereum.Metamask.Blazor repo and the SIWE library currently in development. None of this would have been possible without them!

NOTE: There is now a professional SIWE template over at the official Nethereum site. Go check it out!

Screenshot

Projects

Project Source Nuget_Package Description
Siwe This C# library provides some experimental extensions and classes that supplement the Nethereum.Siwe.Core library.
siwe-nethereum This Blazor UI project showcases how to interact with Metamask and how to use a SIWE login via the REST services (i.e., the Notepad example).
siwe-rest-service This .NET 6 web api uses Nethereum.Siwe.Core (and the local Siwe supplement) to demonstrate how SIWE login can integrate with a Web2 scenario. NOTE: In order to run the siwe-nethereum project, this service must be running prior.

How to Use

In order to properly run the sample, you should:

  1. Run two instances of Visual Studio 2022, opening the 'siwe-nethereum' project with one and the 'siwe-rest-service' project with the other.
  2. Start the 'siwe-rest-service' project.
  3. Start the 'siwe-nethereum' project.
  4. When the browser page for 'siwe-nethereum' pops up, navigate to "SIWE with Nethereum" on the left-hand navigation pane. This page functions as the Notepad example.
  5. When at the Notepad screen, click on the "Connect Metamask" button at the top, which will trigger a login via Metamask.
  6. After the login with Metamask, click on the "Sign-In with Ethereum" button to start the SIWE process. It will trigger Metamask, asking you to sign the EIP-191 payload before forwarding it to the SignIn REST controller.
  7. Once the SignIn REST controller has validated the payload, SIWE will be complete, and you can then use the Notepad example to save text (via the Save REST controller).

NOTE: When running the 'siwe-nethereum' project, it assumes that the 'siwe-rest-service' is listening on local port 7148, as specified in Startup.cs:

services.AddSingleton<SiweRestService>(new SiweRestService("https://localhost:7148/"));

If the 'siwe-rest-service' starts on a different port when you run it, you'll have to change that respective line to the correct port.

STEP 4

Screenshot 1

STEP 5

Screenshot 2

STEP 6

Screenshot 3

siwe-nethereum's People

Contributors

jaerith avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.