https://github.com/lit-protocol/cloudflare-litgate-rust
https://github.com/lit-protocol/cloudflare-litgate-rust
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lit-protocol/cloudflare-litgate-rust
- Owner: LIT-Protocol
- License: apache-2.0
- Created: 2021-12-12T16:43:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-12T20:51:26.000Z (over 4 years ago)
- Last Synced: 2025-08-31T12:39:06.562Z (10 months ago)
- Language: Rust
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE_APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Getting Started
A template for kick starting a Cloudflare worker that protects some URL by verifying a JWT generated by the Lit Protocol
## Notes
This has only been tested to compile on Ubuntu 20.04 with emcc as the compiler. I could not get it to compile on a mac.
## Usage
You will need Cloudflare Wrangler to build and deploy this. Install it using the instructions here: https://developers.cloudflare.com/workers/cli-wrangler/install-update
After installing it, run "wrangler login" to log in to your cloudflare account.
You also need to install EMCC for compilation using instructions here: https://emscripten.org/docs/getting_started/downloads.html
After installing it, make sure you expose emcc in your path by following the instructions that emcc gives after installation.
Before compiling, make sure you run `export CC=emcc` in your terminal to set emcc as the compiler.
Next, open at src/lib.rs. Every line that has a comment that starts with "LIT Developers" is something you should look at.
Specifically, you should set the `protected_url` variable on line 41 to the final URL you want to send your users to, if they authenticate successfully.
## Building and Deploying on cloudflare
This template starts you off with a `src/lib.rs` file, acting as an entrypoint for requests hitting
your Worker. Feel free to add more code in this file, or create Rust modules anywhere else for this
project to use.
With `wrangler`, you can build, test, and deploy your Worker with the following commands:
```bash
# compiles your project to WebAssembly and will warn of any issues
wrangler build
# run your Worker in an ideal development workflow (with a local server, file watcher & more)
wrangler dev
# deploy your Worker globally to the Cloudflare network (update your wrangler.toml file for configuration)
wrangler publish
```
Read the latest `worker` crate documentation here: https://docs.rs/worker