Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.52 KB

README.md

File metadata and controls

63 lines (45 loc) · 1.52 KB

rust-axum-jwt-postgresql-demo Unit Tests

A demo API for a presentation on Rust/Axum Architecture and for the enterprise.

Run example with Doocker

Build a Docker image

docker build -t rust-axum-jwt-postgresql-demo .

Run a Docker container

docker run -p 3000:3000 rust-axum-jwt-postgresql-demo -e JWT_SECRET=bar

Trying it out

  • get an authorization token:
curl -s \
    -w '\n' \
    -H 'Content-Type: application/json' \
    -d '{"client_id":"foo","client_secret":"bar"}' \
    http:localhost:3000/authorize
  • visit the protected area using the authorized token
curl -s \
    -w '\n' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJiQGIuY29tIiwiY29tcGFueSI6IkFDTUUiLCJleHAiOjEwMDAwMDAwMDAwfQ.M3LAZmrzUkXDC1q5mSzFAs_kJrwuKz3jOoDmjJ0G4gM' \
    http:localhost:3000/protected
  • try to visit the protected area using an invalid token
curl -s \
    -w '\n' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer blahblahblah' \
    http:localhost:3000/protected

Developer Notes

Build locally on Windows by command line

cargo build --target=i686-pc-windows-msvc

Run on Windows by command line

cargo run --target=i686-pc-windows-msvc