about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 778aa4a..ce654df 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,9 +39,27 @@ async fn main() -> Result<(), std::io::Error> {
             std::process::exit(1)
         }
     }
+    let authorization_endpoint: Url;
+    match env::var("AUTHORIZATION_ENDPOINT") {
+        Ok(val) => {
+            debug!("Auth endpoint: {}", val);
+            match Url::parse(&val) {
+                Ok(val) => authorization_endpoint = val,
+                _ => {
+                    error!("Authorization endpoint URL cannot be parsed, aborting.");
+                    std::process::exit(1)
+                }
+            }
+        },
+        Err(_) => {
+            error!("AUTHORIZATION_ENDPOINT is not set, will not be able to confirm token and ID requests using IndieAuth!");
+            std::process::exit(1)
+        }
+    }
+
     let media_endpoint: Option<String> = env::var("MEDIA_ENDPOINT").ok();
 
     let host = env::var("SERVE_AT").ok().unwrap_or_else(|| "0.0.0.0:8080".to_string());
-    let app = micropub::get_app_with_redis(token_endpoint, redis_uri, media_endpoint).await;
+    let app = micropub::get_app_with_redis(token_endpoint, authorization_endpoint, redis_uri, media_endpoint).await;
     app.listen(host).await
-}
\ No newline at end of file
+}