Example full stack Rust project, using actix-web and Sycamore and bulma-css. (Initially was using dioxus but switched to sycamore to test out the api)
Adapted from https://robert.kra.hn/posts/2022-04-03_rust-web-wasm/.
Attempts to implement BFF (backend for frontend) pattern for login using oidc. Inspired by Duendesoftware's implementation.
/public/*
endpoints accessible by all/api/*
endpoints accessible by logged in users/admin/*
endpoints accessible by only whitelisted emails (hardcoded for now)
- AuthN with Google OIDC, utilising the BFF architecture
- AuthZ: Access control with something like casbin-rs
- Full stack frontend and backend, with shared structs in
commons
- Demo of Server Sent Events as a ticker to frontend
- Use Bulma CSS and Sycamore-rs for frontend
- Integration with a simple database like SQLITE
- Set up google oidc client at https://console.cloud.google.com/apis/credentials
- Get GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET and set them as environment variables before you run the server binary
- Set an environment variable SERVER_SECRET_KEY to a random string with at least 64 characters for cryptographically signing your tokens. Keep this a secret.
- Make sure to set authorised redirect uri to http://localhost:8080/public/token_exchange in your google oauth app
- Build frontend distribution using Trunk
cd frontend
trunk build --release
- This will build the wasm bundle in the root ./dist folder
- Next, compile the backend from the root folder
cargo build --release
- Run the binary
RUST_LOG=INFO target/release/server
- Open your browser at localhost:8080
You can watch your front end code with trunk watch
and start the webserver to serve the frontend
Note that you'll need to reload the page to see your changes