diff options
author | Rutger Broekhoff | 2024-01-19 15:20:19 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2024-01-19 15:20:19 +0100 |
commit | 0956476fda305f48644e53305e12ae46cb67a32b (patch) | |
tree | 26724c0f62c8c2fee5eeae7a1f7853245e155c30 /rs/git-lfs-authenticate | |
parent | fa2a763777d775a853ec41d73efb345e304c81e7 (diff) | |
download | gitolfs3-0956476fda305f48644e53305e12ae46cb67a32b.tar.gz gitolfs3-0956476fda305f48644e53305e12ae46cb67a32b.zip |
Implement crude batch API authorization
Diffstat (limited to 'rs/git-lfs-authenticate')
-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 |