Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darkness4/auth-web3-htmx
Experiment with Go + HTMX and Ethereum authentication
https://github.com/darkness4/auth-web3-htmx
ethereum go htmx sql web3
Last synced: about 1 month ago
JSON representation
Experiment with Go + HTMX and Ethereum authentication
- Host: GitHub
- URL: https://github.com/darkness4/auth-web3-htmx
- Owner: Darkness4
- License: apache-2.0
- Created: 2023-11-23T19:52:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-29T01:57:06.000Z (about 1 year ago)
- Last Synced: 2024-12-01T07:22:42.520Z (about 2 months ago)
- Topics: ethereum, go, htmx, sql, web3
- Language: Go
- Homepage: https://auth-web3-htmx.mnguyen.fr
- Size: 76.2 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go + HTMX + Web3
A very simple example HTMX with Web3 with:
- Go HTML templating engine.
- HTMX solution for SSR.
- Ethereum as authenticator.
- (+CSRF protection measures for all requests).
- SQLite3 with sqlc and golang-migrate.## Motivation
For the hype.
## Usage
1. Set the necessary parameters or environment variables:
```shell
## .env.local
## A 32 bytes hex secret (openssl rand -hex 32)
CSRF_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
## A hex ECDSA private key in ethereum format (openssl rand -hex 32)
PRIVATE_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
## A unique string secret
JWT_SECRET=secret
## PUBLIC_URL will be used as redirect url which is ${PUBLIC_URL}/callback
PUBLIC_URL=http://localhost:3000
DB_PATH=/data/db.sqlite3
```2. Run the binary:
```shell
./auth-web3-htmx
```**Help**:
```
NAME:
auth-web3-htmx - Demo of Auth and HTMX.USAGE:
auth-web3-htmx [global options] command [command options] [arguments...]COMMANDS:
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--csrf.secret value A 32 bytes hex secret [$CSRF_SECRET]
--jwt.secret value A unique string secret [$JWT_SECRET]
--private-key value A ecdsa private key in Hex. [$PRIVATE_KEY]
--db.path value SQLite3 database file path. (default: "./db.sqlite3") [$DB_PATH]
--help, -h show help
--version, -v print the version
```## Application Flow
- A home page:
- Show login button if not logged in.
- Else, show a welcome with routing.
- A protected counter page.