diff options
Diffstat (limited to 'git-lfs-authenticate')
-rw-r--r-- | git-lfs-authenticate/Cargo.toml | 1 | ||||
-rw-r--r-- | git-lfs-authenticate/src/main.rs | 20 |
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" | |||
7 | anyhow = "1.0" | 7 | anyhow = "1.0" |
8 | chrono = "0.4" | 8 | chrono = "0.4" |
9 | common = { path = "../common" } | 9 | common = { path = "../common" } |
10 | serde_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 @@ | |||
1 | use anyhow::{anyhow, bail, Result}; | 1 | use anyhow::{anyhow, bail, Result}; |
2 | use chrono::Utc; | 2 | use chrono::Utc; |
3 | use serde_json::json; | ||
3 | use std::{process::ExitCode, time::Duration}; | 4 | use std::{process::ExitCode, time::Duration}; |
4 | 5 | ||
5 | fn main() -> ExitCode { | 6 | fn 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 | } |