This commit is contained in:
Alex Janka 2024-02-11 14:16:43 +11:00
commit 456161a02d
6 changed files with 1693 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1635
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

11
Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "auth-callback-watcher"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.5.0"
log = "0.4.20"
env_logger = "0.11.1"

2
Rocket.toml Normal file
View file

@ -0,0 +1,2 @@
[default]
port = 7887

28
src/main.rs Normal file
View file

@ -0,0 +1,28 @@
#[macro_use]
extern crate rocket;
#[get("/authenticated/<_..>")]
fn authenticated(uri: &rocket::http::uri::Origin) -> &'static str {
log::error!("AUTHENTICATED: {uri:?}");
"authentication successful 🙂"
}
#[get("/deauthenticated/<_..>")]
fn deauthenticated(uri: &rocket::http::uri::Origin) -> &'static str {
log::error!("DEAUTHENTICATED: {uri:?}");
"deauthentication successful 🙂"
}
#[launch]
fn rocket() -> _ {
env_logger::builder()
.format_module_path(false)
.format_timestamp(
if std::env::var("LOG_TIMESTAMP").is_ok_and(|v| v == "false") {
None
} else {
Some(env_logger::TimestampPrecision::Seconds)
},
)
.init();
rocket::build().mount("/", routes![authenticated, deauthenticated])
}

View file

@ -0,0 +1,16 @@
[Unit]
Description=Tesla Auth Callback Watcher
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=10s
User=tesla
Environment="RUST_LOG=error,warn"
Environment="LOG_TIMESTAMP=false"
ExecStart=/usr/bin/auth-callback-watcher
[Install]
WantedBy=multi-user.target