Home

Awesome

Examples: JWTVault

see: GitHub

Pre-requisite

$ git clone https://github.com/sgrust01/jwtvault_examples.git

Overview

Example 1: Hello World

$ cargo run 
Notes

This example exhibits the core ability of the crate, to run as a library. This requires no runtime, runs on rust stable and has no unsafe code.

Example 2: Actix Server

$ cargo run --bin actix-dynamic
Notes

This crate can integrate with any web-server.

Workflow 1: User login
$ curl -X GET http://127.0.0.1:8080/login/john_doe/john
Workflow 2: User Request execution
$ curl -X GET http://127.0.0.1:8080/execute/john_doe/<authentication_token>
Workflow 3: Renew user authentication token
  $ curl -X GET http://127.0.0.1:8080/renew/john_doe/<refresh_token>
  
Workflow 4: Logout user
  $ curl -X GET http://127.0.0.1:8080/logout/john_doe/<authentication_token>

Example 3: Custom Vault

Notes

Exhibit the feature for saving custom information in memory. The library user need to implement only one method

$ cargo run --bin custom-static

Example 4: Postgres

Pre-requisite

  $ create demodb
  $ psql demodb < ./documentation/setup.sql
Notes

PLEASE NOTE:: The input strings are not sanitized in the example. All data from/to the web needs to be sanitized to avoid SQL Injection.

$ cargo run --bin postgres-dynamic

Example 5: Webserver

Pre-requisite

  $ create demodb
  $ psql demodb < ./documentation/setup.sql
Notes

$ cargo run --bin webserver-dynamic
Workflow 1: User signup
$ curl -X GET http://127.0.0.1:8080/signup/john_doe/john
Workflow 2: User login
   $ curl -X GET http://127.0.0.1:8080/login/<user_id>/<password>
Workflow 3: User Request execution
   $ curl -X GET http://127.0.0.1:8080/execute/<user_id>/<authentication_token>
Workflow 4: Renew user authentication token
     $ curl -X GET http://127.0.0.1:8080/renew/<user_id>/<refresh_token>
Workflow 5: Logout user
     $ curl -X GET http://127.0.0.1:8080/logout/<user_id>/<authentication_token>