Skip to content

Commit

Permalink
updating readme and adding constants for ssl cert paths
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpmyers committed Jun 27, 2023
1 parent e44d7a0 commit 27bb5bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
29 changes: 2 additions & 27 deletions application/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loremaster - Backend

The appilcation is primarily written in Rust.
The application is primarily written in Rust.

## Tech Stack

Expand Down Expand Up @@ -32,38 +32,13 @@ Docker compose command
docker-compose -f infrastructure/docker-compose.yml up
```

### Configuration File Schema - Loremaster.toml

```toml
TestField = "TestValue"

[local_debug]

[local_debug.database]
POSTGRESQL = "postgres://<user_name>:<password>@localhost/postgres"

[local_debug.encryption]
HASH_ITERATIONS = 1
SITE_SECRET = "<secret>"

[local_debug.web_server]
IPV4_ADDRESS = [127, 0, 0, 0]
PORT = 8000

[dev]

[qa]

[prod]
```

You can generate a site secret for testing with the following openssl command:

```bash
openssl rand -base64 64
```

Generate SSL/TLS certs
Generate SSL/TLS certs

(rename to cert.pem/key.pem)

Expand Down
10 changes: 8 additions & 2 deletions application/src/api/web_server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::api;
use crate::configuration::application::LoremasterWebServerConfiguration;
use crate::utility::constants::files::FRONTEND_DIST_PATH;
use crate::utility::constants::files::{
FRONTEND_DIST_PATH, SSL_CERT_FILE_PATH, SSL_CERT_KEY_FILE_PATH, SSL_CERT_PATH,
};
use crate::utility::constants::{
DEV_RELAYING_PARTY_ID, LOCAL_HOST_RELAYING_PARTY_ID, QA_RELAYING_PARTY_ID, RELAYING_PARTY,
RELAYING_PARTY_ID,
Expand Down Expand Up @@ -102,7 +104,11 @@ async fn serve(
}

async fn get_tls_configuration() -> Result<RustlsConfig> {
Ok(RustlsConfig::from_pem_file("certs/cert.pem", "certs/key.pem").await?)
Ok(RustlsConfig::from_pem_file(
format!("{}/{}", SSL_CERT_PATH, SSL_CERT_FILE_PATH),
format!("{}/{}", SSL_CERT_PATH, SSL_CERT_KEY_FILE_PATH),
)
.await?)
}

#[derive(Clone)]
Expand Down
3 changes: 3 additions & 0 deletions application/src/utility/constants/files.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// pub const INDEX_PATH: &str = "frontend/dist/index.html";
// pub const FAVICON_PATH: &str = "./frontend/resources/favicon_io/favicon.ico";
pub const FRONTEND_DIST_PATH: &str = "frontend/dist/exported";
pub const SSL_CERT_PATH: &str = "./certs";
pub const SSL_CERT_FILE_PATH: &str = "cert.pem";
pub const SSL_CERT_KEY_FILE_PATH: &str = "key.pem";

0 comments on commit 27bb5bd

Please sign in to comment.