diff options
Diffstat (limited to 'rs/git-lfs-authenticate/src')
-rw-r--r-- | rs/git-lfs-authenticate/src/main.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/rs/git-lfs-authenticate/src/main.rs b/rs/git-lfs-authenticate/src/main.rs index 76f2edd..db95923 100644 --- a/rs/git-lfs-authenticate/src/main.rs +++ b/rs/git-lfs-authenticate/src/main.rs | |||
@@ -195,7 +195,7 @@ fn main() -> ExitCode { | |||
195 | } | 195 | } |
196 | }; | 196 | }; |
197 | 197 | ||
198 | let (repo_name, op) = match parse_cmdline() { | 198 | let (repo_name, operation) = match parse_cmdline() { |
199 | Ok(args) => args, | 199 | Ok(args) => args, |
200 | Err(e) => { | 200 | Err(e) => { |
201 | eprintln!("Error: {e}\n"); | 201 | eprintln!("Error: {e}\n"); |
@@ -210,15 +210,13 @@ fn main() -> ExitCode { | |||
210 | return ExitCode::FAILURE; | 210 | return ExitCode::FAILURE; |
211 | } | 211 | } |
212 | 212 | ||
213 | let expires_in = Duration::from_secs(5 * 60); | 213 | let expires_at = Utc::now() + Duration::from_secs(5 * 60); |
214 | let expires_at = Utc::now() + expires_in; | ||
215 | |||
216 | let Some(tag) = common::generate_tag( | 214 | let Some(tag) = common::generate_tag( |
217 | common::Claims { | 215 | common::Claims { |
218 | auth_type: common::AuthType::GitLfsAuthenticate, | 216 | auth_type: common::AuthType::GitLfsAuthenticate, |
219 | repo_path: &repo_name, | 217 | repo_path: &repo_name, |
220 | expires_at, | 218 | expires_at, |
221 | operation: op, | 219 | operation, |
222 | }, | 220 | }, |
223 | key, | 221 | key, |
224 | ) else { | 222 | ) else { |
@@ -227,12 +225,12 @@ fn main() -> ExitCode { | |||
227 | }; | 225 | }; |
228 | 226 | ||
229 | println!( | 227 | println!( |
230 | "{{\"header\":{{\"Authorization\":\"Gitolfs3-Hmac-Sha256 {tag}\"}},\ | 228 | "{{\"header\":{{\"Authorization\":\"Gitolfs3-Hmac-Sha256 {tag} {}\"}},\ |
231 | \"expires_at\":\"{}\",\"href\":\"{}{}/info/lfs?p=1&te={}\"}}", | 229 | \"expires_at\":\"{}\",\"href\":\"{}{}/info/lfs\"}}", |
230 | expires_at.timestamp(), | ||
232 | common::EscJsonFmt(&expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)), | 231 | common::EscJsonFmt(&expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)), |
233 | common::EscJsonFmt(&config.href_base), | 232 | common::EscJsonFmt(&config.href_base), |
234 | common::EscJsonFmt(&repo_name), | 233 | common::EscJsonFmt(&repo_name), |
235 | expires_at.timestamp() | ||
236 | ); | 234 | ); |
237 | 235 | ||
238 | ExitCode::SUCCESS | 236 | ExitCode::SUCCESS |