repo init, simplistic salvo hello world

This commit is contained in:
2024-12-21 21:05:53 -06:00
commit cc3d1759a7
5 changed files with 2536 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

2487
Cargo.lock generated Normal file
View File

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@@ -0,0 +1,10 @@
[package]
name = "dynamic-preauth"
version = "0.1.0"
edition = "2021"
[dependencies]
salvo = "0.74.3"
tokio = { version = "1", features = ["macros"] }
tracing = "0.1"
tracing-subscriber = "0.3"

21
README.md Normal file
View File

@@ -0,0 +1,21 @@
# dynamic-preauth
I had an idea that executables could be pre-authenticated by the server before being ran, with no interaction from the user.
This is a proof of concept of that idea, built in Rust.
## How it works
1. The server is provided a fully built template executable on startup.
2. Users can 'authenticate' themselves and then download the executable.
3. Before the executable is served to the user, the server will inject the user's authentication token into the executable by modifying the binary.
4. The modified binary is then served to the user.
5. A constant time string in the binary, now modified, is used to authenticate the binary's requests to the server.
## Implementation
- The testing binary is built in Docker, and is a simple Rust binary that sends a GET request to the server with the authentication token.

17
src/main.rs Normal file
View File

@@ -0,0 +1,17 @@
use salvo::prelude::*;
#[handler]
async fn hello() -> &'static str {
"Hello World"
}
#[tokio::main]
async fn main() {
let port = std::env::var("PORT").unwrap_or_else(|_| "5800".to_string());
let addr = format!("127.0.0.1:{}", port);
tracing_subscriber::fmt().init();
let router = Router::new().get(hello);
let acceptor = TcpListener::new(addr).bind().await;
Server::new(acceptor).serve(router).await;
}