Skip to content

Commit 323e5b8

Browse files
committed
refactoring readme docs with updates to the jwt docs - using signed jwt not encrypted (yet)
1 parent c3723da commit 323e5b8

File tree

4 files changed

+54
-38
lines changed

4 files changed

+54
-38
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "restapi"
33
description = "A secure-by-default rest api stack implemented with hyper, tokio, bb8 and postgres. This project is focused on providing end-to-end encryption by default for 12-factor applications looking to customize functionality using environment variables as needed. Includes a working user management and authentication backend written in postgresql with async S3 uploading for POST-ed data files."
4-
version = "1.0.7"
4+
version = "1.0.8"
55
edition = "2021"
66
license = "MIT"
77
authors = [

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@
22

33
A secure-by-default rest api stack implemented with hyper, tokio, bb8 and postgres. This project is focused on providing end-to-end encryption by default for 12-factor applications looking to customize functionality using environment variables as needed. Includes a working user management and authentication backend written in postgresql with async S3 uploading for POST-ed data files.
44

5-
### Overview
5+
## Overview
6+
7+
### User
68

7-
- User authentication enabled by default and implemented with custom tls assets to encrypt all JWT tokens with storage in postgres.
8-
- Users can upload and manage files stored on AWS S3 (assuming valid credentials are loaded outside this rust project).
99
- User password reset and user email change support using one-time-use tokens that are stored in postgres.
10+
- Users can upload and manage files stored on AWS S3 (assuming valid credentials are loaded outside this rust project).
1011
- User passwords are hashed using [argon2](https://docs.rs/argon2/latest/argon2/).
11-
- The hyper server hosts tls assets that can be re-generated with the tools in this repository.
12-
- JWT encryption and decryption keys included and [documentation for building new keys as needed](https://github.com/jay-johnson/restapi/tree/main/jwt).
13-
- Includes a tls asset generator tool ([./certs/generate-tls-assets.sh](https://github.com/jay-johnson/restapi/blob/main/certs/generate-tls-assets.sh)) for building self-signed tls assets (requires docker).
14-
- The postgres database requires each client include the postgres tls certificate authority file for encrypting data in-transit.
12+
13+
### Auth
14+
15+
- User authentication enabled by default
16+
- Default JWT signing keys included with [documentation for building new keys as needed](https://github.com/jay-johnson/restapi/tree/main/jwt).
17+
18+
### Database
19+
1520
- The rest api server utilizes postgres with a [bb8 client threadpool](https://github.com/djc/bb8).
21+
- The postgres database requires each client connection include the postgres tls certificate authority file for encrypting data in-transit.
1622
- Includes [pg4admin](https://www.pgadmin.org/docs/pgadmin4/latest/index.html) for database management in a browser (deployed with docker compose).
1723

18-
### TLS Encryption Status
24+
### TLS Encryption
25+
26+
- Includes a tls asset generator tool ([./certs/generate-tls-assets.sh](https://github.com/jay-johnson/restapi/blob/main/certs/generate-tls-assets.sh)) for building self-signed tls assets (requires docker).
27+
28+
#### Ingress
1929

2030
Component | Status
2131
---------------- | ------
2232
Rest API Server | Listening for encrypted client connections on tcp port **3000**
23-
JWT | Encrypting and decrypting tokens with [ECDSA using SHA-256](https://docs.rs/jsonwebtoken/latest/jsonwebtoken/enum.Algorithm.html#variant.ES256)
2433
Postgres | Listening for encrypted client connections on tcp port **5432** (tls Certificate Authority required)
2534
pgAdmin | Listening for encrypted HTTP client connections on tcp port **5433**
26-
AWS S3 | Encrypted at rest with [AES256](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)
2735

2836
## Getting Started
2937

@@ -40,21 +48,17 @@ The repository [restapi](https://github.com/jay-johnson/restapi) includes defaul
4048

4149
Here's how to generate them under the ``./certs`` directory:
4250

43-
<a href="https://asciinema.org/a/473131?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473131.png"/></a>
44-
4551
```bash
4652
cd certs
4753
./generate-tls-assets.sh -f -c ./configs/dev-network.yml
4854
cd ..
4955
```
5056

51-
### Generate JWT Keys
52-
53-
Authentication using JWT requires encrypting and decrypting using your own keys. Please refer to the [How to build JWT private and public keys for the jsonwebtokens crate doc](./certs/README.md) for more information.
57+
<a href="https://asciinema.org/a/473131?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473131.png"/></a>
5458

55-
Here's how to generate the jwt keys under the ``./jwt`` directory:
59+
### Generate JWT Keys
5660

57-
<a href="https://asciinema.org/a/473132?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473132.png"/></a>
61+
This repo includes default JWT signing keys, but you should generate your own signing keys under the ``./jwt`` directory with these commands:
5862

5963
```bash
6064
cd jwt
@@ -64,6 +68,10 @@ openssl ec -in private-key.pem -pubout -out public-key.pem
6468
cd ..
6569
```
6670

71+
<a href="https://asciinema.org/a/473132?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473132.png"/></a>
72+
73+
Please refer to the [How to build JWT private and public keys for the jsonwebtokens crate doc](./certs/README.md) for more information.
74+
6775
### Build the Postgres docker image
6876

6977
Please refer to the [Build and Deploy a Secured Postgres backend doc](./docker/db/README.md) for more information.

src/lib.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,36 @@
66
//!
77
//! Please see the [restapi/examples/server.rs](https://github.com/jay-johnson/restapi/blob/main/examples/server.rs) for developing your own rest api.
88
//!
9-
//! ### Overview
9+
//! ## Overview
10+
//!
11+
//! ### User
1012
//!
11-
//! - User authentication enabled by default and implemented with custom tls assets to encrypt all JWT tokens with storage in postgres.
12-
//! - Users can upload and manage files stored on AWS S3 (assuming valid credentials are loaded outside this rust project).
1313
//! - User password reset and user email change support using one-time-use tokens that are stored in postgres.
14+
//! - Users can upload and manage files stored on AWS S3 (assuming valid credentials are loaded outside this rust project).
1415
//! - User passwords are hashed using [argon2](https://docs.rs/argon2/latest/argon2/).
15-
//! - The hyper server hosts tls assets that can be re-generated with the tools in this repository.
16-
//! - JWT encryption and decryption keys included and [documentation for building new keys as needed](https://github.com/jay-johnson/restapi/tree/main/jwt).
17-
//! - Includes a tls asset generator tool ([./certs/generate-tls-assets.sh](https://github.com/jay-johnson/restapi/blob/main/certs/generate-tls-assets.sh)) for building self-signed tls assets (requires docker).
18-
//! - The postgres database requires each client include the postgres tls certificate authority file for encrypting data in-transit.
16+
//!
17+
//! ### Auth
18+
//!
19+
//! - User authentication enabled by default
20+
//! - Default JWT signing keys included with [documentation for building new keys as needed](https://github.com/jay-johnson/restapi/tree/main/jwt).
21+
//!
22+
//! ### Database
23+
//!
1924
//! - The rest api server utilizes postgres with a [bb8 client threadpool](https://github.com/djc/bb8).
25+
//! - The postgres database requires each client connection include the postgres tls certificate authority file for encrypting data in-transit.
2026
//! - Includes [pg4admin](https://www.pgadmin.org/docs/pgadmin4/latest/index.html) for database management in a browser (deployed with docker compose).
2127
//!
22-
//! ### TLS Encryption Status
28+
//! ### TLS Encryption
29+
//!
30+
//! - Includes a tls asset generator tool ([./certs/generate-tls-assets.sh](https://github.com/jay-johnson/restapi/blob/main/certs/generate-tls-assets.sh)) for building self-signed tls assets (requires docker).
31+
//!
32+
//! #### Ingress
2333
//!
2434
//! Component | Status
2535
//! ---------------- | ------
2636
//! Rest API Server | Listening for encrypted client connections on tcp port **3000**
27-
//! JWT | Encrypting and decrypting tokens with [ECDSA using SHA-256](https://docs.rs/jsonwebtoken/latest/jsonwebtoken/enum.Algorithm.html#variant.ES256)
2837
//! Postgres | Listening for encrypted client connections on tcp port **5432** (tls Certificate Authority required)
2938
//! pgAdmin | Listening for encrypted HTTP client connections on tcp port **5433**
30-
//! AWS S3 | Encrypted at rest with [AES256](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)
3139
//!
3240
//! ## Getting Started
3341
//!
@@ -44,21 +52,17 @@
4452
//!
4553
//! Here's how to generate them under the ``./certs`` directory:
4654
//!
47-
//! <a href="https://asciinema.org/a/473131?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473131.png"/></a>
48-
//!
4955
//! ```bash
5056
//! cd certs
5157
//! ./generate-tls-assets.sh -f -c ./configs/dev-network.yml
5258
//! cd ..
5359
//! ```
5460
//!
55-
//! ### Generate JWT Keys
56-
//!
57-
//! Authentication using JWT requires encrypting and decrypting using your own keys. Please refer to the [How to build JWT private and public keys for the jsonwebtokens crate doc](./certs/README.md) for more information.
61+
//! <a href="https://asciinema.org/a/473131?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473131.png"/></a>
5862
//!
59-
//! Here's how to generate the jwt keys under the ``./jwt`` directory:
63+
//! ### Generate JWT Keys
6064
//!
61-
//! <a href="https://asciinema.org/a/473132?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473132.png"/></a>
65+
//! This repo includes default JWT signing keys, but you should generate your own signing keys under the ``./jwt`` directory with these commands:
6266
//!
6367
//! ```bash
6468
//! cd jwt
@@ -68,6 +72,10 @@
6872
//! cd ..
6973
//! ```
7074
//!
75+
//! <a href="https://asciinema.org/a/473132?autoplay=1" width="600" height="400" target="_blank"><img src="https://asciinema.org/a/473132.png"/></a>
76+
//!
77+
//! Please refer to the [How to build JWT private and public keys for the jsonwebtokens crate doc](./certs/README.md) for more information.
78+
//!
7179
//! ### Build the Postgres docker image
7280
//!
7381
//! Please refer to the [Build and Deploy a Secured Postgres backend doc](./docker/db/README.md) for more information.
@@ -83,7 +91,7 @@
8391
//! ### Run API Server
8492
//!
8593
//! ```bash
86-
//! cargo run --example server
94+
//! export RUST_BACKTRACE=1 && export RUST_LOG=info && ./target/debug/examples/server
8795
//! ```
8896
//!
8997
//! ## Supported APIs
@@ -225,7 +233,7 @@
225233
//! ## Build and run the example server
226234
//!
227235
//! ```bash
228-
//! time cargo build --example server && export RUST_BACKTRACE=1 && export RUST_LOG=info && time ./target/debug/examples/server
236+
//! cargo build --example server && export RUST_BACKTRACE=1 && export RUST_LOG=info && ./target/debug/examples/server
229237
//! ```
230238
//!
231239
//! # Integration Tests Using curl Guide

0 commit comments

Comments
 (0)