Skip to content

Commit ca04c19

Browse files
committed
feat: Add a username + password protected UI to manage torrents
1 parent 3512777 commit ca04c19

5 files changed

Lines changed: 792 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ url = "2.5"
4242
regex = "1.12"
4343
rusqlite = { version = "0.39", features = ["bundled"] }
4444
dirs = "6.0.0"
45+
minijinja = "2.20.0"
46+
base64 = "0.22.1"

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod settings;
2020
mod squire;
2121
mod swagger;
2222
mod telegram;
23+
mod ui;
2324

2425
/// Contains entrypoint and initializer settings to trigger the asynchronous `HTTPServer`
2526
///
@@ -92,7 +93,8 @@ pub async fn start() -> std::io::Result<()> {
9293
.route("/torrent", web::delete().to(api::delete_torrent))
9394
.route("/swagger", web::get().to(swagger::redirector))
9495
.route("/ui", web::get().to(swagger::redirector))
95-
.route("/", web::get().to(swagger::redirector))
96+
.route("/authenticator", web::post().to(ui::authenticator))
97+
.route("/", web::get().to(ui::index_page))
9698
.service(swagger::service())
9799
})
98100
.bind((host, port))?

src/settings.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct Config {
5151
// RuTorrent API config
5252
pub host: String,
5353
pub port: u16,
54+
pub username: String,
55+
pub password: String,
56+
5457
pub apikey: String,
5558
pub workers: usize,
5659

@@ -100,6 +103,9 @@ impl Config {
100103
let port = squire::get_env_var("port", Some("3000"))
101104
.parse::<u16>()
102105
.unwrap();
106+
let username = squire::get_env_var("username", None);
107+
let password = squire::get_env_var("password", None);
108+
103109
let apikey = squire::get_env_var("apikey", None);
104110
if apikey.is_empty() {
105111
startup_error("'apikey' is empty");
@@ -185,6 +191,8 @@ impl Config {
185191
Self {
186192
host,
187193
port,
194+
username,
195+
password,
188196
apikey,
189197
workers,
190198
qbit_url,

0 commit comments

Comments
 (0)