aboutsummaryrefslogtreecommitdiffstats
path: root/git-lfs-authenticate
diff options
context:
space:
mode:
Diffstat (limited to 'git-lfs-authenticate')
-rw-r--r--git-lfs-authenticate/Cargo.toml1
-rw-r--r--git-lfs-authenticate/src/main.rs20
2 files changed, 13 insertions, 8 deletions
diff --git a/git-lfs-authenticate/Cargo.toml b/git-lfs-authenticate/Cargo.toml
index f4ab4d7..15feba8 100644
--- a/git-lfs-authenticate/Cargo.toml
+++ b/git-lfs-authenticate/Cargo.toml
@@ -7,3 +7,4 @@ edition = "2021"
7anyhow = "1.0" 7anyhow = "1.0"
8chrono = "0.4" 8chrono = "0.4"
9common = { path = "../common" } 9common = { path = "../common" }
10serde_json = "1"
diff --git a/git-lfs-authenticate/src/main.rs b/git-lfs-authenticate/src/main.rs
index accc37f..3101c92 100644
--- a/git-lfs-authenticate/src/main.rs
+++ b/git-lfs-authenticate/src/main.rs
@@ -1,5 +1,6 @@
1use anyhow::{anyhow, bail, Result}; 1use anyhow::{anyhow, bail, Result};
2use chrono::Utc; 2use chrono::Utc;
3use serde_json::json;
3use std::{process::ExitCode, time::Duration}; 4use std::{process::ExitCode, time::Duration};
4 5
5fn main() -> ExitCode { 6fn main() -> ExitCode {
@@ -39,14 +40,17 @@ fn main() -> ExitCode {
39 return ExitCode::FAILURE; 40 return ExitCode::FAILURE;
40 }; 41 };
41 42
42 println!( 43 let response = json!({
43 "{{\"header\":{{\"Authorization\":\"Gitolfs3-Hmac-Sha256 {tag} {}\"}},\ 44 "header": {
44 \"expires_at\":\"{}\",\"href\":\"{}{}/info/lfs\"}}", 45 "Authorization": format!(
45 expires_at.timestamp(), 46 "Gitolfs3-Hmac-Sha256 {tag} {}",
46 common::EscJsonFmt(&expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)), 47 expires_at.timestamp()
47 common::EscJsonFmt(&config.href_base), 48 ),
48 common::EscJsonFmt(&repo_name), 49 },
49 ); 50 "expires_at": expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
51 "href": format!("{}{}/info/lfs", config.href_base, repo_name),
52 });
53 println!("{}", response.to_string());
50 54
51 ExitCode::SUCCESS 55 ExitCode::SUCCESS
52} 56}